INI file class.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=I4P), | private | :: | Ns | = | 0 | Number of sections. |
|
character(len=:), | public, | allocatable | :: | filename | File name |
||
character(len=1), | private | :: | opt_sep | = | DEF_OPT_SEP | Separator character of option name/value. |
|
type(section), | private, | allocatable | :: | sections(:) | Sections. |
Add a section. Add an option to a section (scalar). Add an option to a section (array).
Add a section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
|
character, | intent(in) | :: | section_name | Section name. |
Add an option (with scalar value).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
|
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val | Option value. |
Add an option (with array value).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
|
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val(1:) | Option value. |
Add an option to a section (array).
Add an option (with array value).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
|
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val(1:) | Option value. |
Add an option to a section (scalar).
Add an option (with scalar value).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
|
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(in) | :: | val | Option value. |
Add a section.
Add a section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
|
character, | intent(in) | :: | section_name | Section name. |
Assignment overloading.
Assignment between two INI files.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | lhs | Left hand side. |
||
type(file_ini), | intent(in) | :: | rhs | Rigth hand side. |
Procedure for section assignment overloading.
Assignment between two INI files.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | lhs | Left hand side. |
||
type(file_ini), | 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(file_ini), | intent(in) | :: | self | File data. |
||
character, | intent(in), | optional | :: | delimiter | Delimiter used for separating values. |
|
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
Number of values.
Remove (freeing) an option of a section. Remove (freeing) a section.
Free all options of a section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
Free all options of a section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
Free dynamic memory destroyng file data.
Free an option of a section.
Free all options of a section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
Free all options. Free all options of a section. Free an option of a section.
Free all options of all sections.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
Free all options of a section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
Free all options of a section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
Free all options of all sections.
Free all options of all sections.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
Free all options of a section.
Free all options of a section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
Free a section.
Free all options of a section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
Get option value (scalar). Get option value (array).
Get option value (scalar).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(inout) | :: | val | Value. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Get option value (array)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
||
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).
Get option value (array)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
||
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 list of pairs option name/value.
Get option value (scalar).
Get option value (scalar).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
||
class(*), | intent(inout) | :: | val | Value. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Get sections names list.
Get sections names list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character(len=:), | intent(out), | allocatable | :: | list(:) | Sections names list. |
Inquire the presence of an option.
Inquire the presence of (at least one) option with the name passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character, | intent(in) | :: | option_name | Option name. |
||
character, | intent(inout), | optional | :: | section_name | Section name. |
Inquiring flag.
Inquire the presence of a section.
Inquire the presence of (at least one) section with the name passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
Inquiring flag.
Return the index of a section. Return the index of an option.
Return the index of the section matching the name passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
logical, | intent(in), | optional | :: | back | If back appears with the value true, the last matching index is returned. |
|
character, | intent(in) | :: | section_name | Section name. |
Index of searched section.
Return the index of the option (inside a section) matching the name(s) passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
logical, | intent(in), | optional | :: | back | If back appears with the value true, the last matching index is returned. |
|
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
Index of searched section.
Return the index of an option.
Return the index of the option (inside a section) matching the name(s) passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
logical, | intent(in), | optional | :: | back | If back appears with the value true, the last matching index is returned. |
|
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
Index of searched section.
Return the index of a section.
Return the index of the section matching the name passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
logical, | intent(in), | optional | :: | back | If back appears with the value true, the last matching index is returned. |
|
character, | intent(in) | :: | section_name | Section name. |
Index of searched section.
Initialize file.
Initialize file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
character, | intent(in), | optional | :: | filename | File name. |
Load file data.
Get file data from a file or a source string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
character(len=1), | intent(in), | optional | :: | separator | Separator of options name/value. |
|
character, | intent(in), | optional | :: | filename | File name. |
|
character, | intent(in), | optional | :: | source | File source contents. |
|
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Loop over options of a section. Loop over all options.
Loop returning option name/value defined into section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
||
character(len=:), | intent(out), | allocatable | :: | option_pairs(:) | Pairs option name/value [1:2]. |
Flag continuing the loop.
Loop returning option name/value defined into all sections.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character(len=:), | intent(out), | allocatable | :: | option_pairs(:) | Pairs option name/value [1:2]. |
Flag continuing the loop.
Loop over all options.
Loop returning option name/value defined into all sections.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character(len=:), | intent(out), | allocatable | :: | option_pairs(:) | Pairs option name/value [1:2]. |
Flag continuing the loop.
Loop over options of a section.
Loop returning option name/value defined into section.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
character, | intent(in) | :: | section_name | Section name. |
||
character(len=:), | intent(out), | allocatable | :: | option_pairs(:) | Pairs option name/value [1:2]. |
Flag continuing the loop.
Parse file data.
Parse file either from the self source data or from a source string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
type(string), | intent(in) | :: | source | String source. |
||
integer(kind=I4P), | intent(out), | optional | :: | error | Error code. |
Pretty printing data.
Print data with a pretty format.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
integer(kind=I4P), | intent(in) | :: | unit | Logic unit. |
||
character, | intent(in), | optional | :: | pref | Prefixing string. |
|
logical, | intent(in), | optional | :: | retain_comments | Flag for retaining eventual comments. |
|
integer(kind=I4P), | intent(out), | optional | :: | iostat | IO error. |
|
character, | intent(out), | optional | :: | iomsg | IO error message. |
Save data.
Save data.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(inout) | :: | self | File data. |
||
logical, | intent(in), | optional | :: | retain_comments | Flag for retaining eventual comments. |
|
integer(kind=I4P), | intent(out), | optional | :: | iostat | IO error. |
|
character, | intent(out), | optional | :: | iomsg | IO error message. |
|
character, | intent(in), | optional | :: | filename | File name. |
Get section name once provided an index.
Get section name once an index (valid) is provided.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
integer(kind=I4P), | intent(in) | :: | section_index | Section index. |
Section name.
type :: file_ini
!< INI file class.
private
character(len=:), allocatable, public :: filename !< File name
integer(I4P) :: Ns = 0 !< Number of sections.
character(1) :: opt_sep = DEF_OPT_SEP !< Separator character of option name/value.
type(section), allocatable :: sections(:) !< Sections.
contains
! public methods
generic :: add => add_section, & !< Add a section.
add_option, & !< Add an option to a section (scalar).
add_a_option !< Add an option to a section (array).
procedure, pass(self) :: count_values !< Count option value(s).
generic :: del => free_option_of_section, & !< Remove (freeing) an option of a section.
free_section !< Remove (freeing) a section.
procedure, pass(self) :: free !< Free dynamic memory destroyng file data.
generic :: free_options => free_options_all, & !< Free all options.
free_options_of_section, & !< Free all options of a section.
free_option_of_section !< Free an option of a section.
generic :: get => get_option, & !< Get option value (scalar).
get_a_option !< Get option value (array).
procedure, pass(self) :: get_items !< Get list of pairs option name/value.
procedure, pass(self) :: get_sections_list !< Get sections names list.
procedure, pass(self) :: initialize !< Initialize file.
procedure, pass(self) :: has_option !< Inquire the presence of an option.
procedure, pass(self) :: has_section !< Inquire the presence of a section.
generic :: index => index_section, & !< Return the index of a section.
index_option !< Return the index of an option.
procedure, pass(self) :: load !< Load file data.
generic :: loop => loop_options_section, & !< Loop over options of a section.
loop_options !< Loop over all options.
procedure, pass(self) :: print => print_file_ini !< Pretty printing data.
procedure, pass(self) :: save => save_file_ini !< Save data.
procedure, pass(self) :: section => section_file_ini !< Get section name once provided an index.
! operators overloading
generic :: assignment(=) => assign_file_ini !< Procedure for section assignment overloading.
! private methods
procedure, private, pass(self) :: add_a_option !< Add an option to a section (array).
procedure, private, pass(self) :: add_option !< Add an option to a section (scalar).
procedure, private, pass(self) :: add_section !< Add a section.
procedure, private, pass(self) :: free_options_all !< Free all options of all sections.
procedure, private, pass(self) :: free_options_of_section !< Free all options of a section.
procedure, private, pass(self) :: free_option_of_section !< Free an option of a section.
procedure, private, pass(self) :: free_section !< Free a section.
procedure, private, pass(self) :: get_a_option !< Get option value (array).
procedure, private, pass(self) :: get_option !< Get option value (scalar).
procedure, private, pass(self) :: index_option !< Return the index of an option.
procedure, private, pass(self) :: index_section !< Return the index of a section.
procedure, private, pass(self) :: loop_options !< Loop over all options.
procedure, private, pass(self) :: loop_options_section !< Loop over options of a section.
procedure, private, pass(self) :: parse !< Parse file data.
! assignments
procedure, private, pass(lhs) :: assign_file_ini !< Assignment overloading.
endtype file_ini