INISection Class Reference

Section of ini file. More...

#include <inisection.h>

List of all members.

Public Member Functions

const char * GetName () const
std::string GetNameSTL () const
unsigned GetLength () const
void Reset ()
 Resets iteration.
bool Next ()
 Advance iteration to the next tag.
const char * CurrentTag () const
std::string CurrentTagSTL () const
bool ReadString (const char *const name, const char *&out) const
 Read a string value from given tag.
bool ReadString (const std::string &name, std::string &out) const
 Read a string value from given tag. (STL version).
bool ReadInt (const char *const name, int &out) const
 Read an int value from given tag.
bool ReadInt (const std::string &name, int &out) const
 Read an int value from given tag. (STL version).
bool ReadFloat (const char *const name, float &out) const
 Read a float value from given tag.
bool ReadFloat (const std::string &name, float &out) const
 Read a float value from given tag. (STL version).
bool ReadBool (const char *const name, bool &out) const
 Read a bool value from given tag.
bool ReadBool (const std::string &name, bool &out) const
 Read a bool value from given tag. (STL version).
unsigned MultiValSize (const char *const name) const
 Determine number of values in given tag.
unsigned ReadMultiString (const char *const name, const char **out, const unsigned cap) const
 Read an array of strings from a multi value tag with given name.
unsigned ReadMultiString (const std::string &name, std::vector< std::string > &out) const
 Read an array of strings from a multi value tag with given name. (STL version).
unsigned ReadMultiInt (const char *const name, int *out, const unsigned cap) const
 Read an array of ints from a multi value tag with given name.
unsigned ReadMultiInt (const std::string &name, std::vector< int > &out) const
 Read an array of ints from a multi value tag with given name. (STL version).
unsigned ReadMultiFloat (const char *const name, float *out, const unsigned cap) const
 Read an array of floats from a multi value tag with given name.
unsigned ReadMultiFloat (const std::string &name, std::vector< float > &out) const
 Read an array of floats from a multi value tag with given name. (STL version).
unsigned ReadMultiBool (const char *const name, bool *out, const unsigned cap) const
 Read an array of bools from a multi value tag with given name.
unsigned ReadMultiBool (const std::string &name, std::vector< bool > &out) const
 Read an array of bools from a multi value tag with given name. (STL version).
unsigned ArraySize (const char *const name) const
 Determine size of array of tags with given base name.
unsigned ReadStrings (const char *const name, const char **out, const unsigned cap) const
 Read an array of strings with given base name.
unsigned ReadStrings (const std::string &name, std::vector< std::string > &out) const
 Read an array of strings with given base name. (STL version).
unsigned ReadInts (const char *const name, int *out, const unsigned cap) const
 Read an array of ints with given base name.
unsigned ReadInts (const std::string &name, std::vector< int > &out) const
 Read an array of ints with given base name. (STL version).
unsigned ReadFloats (const char *const name, float *out, const unsigned cap) const
 Read an array of floats with given base name.
unsigned ReadFloats (const std::string &name, std::vector< float > &out) const
 Read an array of floats with given base name. (STL version).
unsigned ReadBools (const char *const name, bool *out, const unsigned cap) const
 Read an array of bools with given base name.
unsigned ReadBools (const std::string &name, std::vector< bool > &out) const
 Read an array of bools with given base name. (STL version).

Detailed Description

Section of ini file.

Stores tags of an ini file section.

Definition at line 25 of file inisection.h.


Member Function Documentation

unsigned INISection::ArraySize ( const char *const   name  )  const

Determine size of array of tags with given base name.

Counts tags named name1=, name2=, etc. where name is the given base name for the tags.

Parameters:
name Base name of tags in the array. Must be a valid zero terminated string.
Returns:
number of elements in the array.

Definition at line 498 of file inisection.cpp.

const char* INISection::CurrentTag (  )  const [inline]
Returns:
name of the tag currently pointed to by internal iteration index.

Definition at line 100 of file inisection.h.

std::string INISection::CurrentTagSTL (  )  const [inline]
Returns:
name of the tag currently pointed to by internal iteration index. (STL version)

Definition at line 111 of file inisection.h.

