Skip to content

finer_file_ini_t

INI file class definition.

Source: src/lib/finer_file_ini_t.F90

Dependencies

Contents

Derived Types

file_ini

INI file class.

Components

NameTypeAttributesDescription
filenamecharacter(len=:)allocatableFile name
Nsinteger(kind=I4P)Number of sections.
opt_sepcharacter(len=1)Separator character of option name/value.
sectionstype(section)allocatableSections.

Type-Bound Procedures

NameAttributesDescription
addAdd a section.
count_valuespass(self)Count option value(s).
delRemove (freeing) an option of a section.
freepass(self)Free dynamic memory destroyng file data.
free_optionsFree all options.
getGet option value (scalar).
get_itemspass(self)Get list of pairs option name/value.
get_sections_listpass(self)Get sections names list.
initializepass(self)Initialize file.
has_optionpass(self)Inquire the presence of an option.
has_sectionpass(self)Inquire the presence of a section.
indexReturn the index of a section.
loadpass(self)Load file data.
loopLoop over options of a section.
printpass(self)Pretty printing data.
savepass(self)Save data.
sectionpass(self)Get section name once provided an index.
assignment(=)Procedure for section assignment overloading.
add_a_optionpass(self)Add an option to a section (array).
add_optionpass(self)Add an option to a section (scalar).
add_sectionpass(self)Add a section.
free_options_allpass(self)Free all options of all sections.
free_options_of_sectionpass(self)Free all options of a section.
free_option_of_sectionpass(self)Free an option of a section.
free_sectionpass(self)Free a section.
get_a_optionpass(self)Get option value (array).
get_optionpass(self)Get option value (scalar).
index_optionpass(self)Return the index of an option.
index_sectionpass(self)Return the index of a section.
loop_optionspass(self)Loop over all options.
loop_options_sectionpass(self)Loop over options of a section.
parsepass(self)Parse file data.
assign_file_inipass(lhs)Assignment overloading.

Subroutines

free

Free dynamic memory.

Attributes: elemental

