INISection Class Reference

Handles reading of data from a single INI section. More...

#include <inisection.h>

List of all members.

Public Member Functions

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

Detailed Description

Handles reading of data from a single INI section.

Definition at line 24 of file inisection.h.


Member Function Documentation

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

Determine size of a sequence 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. Must be a zero terminated string.
Returns:
number of elements in the array.

Definition at line 498 of file inisection.cpp.

const char* INISection::CurrentTag (  )  const [inline]

Get name of the current tag.

Returns:
name of the tag currently pointed to by internal iteration index.

Definition at line 105 of file inisection.h.

std::string INISection::CurrentTagSTL (  )  const [inline]

Get name of the current tag (STL version).

Returns:
name of the tag currently pointed to by internal iteration index.

Definition at line 118 of file inisection.h.

unsigned INISection::GetLength (  )  const [inline]

Gets number of tags in the section.

Returns:
number of tags in the section.

Definition at line 78 of file inisection.h.

const char* INISection::GetName (  )  const [inline]

Gets name of this section.

Returns:
name of this section.

Definition at line 60 of file inisection.h.

std::string INISection::GetNameSTL (  )  const [inline]

Gets name of this section (STL version).

Returns:
name of this section.

Definition at line 69 of file inisection.h.

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

Determine number of values in a tag.

Parameters:
name Name of tag. Must be a 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 iteration moved to it.
false if there are no more tags, i.e. we're finished with iteration.

Definition at line 93 of file inisection.h.

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

Read a bool from a tag (STL version).

Note:
If the tag has multiple values, the first value is read.
Parameters:
name Name of the tag to read.
out Reference to variable to read to. If tag is not found, out won't be changed.
Returns:
true if the value was read successfully
false if the tag does not exist and no value was read.

Definition at line 223 of file inisection.h.

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

Read a bool from a tag.

Note:
If the tag has multiple values, the first value is read.
Parameters:
name Name of the tag to read. Must be a zero terminated string.
out Reference to variable to read to. If tag is not found, out won't be changed.
Returns:
true if the value was read successfully
false if the tag does not exist and no value was 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 from a sequence of tags with given base name (STL version).

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags.

Note:
If any tag has multiple values, the first value is read.
Values are added to the end of vector.
Parameters:
name Base name of tags to read.
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 from a sequence of tags with given base name.

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags.

Note:
If any tag has multiple values, the first value is read.
Parameters:
name Base name of tags to read. Must be a zero terminated string.
out Pointer to buffer to read to.
cap Maximum number of values the buffer can hold.
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 from a tag (STL version).

Note:
If the tag has multiple values, the first value is read.
Parameters:
name Name of the tag to read.
out Reference to variable to read to. If tag is not found, out won't be changed.
Returns:
true if the value was read successfully
false if the tag does not exist and no value was read.

Definition at line 200 of file inisection.h.

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

Read a float from a tag.

Note:
If the tag has multiple values, the first value is read.
Parameters:
name Name of the tag to read. Must be a zero terminated string.
out Reference to variable to read to. If tag is not found, out won't be changed.
Returns:
true if the value was read successfully
false if the tag does not exist and no value was 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 from a sequence of tags with given base name (STL version).

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags.

Note:
If any tag has multiple values, the first value is read.
Values are added to the end of vector.
Parameters:
name Base name of tags to read.
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 from a sequence of tags with given base name.

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags.

Note:
If any tag has multiple values, the first value is read.
Parameters:
name Base name of tags to read. Must be a zero terminated string.
out Pointer to buffer to read to.
cap Maximum number of values the buffer can hold.
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 from a tag (STL version).

Note:
If the tag has multiple values, the first value is read.
Parameters:
name Name of the tag to read.
out Reference to variable to read to. If tag is not found, out won't be changed.
Returns:
true if the value was read successfully.
false if the tag does not exist and no value was read.

Definition at line 177 of file inisection.h.

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