unsigned INISection::GetLength (  )  const [inline]
Returns:
number of tags in the section. (STL version)

Definition at line 73 of file inisection.h.

const char* INISection::GetName (  )  const [inline]
Returns:
name of this section.

Definition at line 59 of file inisection.h.

std::string INISection::GetNameSTL (  )  const [inline]
Returns:
name of this section.

Definition at line 66 of file inisection.h.

unsigned INISection::MultiValSize ( const char *const   name  )  const

Determine number of values in given tag.

Parameters:
name Name of tag. Must be a valid zero terminated string.
Returns:
number of values in the tag.

Definition at line 264 of file inisection.cpp.

bool INISection::Next (  )  [inline]

Advance iteration to the next tag.

Returns:
true if there is another tag and internal index now points to it.
false if there are no more tags, i.e. we're finished with iteration.

Definition at line 89 of file inisection.h.

bool INISection::ReadBool ( const std::string &  name,
bool &  out 
) const [inline]

Read a bool value from given tag. (STL version).

If the tag has multiple values, the first value is read.

Parameters:
name Name of the tag to read from.
out Reference to variable to read to. If tag not found, out won't be chaged.
Returns:
true if the value was read succesfully
false if the tag does not exist (value was not read)

Definition at line 227 of file inisection.h.

bool INISection::ReadBool ( const char *const   name,
bool &  out 
) const

Read a bool value from given tag.

If the tag has multiple values, the first value is read.

Parameters:
name Name of the tag to read from. Must be a valid zero terminated string.
out Reference to variable to read to. If tag not found, out won't be chaged.
Returns:
true if the value was read succesfully
false if the tag does not exist (value was not read)

Definition at line 228 of file inisection.cpp.

unsigned INISection::ReadBools ( const std::string &  name,
std::vector< bool > &  out 
) const

Read an array of bools with given base name. (STL version).

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags. This version of ReadBools will read as many elements as there are in the ini file to given vector. If any array tag has multiple values, the first value is read.

Note:
Elements read are appended to the given vector.
Parameters:
name Base name of the tags to read from.
out Reference to the vector to read to.
Returns:
number of values read

Definition at line 742 of file inisection.cpp.

unsigned INISection::ReadBools ( const char *const   name,
bool *  out,
const unsigned  cap 
) const

Read an array of bools with given base name.

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags. If any array tag has multiple values, the first value is read.

Parameters:
name Base name of the tags to read from. Must be a valid zero terminated string.
out Pointer to buffer to read to.
cap Capacity of the buffer.
Returns:
number of values read

Definition at line 671 of file inisection.cpp.

bool INISection::ReadFloat ( const std::string &  name,
float &  out 
) const [inline]

Read a float value from given tag. (STL version).

If the tag has multiple values, the first value is read.

Parameters:
name Name of the tag to read from.
out Reference to variable to read to. If tag not found, out won't be chaged.
Returns:
true if the value was read succesfully
false if the tag does not exist (value was not read)

Definition at line 202 of file inisection.h.

bool INISection::ReadFloat ( const char *const   name,
float &  out 
) const

Read a float value from given tag.

If the tag has multiple values, the first value is read.

Parameters:
name Name of the tag to read from. Must be a valid zero terminated string.
out Reference to variable to read to. If tag not found, out won't be chaged.
Returns:
true if the value was read succesfully
false if the tag does not exist (value was not read)

Definition at line 189 of file inisection.cpp.

unsigned INISection::ReadFloats ( const std::string &  name,
std::vector< float > &  out 
) const

Read an array of floats with given base name. (STL version).

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags. This version of ReadFloats will read as many elements as there are in the ini file to given vector. If any array tag has multiple values, the first value is read.

Note:
Elements read are appended to the given vector.
Parameters:
name Base name of the tags to read from.
out Reference to the vector to read to.
Returns:
number of values read

Definition at line 724 of file inisection.cpp.

unsigned INISection::ReadFloats ( const char *const   name,
float *  out,
const unsigned  cap 
) const

Read an array of floats with given base name.

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags. in wrong order, e.g. name4= after name2= . If any array tag has multiple values, the first value is read.

