INISection Class Reference

Section of ini file. More...

#include <inisection.h>

List of all members.

Public Member Functions

const char * GetName () 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).
unsigned GetLength () const

Detailed Description

Section of ini file.

Stores tags of an ini file section.

Definition at line 24 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 763 of file inisection.cpp.

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

Definition at line 417 of file inisection.h.

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

Definition at line 56 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 565 of file inisection.cpp.

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 167 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 414 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 1002 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 933 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 142 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 376 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 984 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 919 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 117 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 337 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 966 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 905 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 744 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 675 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 726 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 661 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 708 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 647 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 690 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 598 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 86 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 325 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 948 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 836 of file inisection.cpp.


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

MiniINI was written by Ferdinand Majerech kiithsacmp[at]gmail.com
Generated on Sun Apr 11 17:08:19 2010 for MiniINI by  Doxygen 1.6.3