Section data of file INI.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(option), | private, | allocatable | :: | options(:) | Section options. |
||
character(len=:), | private, | allocatable | :: | sname | Section name. |
Overload section
name with a function returning a new (itiliazed) section instance.
Return a new (initiliazed) section instance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character, | intent(in), | optional | :: | section_name | Option name. |
New (initiliazed) section instance.
Add an option (scalar). Add an option (array).
Add an option (with scalar value).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val | Option value. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Add an option (with array value).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val(:) | Option value. |
||
character, | intent(in), | optional | :: | delimiter | Delimiter used for separating values. |
|
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Add an option (array).
Add an option (with array value).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val(:) | Option value. |
||
character, | intent(in), | optional | :: | delimiter | Delimiter used for separating values. |
|
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Add an option (scalar).
Add an option (with scalar value).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val | Option value. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Assignment overloading.
Assignment between two sections.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | lhs | Left hand side. |
||
type(section), | intent(in) | :: | rhs | Rigth hand side. |
Assignment overloading.
Assignment between two sections.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | lhs | Left hand side. |
||
type(section), | intent(in) | :: | rhs | Rigth hand side. |
Count option value(s).
Get the number of values of option into section data.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
character, | intent(in), | optional | :: | delimiter | Delimiter used for separating values. |
Number of values.
Free dynamic memory.
Free a option.
Free an option.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
Free all options.
Free all options.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
Get option value (scalar). Get option value (array).
Get option value (scalar).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(inout) | :: | val | Value. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Procedure for getting option value (array).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(inout) | :: | val(1:) | Value. |
||
character, | intent(in), | optional | :: | delimiter | Delimiter used for separating values. |
|
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Get option value (array).
Procedure for getting option value (array).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(inout) | :: | val(1:) | Value. |
||
character, | intent(in), | optional | :: | delimiter | Delimiter used for separating values. |
|
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Get option value (scalar).
Get option value (scalar).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(inout) | :: | val | Value. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Inquire if section has options.
Inquire is section has options (at least one).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
Inquire result.
Return the index of an option.
Return the index of the option matching the name passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
logical, | intent(in), | optional | :: | back | If back appears with the value true, the last matching index is returned. |
Index of searched section.
Loop over options.
Loop returning option name/value defined into section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
||
character(len=:), | intent(out), | allocatable | :: | option_pairs(:) | Couples option name/value [1:2]. |
Flag continuing the loop.
Return max len of option-name/values on all options.
Return the maximum number of characters between option-name/option-values on all options.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
Inquire result.
Return section name.
Equal operator overloading.
Equal to string logical operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | lhs | Left hand side. |
||
type(string), | intent(in) | :: | rhs | Right hand side. |
Opreator test result.
Equal to character logical operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | lhs | Left hand side. |
||
character(kind=CK,len=*), | intent(in) | :: | rhs | Right hand side. |
Opreator test result.
Return an option pairs.
Return an option pairs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Option data. |
||
integer, | intent(in) | :: | option_index | Option index. |
||
character(len=:), | intent(out), | allocatable | :: | pairs(:) | Option name/values pairs. |
Return the options number.
Return the options number.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
Options number.
Parse section data.
Gett section data from a source string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | sep | Separator of option name/value. |
||
type(string), | intent(inout) | :: | source | String containing section data. |
||
integer(kind=I4P), | intent(out) | :: | error | Error code. |
Get section name.
Get section name from a source string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
type(string), | intent(in) | :: | source | String containing section data. |
||
integer(kind=I4P), | intent(out) | :: | error | Error code. |
Get section options.
Get section options from a source string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | sep | Separator of option name/value. |
||
type(string), | intent(inout) | :: | source | String containing section data. |
||
integer(kind=I4P), | intent(out) | :: | error | Error code. |
Pretty print data.
Print data with a pretty format.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
||
integer(kind=I4P), | intent(in) | :: | unit | Logic unit. |
||
logical, | intent(in) | :: | retain_comments | Flag for retaining eventual comments. |
||
character, | intent(in), | optional | :: | pref | Prefixing string. |
|
integer(kind=I4P), | intent(out), | optional | :: | iostat | IO error. |
|
character, | intent(out), | optional | :: | iomsg | IO error message. |
Sanitize source.
Sanitize source.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character, | intent(in) | :: | sep | Separator of option name/value. |
||
type(string), | intent(inout) | :: | source | String containing option data. |
||
integer(kind=I4P), | intent(out) | :: | error | Error code. |
Save data.
Save data.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | self | Section data. |
||
integer(kind=I4P), | intent(in) | :: | unit | Logic unit. |
||
logical, | intent(in) | :: | retain_comments | Flag for retaining eventual comments. |
||
integer(kind=I4P), | intent(out), | optional | :: | iostat | IO error. |
|
character, | intent(out), | optional | :: | iomsg | IO error message. |
Equal to character logical operator.
Equal to character logical operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | lhs | Left hand side. |
||
character(kind=CK,len=*), | intent(in) | :: | rhs | Right hand side. |
Opreator test result.
Equal to string logical operator.
Equal to string logical operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(in) | :: | lhs | Left hand side. |
||
type(string), | intent(in) | :: | rhs | Right hand side. |
Opreator test result.
Set option value (scalar). Set option value (array).
Set option value (scalar).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val | Value. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Set option value (array).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val(:) | Value. |
||
character, | intent(in), | optional | :: | delimiter | Delimiter used for separating values. |
|
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Set option value (array).
Set option value (array).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val(:) | Value. |
||
character, | intent(in), | optional | :: | delimiter | Delimiter used for separating values. |
|
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Set option value (scalar).
Set option value (scalar).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(section), | intent(inout) | :: | self | Section data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val | Value. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
type :: section
!< Section data of file INI.
private
character(len=:), allocatable :: sname !< Section name.
type(option), allocatable :: options(:) !< Section options.
contains
! public methods
generic :: add => add_option, & !< Add an option (scalar).
add_a_option !< Add an option (array).
procedure, pass(self) :: count_values !< Count option value(s).
procedure, pass(self) :: free !< Free dynamic memory.
procedure, pass(self) :: free_options !< Free all options.
procedure, pass(self) :: free_option !< Free a option.
generic :: get => get_option, & !< Get option value (scalar).
get_a_option !< Get option value (array).
procedure, pass(self) :: has_options !< Inquire if section has options.
procedure, pass(self) :: index => index_option !< Return the index of an option.
procedure, pass(self) :: loop !< Loop over options.
procedure, pass(self) :: max_chars_len !< Return max len of option-name/values on all options.
procedure, pass(self) :: name !< Return section name.
procedure, pass(self) :: options_number !< Return the options number.
procedure, pass(self) :: option_pairs !< Return an option pairs.
procedure, pass(self) :: parse !< Parse section data.
procedure, pass(self) :: print => print_section !< Pretty print data.
generic :: set => set_option, & !< Set option value (scalar).
set_a_option !< Set option value (array).
procedure, pass(self) :: save => save_section !< Save data.
! operators overloading
generic :: assignment(=) => assign_section !< Assignment overloading.
generic :: operator(==) => section_eq_string, &
section_eq_character !< Equal operator overloading.
! private methods
procedure, private, pass(self) :: add_option !< Add an option (scalar).
procedure, private, pass(self) :: add_a_option !< Add an option (array).
procedure, private, pass(self) :: get_option !< Get option value (scalar).
procedure, private, pass(self) :: get_a_option !< Get option value (array).
procedure, private, pass(self) :: parse_name !< Get section name.
procedure, private, pass(self) :: parse_options !< Get section options.
procedure, private, nopass :: sanitize_source !< Sanitize source.
procedure, private, pass(self) :: set_option !< Set option value (scalar).
procedure, private, pass(self) :: set_a_option !< Set option value (array).
! assignments
procedure, private, pass(lhs) :: assign_section !< Assignment overloading.
! logical operators
procedure, private, pass(lhs) :: section_eq_string !< Equal to string logical operator.
procedure, private, pass(lhs) :: section_eq_character !< Equal to character logical operator.
endtype section