Parameters:
name Base name of the tags to read from. Must be a valid zero terminated string.
out Pointer to buffer to read to.
cap Capacity of the buffer.
Returns:
number of values read

Definition at line 655 of file inisection.cpp.

bool INISection::ReadInt ( const std::string &  name,
int &  out 
) const [inline]

Read an int value from given tag. (STL version).

If the tag has multiple values, the first value is read.

Parameters:
name Name of the tag to read from.
out Reference to variable to read to. If tag not found, out won't be chaged.
Returns:
true if the value was read succesfully
false if the tag does not exist (value was not read)

Definition at line 177 of file inisection.h.

bool INISection::ReadInt ( const char *const   name,
int &  out 
) const

Read an int value from given tag.

If the tag has multiple values, the first value is read.

Parameters:
name Name of the tag to read from. Must be a valid zero terminated string.
out Reference to variable to read to. If tag not found, out won't be chaged.
Returns:
true if the value was read succesfully
false if the tag does not exist (value was not read)

Definition at line 151 of file inisection.cpp.

unsigned INISection::ReadInts ( const std::string &  name,
std::vector< int > &  out 
) const

Read an array of ints with given base name. (STL version).

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags. This version of ReadInts will read as many elements as there are in the ini file to given vector. If any array tag has multiple values, the first value is read.

Note:
Elements read are appended to the given vector.
Parameters:
name Base name of the tags to read from.
out Reference to the vector to read to.
Returns:
number of values read

Definition at line 706 of file inisection.cpp.

unsigned INISection::ReadInts ( const char *const   name,
int *  out,
const unsigned  cap 
) const

Read an array of ints with given base name.

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags. If any array tag has multiple values, the first value is read.

Parameters:
name Base name of the tags to read from. Must be a valid zero terminated string.
out Pointer to buffer to read to.
cap Capacity of the buffer.
Returns:
number of values read

Definition at line 639 of file inisection.cpp.

unsigned INISection::ReadMultiBool ( const std::string &  name,
std::vector< bool > &  out 
) const

Read an array of bools from a multi value tag with given name. (STL version).

Reads bools from comma separated values in the tag.

Note:
Elements read are appended to the given vector.
Parameters:
name Name of the tag to read from.
out Reference to the vector to read to.
Returns:
number of values read.

Definition at line 479 of file inisection.cpp.

unsigned INISection::ReadMultiBool ( const char *const   name,
bool *  out,
const unsigned  cap 
) const

Read an array of bools from a multi value tag with given name.

Reads bools from comma separated values in the tag.

Parameters:
name Name of the tag to read from. Must be a valid zero terminated string.
out Pointer to buffer to read to.
cap Capacity of the buffer.
Returns:
number of values read.

Definition at line 408 of file inisection.cpp.

unsigned INISection::ReadMultiFloat ( const std::string &  name,
std::vector< float > &  out 
) const

Read an array of floats from a multi value tag with given name. (STL version).

Reads floats from comma separated values in the tag.

Note:
Elements read are appended to the given vector.
Parameters:
name Name of the tag to read from.
out Reference to the vector to read to.
Returns:
number of values read.

Definition at line 461 of file inisection.cpp.

unsigned INISection::ReadMultiFloat ( const char *const   name,
float *  out,
const unsigned  cap 
) const

Read an array of floats from a multi value tag with given name.

Reads floats from comma separated values in the tag.

Parameters:
name Name of the tag to read from. Must be a valid zero terminated string.
out Pointer to buffer to read to.
cap Capacity of the buffer.
Returns:
number of values read.

Definition at line 392 of file inisection.cpp.

unsigned INISection::ReadMultiInt ( const std::string &  name,
std::vector< int > &  out 
) const

Read an array of ints from a multi value tag with given name. (STL version).

Reads ints from comma separated values in the tag.

Note:
Elements read are appended to the given vector.
Parameters:
name Name of the tag to read from.
out Reference to the vector to read to.
Returns:
number of values read.

Definition at line 443 of file inisection.cpp.

unsigned INISection::ReadMultiInt ( const char *const   name,
int *  out,
const unsigned  cap 
) const