fortran
subroutine free(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.

get_items

Get list of pairs option name/value.

Attributes: pure

fortran
subroutine get_items(self, items)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
itemscharacter(len=:)outallocatableItems, list of pairs option name/value for all options [1:No,1:2].

Call graph

get_sections_list

Get sections names list.

Attributes: pure

fortran
subroutine get_sections_list(self, list)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
listcharacter(len=:)outallocatableSections names list.

Call graph

initialize

Initialize file.

Attributes: elemental

fortran
subroutine initialize(self, filename)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
filenamecharacter(len=*)inoptionalFile name.

load

Get file data from a file or a source string.

Usage

Loading from a file
bash
type(file_ini):: fini
call fini%load(filename='path_to_my_file.ini')
Loading from a source string
bash
type(file_ini):: fini
call fini%load(source='[section-1] option-1=one [section-2] option-2=due')
fortran
subroutine load(self, separator, filename, source, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
separatorcharacter(len=1)inoptionalSeparator of options name/value.
filenamecharacter(len=*)inoptionalFile name.
sourcecharacter(len=*)inoptionalFile source contents.
errorinteger(kind=I4P)outoptionalError code.

Call graph

Print data with a pretty format.

fortran
subroutine print_file_ini(self, unit, pref, retain_comments, iostat, iomsg)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
unitinteger(kind=I4P)inLogic unit.
prefcharacter(len=*)inoptionalPrefixing string.
retain_commentslogicalinoptionalFlag for retaining eventual comments.
iostatinteger(kind=I4P)outoptionalIO error.
iomsgcharacter(len=*)outoptionalIO error message.

save_file_ini

Save data.

fortran
subroutine save_file_ini(self, retain_comments, iostat, iomsg, filename)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
retain_commentslogicalinoptionalFlag for retaining eventual comments.
iostatinteger(kind=I4P)outoptionalIO error.
iomsgcharacter(len=*)outoptionalIO error message.
filenamecharacter(len=*)inoptionalFile name.

add_a_option

Add an option (with array value).

If the option already exists, its value is updated.

Attributes: pure

fortran
subroutine add_a_option(self, error, section_name, option_name, val)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
errorinteger(kind=I4P)outoptionalError code.
section_namecharacter(len=*)inSection name.
option_namecharacter(len=*)inOption name.
valclass(*)inOption value.

Call graph

add_option

Add an option (with scalar value).

If the option already exists, its value is updated.

Attributes: pure

fortran
subroutine add_option(self, error, section_name, option_name, val)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
errorinteger(kind=I4P)outoptionalError code.
section_namecharacter(len=*)inSection name.
option_namecharacter(len=*)inOption name.
valclass(*)inOption value.

Call graph

add_section

Add a section.

If the section already exists, it is left unchanged.

Attributes: pure

fortran
subroutine add_section(self, error, section_name)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
errorinteger(kind=I4P)outoptionalError code.
section_namecharacter(len=*)inSection name.

free_options_all

Free all options of all sections.

Attributes: elemental

fortran
subroutine free_options_all(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.

Call graph

free_option_of_section

Free all options of a section.

Attributes: elemental

fortran
subroutine free_option_of_section(self, section_name, option_name)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
section_namecharacter(len=*)inSection name.
option_namecharacter(len=*)inOption name.

Call graph

free_options_of_section

Free all options of a section.

Attributes: elemental

fortran
subroutine free_options_of_section(self, section_name)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
section_namecharacter(len=*)inSection name.

Call graph

free_section

Free all options of a section.

Attributes: elemental

fortran
subroutine free_section(self, section_name)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
section_namecharacter(len=*)inSection name.

get_a_option

Get option value (array)

fortran
subroutine get_a_option(self, section_name, option_name, val, delimiter, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
section_namecharacter(len=*)inSection name.
option_namecharacter(len=*)inOption name.
valclass(*)inoutValue.
delimitercharacter(len=*)inoptionalDelimiter used for separating values.
errorinteger(kind=I4P)outoptionalError code.

Call graph

get_option

Get option value (scalar).

fortran
subroutine get_option(self, section_name, option_name, val, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
section_namecharacter(len=*)inSection name.
option_namecharacter(len=*)inOption name.
valclass(*)inoutValue.
errorinteger(kind=I4P)outoptionalError code.

Call graph

parse

Parse file either from the self source data or from a source string.

fortran
subroutine parse(self, source, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inoutFile data.
sourcetype(string)inString source.
errorinteger(kind=I4P)outoptionalError code.

Call graph

assign_file_ini

Assignment between two INI files.

Attributes: elemental

fortran
subroutine assign_file_ini(lhs, rhs)

Arguments

NameTypeIntentAttributesDescription
lhsclass(file_ini)inoutLeft hand side.
rhstype(file_ini)inRigth hand side.

file_ini_autotest

Autotest the library functionalities.

fortran
subroutine file_ini_autotest()

Call graph

Functions

count_values

Get the number of values of option into section data.

Attributes: elemental

Returns: integer(kind=I4P)

fortran
function count_values(self, delimiter, section_name, option_name) result(Nv)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
delimitercharacter(len=*)inoptionalDelimiter used for separating values.
section_namecharacter(len=*)inSection name.
option_namecharacter(len=*)inOption name.

Call graph

has_option

Inquire the presence of (at least one) option with the name passed.

Optional, the first matching section name is returned.

@note All sections are searched and the first occurence is returned.

Returns: logical

fortran
function has_option(self, option_name, section_name) result(pres)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
option_namecharacter(len=*)inOption name.
section_namecharacter(len=*)inoutoptionalSection name.

Call graph

has_section

Inquire the presence of (at least one) section with the name passed.

Attributes: elemental

Returns: logical

fortran
function has_section(self, section_name) result(pres)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
section_namecharacter(len=*)inSection name.

Call graph

section_file_ini

Get section name once an index (valid) is provided.

Attributes: pure

Returns: character(len=:)

fortran
function section_file_ini(self, section_index) result(sname)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
section_indexinteger(kind=I4P)inSection index.

Call graph

index_option

Return the index of the option (inside a section) matching the name(s) passed.

@note The matching index returned is the first found if back is not passed or if back=.false.. On the contrary the last found is returned if back=.true..

Attributes: elemental

Returns: integer(kind=I4P)

fortran
function index_option(self, back, section_name, option_name) result(ind)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
backlogicalinoptionalIf back appears with the value true, the last matching index is returned.
section_namecharacter(len=*)inSection name.
option_namecharacter(len=*)inOption name.

index_section

Return the index of the section matching the name passed.

@note The matching index returned is the first found if back is not passed or if back=.false.. On the contrary the last found is returned if back=.true..

Attributes: elemental

Returns: integer(kind=I4P)

fortran
function index_section(self, back, section_name) result(ind)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
backlogicalinoptionalIf back appears with the value true, the last matching index is returned.
section_namecharacter(len=*)inSection name.

loop_options_section

Loop returning option name/value defined into section.

Returns: logical

fortran
function loop_options_section(self, section_name, option_pairs) result(again)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
section_namecharacter(len=*)inSection name.
option_pairscharacter(len=:)outallocatablePairs option name/value [1:2].

Call graph

loop_options

Loop returning option name/value defined into all sections.

Attributes: recursive

Returns: logical

fortran
function loop_options(self, option_pairs) result(again)

Arguments

NameTypeIntentAttributesDescription
selfclass(file_ini)inFile data.
option_pairscharacter(len=:)outallocatablePairs option name/value [1:2].

Call graph