preprocess_config_t Derived Type

type, public, extends(serializable_t) :: preprocess_config_t

Configuration meta data for a preprocessor


Components

Type Visibility Attributes Name Initial
type(string_t), public, allocatable :: directories(:)

Directories to search for files to be preprocessed

type(string_t), public, allocatable :: macros(:)

Macros to be defined for the preprocessor

character(len=:), public, allocatable :: name

Name of the preprocessor

type(string_t), public, allocatable :: suffixes(:)

Suffixes of the files to be preprocessed


Type-Bound Procedures

procedure, public :: add_config

  • private subroutine add_config(this, that)

    Add preprocessor settings

    Arguments

    Type IntentOptional Attributes Name
    class(preprocess_config_t), intent(inout) :: this
    type(preprocess_config_t), intent(in) :: that

procedure, public :: destroy

Operations

  • private elemental subroutine destroy(this)

    Clean preprocessor structure

    Arguments

    Type IntentOptional Attributes Name
    class(preprocess_config_t), intent(inout) :: this

generic, public :: dump => dump_to_toml, dump_to_file, dump_to_unit

  • private subroutine srcfile_dump_to_toml(self, table, error)

    Dump dependency to toml table

    Arguments

    Type IntentOptional Attributes Name
    class(srcfile_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

  • private subroutine dump_to_file(self, file, error, json)

    Write serializable object to file

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    character(len=*), intent(in) :: file

    File name

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format

  • private subroutine dump_to_unit(self, unit, error, json)

    Write serializable object to a formatted Fortran unit

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    integer, intent(in) :: unit

    Formatted unit

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format requested?

procedure, public :: dump_to_toml

  • private subroutine dump_to_toml(self, table, error)

    Dump install config to toml table

    Arguments

    Type IntentOptional Attributes Name
    class(preprocess_config_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

procedure, public :: info

Print information on this instance

  • private subroutine info(self, unit, verbosity)

    Write information on this instance

    Arguments

    Type IntentOptional Attributes Name
    class(preprocess_config_t), intent(in) :: self

    Instance of the preprocess configuration

    integer, intent(in) :: unit

    Unit for IO

    integer, intent(in), optional :: verbosity

    Verbosity of the printout

procedure, public :: is_cpp

Properties

  • private function is_cpp(this)

    Arguments

    Type IntentOptional Attributes Name
    class(preprocess_config_t), intent(in) :: this

    Return Value logical

procedure, public :: is_fypp

  • private function is_fypp(this)

    Arguments

    Type IntentOptional Attributes Name
    class(preprocess_config_t), intent(in) :: this

    Return Value logical

generic, public :: load => load_from_toml, load_from_file, load_from_unit

  • private subroutine srcfile_load_from_toml(self, table, error)

    Read dependency from toml table (no checks made at this stage)

    Arguments

    Type IntentOptional Attributes Name
    class(srcfile_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

  • private subroutine load_from_file(self, file, error, json)

    Read dependency tree from file

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    character(len=*), intent(in) :: file

    File name

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format

  • private subroutine load_from_unit(self, unit, error, json)

    Read dependency tree from file init JSON interpreter Read object from TOML table

    use default TOML parser

    Read object from TOML table

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    integer, intent(in) :: unit

    File name

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format

procedure, public :: load_from_toml

  • private subroutine load_from_toml(self, table, error)

    Read install config from toml table (no checks made at this stage)

    Arguments

    Type IntentOptional Attributes Name
    class(preprocess_config_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

generic, public :: operator(==) => serializable_is_same

  • private function srcfile_is_same(this, that)

    Check that two source files are equal All checks passed!

    Arguments

    Type IntentOptional Attributes Name
    class(srcfile_t), intent(in) :: this
    class(serializable_t), intent(in) :: that

    Return Value logical

procedure, public :: serializable_is_same => preprocess_is_same

Serialization interface

  • private function preprocess_is_same(this, that)

    All checks passed!

    Arguments

    Type IntentOptional Attributes Name
    class(preprocess_config_t), intent(in) :: this
    class(serializable_t), intent(in) :: that

    Return Value logical

procedure, public, non_overridable :: test_serialization

Test load/write roundtrip

  • private subroutine test_serialization(self, message, error)

    Test serialization of a serializable object Dump to scratch file Load from scratch file Check same

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self
    character(len=*), intent(in) :: message
    type(error_t), intent(out), allocatable :: error

Source Code

   type, extends(serializable_t) :: preprocess_config_t

      !> Name of the preprocessor
      character(len=:), allocatable :: name

      !> Suffixes of the files to be preprocessed
      type(string_t), allocatable :: suffixes(:)

      !> Directories to search for files to be preprocessed
      type(string_t), allocatable :: directories(:)

      !> Macros to be defined for the preprocessor
      type(string_t), allocatable :: macros(:)

   contains

      !> Print information on this instance
      procedure :: info

      !> Serialization interface
      procedure :: serializable_is_same => preprocess_is_same
      procedure :: dump_to_toml
      procedure :: load_from_toml

      !> Operations
      procedure :: destroy
      procedure :: add_config

      !> Properties
      procedure :: is_cpp
      procedure :: is_fypp

   end type preprocess_config_t