Read an array of ints from a multi value tag with given name.

Reads ints from comma separated values in the tag.

Parameters:
name Name of the tag to read from. Must be a valid zero terminated string.
out Pointer to buffer to read to.
cap Capacity of the buffer.
Returns:
number of values read.

Definition at line 376 of file inisection.cpp.

unsigned INISection::ReadMultiString ( const std::string &  name,
std::vector< std::string > &  out 
) const

Read an array of strings from a multi value tag with given name. (STL version).

Reads strings from comma separated values in the tag.

Note:
Elements read are appended to the given vector. Unlike non-STL ReadMultiString, string data does get copied here (using std::string constructor) so there is no need to copy it manually.
Parameters:
name Name of the tag to read from.
out Reference to the vector to read to.
Returns:
number of values read.

Definition at line 425 of file inisection.cpp.

unsigned INISection::ReadMultiString ( const char *const   name,
const char **  out,
const unsigned  cap 
) const

Read an array of strings from a multi value tag with given name.

Reads strings from comma separated values in the tag.

Note:
Unlike other ReadMultiXXX methods, ReadMultiString only gives a pointer to data inside the INISection. If you want to use this data after INIFile is destroyed, you have to copy it.
Parameters:
name Name of the tag to read from. Must be a valid zero terminated string.
out Pointer to buffer to read to.
cap Capacity of the buffer.
Returns:
number of values read.

Definition at line 311 of file inisection.cpp.

bool INISection::ReadString ( const std::string &  name,
std::string &  out 
) const [inline]

Read a string value from given tag. (STL version).

Unlike non-STL ReadString, string data does get copied here (using std::string constructor) so there is no need to copy it manually. If the tag has multiple values, the first value is read.

Parameters:
name Name of the tag to read from.
out Reference to variable to read to. If tag not found, out won't be chaged.
Returns:
true if the value was read succesfully.
false if the tag does not exist. (value was not read)

Definition at line 146 of file inisection.h.

bool INISection::ReadString ( const char *const  name,
const char *&  out 
) const [inline]

Read a string value from given tag.

Note:
Unlike other ReadXXX methods, ReadString only gives a pointer to data inside the INISection. If you want to use this data after INIFile is destroyed, you have to copy it. If the tag has multiple values, the first value is read.
Parameters:
name Name of the tag to read from. Must be a valid zero terminated string.
out Reference to variable to read to. If tag not found, out won't be chaged.
Returns:
true if the value was read succesfully.
false if the tag does not exist. (value was not read)

Definition at line 125 of file inisection.cpp.

unsigned INISection::ReadStrings ( const std::string &  name,
std::vector< std::string > &  out 
) const

Read an array of strings with given base name. (STL version).

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags. This version of ReadStrings will read as many elements as there are in the ini file to given vector. If any array tag has multiple values, the first value is read.

Note:
Elements read are appended to the given vector. Unlike non-STL ReadString, string data does get copied here (using std::string constructor) so there is no need to copy it manually.
Parameters:
name Base name of the tags to read from.
out Reference to the vector to read to.
Returns:
number of values read.

Definition at line 688 of file inisection.cpp.

unsigned INISection::ReadStrings ( const char *const   name,
const char **  out,
const unsigned  cap 
) const

Read an array of strings with given base name.

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags. If any array tag has multiple values, the first value is read.

Note:
Unlike other ReadXXXs methods, ReadStrings only gives a pointer to data inside the INISection. If you want to use this data after INIFile is destroyed, you have to copy it.
After a call to ReadStrings, contents of out after out[return value] are undefined.
Parameters:
name Base name of the tags to read from. Must be a valid zero terminated string.
out Pointer to buffer to read to.
cap Capacity of the buffer.
Returns:
number of values read.

Definition at line 569 of file inisection.cpp.

void INISection::Reset (  )  [inline]

Resets iteration.

Definition at line 79 of file inisection.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Defines

MiniINI was written by Ferdinand Majerech kiithsacmp[at]gmail.com
Generated on Wed Jun 16 18:51:44 2010 for MiniINI by  Doxygen 1.6.3