Read an int from a tag.

Note:
If the tag has multiple values, the first value is read.
Parameters:
name Name of the tag to read. Must be a zero terminated string.
out Reference to variable to read to. If tag is not found, out won't be changed.
Returns:
true if the value was read successfully.
false if the tag does not exist and no value was 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 from a sequence of tags with given base name (STL version).

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags.

Note:
If any tag has multiple values, the first value is read.
Values are added to the end of vector.
Parameters:
name Base name of tags to read.
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 from a sequence of tags with given base name.

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags.

Note:
If any tag has multiple values, the first value is read.
Parameters:
name Base name of tags to read. Must be a zero terminated string.
out Pointer to buffer to read to.
cap Maximum number of values the buffer can hold.
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 (STL version).

Reads bools from comma separated values in a tag.

Note:
Values are added to the end of vector.
Parameters:
name Name of the tag to read.
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.

Reads bools from comma separated values in a tag.

Parameters:
name Name of the tag to read. Must be a zero terminated string.
out Pointer to buffer to read to.
cap Maximum number of values the buffer can hold.
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 (STL version).

Reads floats from comma separated values in a tag.

Note:
Values are added to the end of vector.
Parameters:
name Name of the tag to read.
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.

Reads floats from comma separated values in a tag.

Parameters:
name Name of the tag to read. Must be a zero terminated string.
out Pointer to buffer to read to.
cap Maximum number of values the buffer can hold.
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 (STL version).

Reads ints from comma separated values in a tag.

Note:
Values are added to the end of vector.
Parameters:
name Name of the tag to read.
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.

Reads ints from comma separated values in a tag.

Parameters:
name Name of the tag to read. Must be a zero terminated string.
out Pointer to buffer to read to.
cap Maximum number of values the buffer can hold.
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 (STL version).

Reads strings from comma separated values in a tag.

Note:
Values are added to the end of vector.
Parameters:
name Name of the tag to read.
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.

Reads strings from comma separated values in a tag.

Note:
Unlike other ReadMultiXXX methods, ReadMultiString only returns a pointer to INISection data. If you want to use this data after INIFile is destroyed, you have to copy it.
Parameters:
name Name of the tag to read. Must be a zero terminated string.
out Pointer to buffer to read to.
cap Maximum number of values the buffer can hold.
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 from a tag (STL version).

Note:
If the tag has multiple values, the first value is read.
Parameters:
name Name of the tag to read.
out Reference to variable to read to. If tag is not found, out won't be changed.
Returns:
true if the value was read successfully.
false if the tag does not exist and no value was read.

Definition at line 148 of file inisection.h.

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

Read a string from a tag.

Note:
Unlike other ReadXXX methods, ReadString only returns a pointer to INISection data. 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. Must be a zero terminated string.
out Reference to variable to read to. If tag is not found, out won't be changed.
Returns:
true if the value was read successfully.
false if the tag does not exist and no value was 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 from a sequence of tags with given base name (STL version).

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags.

Note:
If any tag has multiple values, the first value is read.
Values are added to the end of vector.
Parameters:
name Base name of tags to read.
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 from a sequence of tags with given base name.

Reads values from tags named name1=, name2=, etc. where name is the given base name for the tags.

Note:
If any tag has multiple values, the first value is read.
Unlike other ReadXXXs methods, ReadStrings only returns a pointer to INISection data. 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 and including out[return value] are undefined.
Parameters:
name Base name of tags to read. Must be a zero terminated string.
out Pointer to buffer to read to.
cap Maximum number of values the buffer can hold.
Returns:
number of values read.

Definition at line 569 of file inisection.cpp.

void INISection::Reset (  )  [inline]

Resets iteration.

Definition at line 84 of file inisection.h.


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

Copyright © Ferdinand Majerech 2009-2010 kiithsacmp[at]gmail.com
Generated on Fri Jul 9 15:09:53 2010 for MiniINI by  Doxygen 1.6.3