Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cIniSectionData Class Reference

#include <cIniSection.h>

Inheritance diagram for Gray::cIniSectionData:
Gray::IIniBaseEnumerator Gray::IIniBaseGetter Gray::IIniBaseSetter Gray::cIniReader Gray::cIniSection Gray::cIniSectionEntry GrayLib::cScriptSection

Public Member Functions

 cIniSectionData (bool bStripComments=false) noexcept
 
virtual ~cIniSectionData ()
 
void DisposeThis ()
 
bool isStripped () const noexcept
 
StrLen_t get_BufferUsed () const noexcept
 
StrLen_t get_BufferSize () const noexcept
 
ITERATE_t get_LineQty () const noexcept
 
IniChar_tGetLineEnum (ITERATE_t iLine=0) const noexcept
 
ITERATE_t FindTriggerName (const IniChar_t *pszTrigName) const
 
virtual HRESULT PropEnum (IPROPIDX_t ePropIdx, OUT cStringI &rsValue, cStringI *psKey=nullptr) const override
 
void ClearLineQty ()
 
ITERATE_t FindKeyLine (const IniChar_t *pszKeyName, bool bPrefixOnly=false) const
 Find a key in the section (key=args) More...
 
const IniChar_tFindKeyLinePtr (const IniChar_t *pszKey) const
 
const IniChar_tFindArgForKey (const IniChar_t *pszKey, const IniChar_t *pszDefault=nullptr) const
 
int FindIntForKey (const IniChar_t *pszKey, int iDefault=0) const
 
virtual HRESULT PropGet (const IniChar_t *pszPropTag, OUT cStringI &rsValue) const override
 
bool IsValidLines () const
 
void SetLinesCopy (const cIniSectionData &section)
 
ITERATE_t AddLine (const IniChar_t *pszLine)
 
bool SetLine (ITERATE_t iLine, const IniChar_t *pszLine=nullptr)
 
bool RemoveLine (ITERATE_t iLine)
 
ITERATE_t AddKeyArg (const IniChar_t *pszKey, const IniChar_t *pszArg)
 
ITERATE_t AddKeyInt (const IniChar_t *pszKey, int iArg)
 
ITERATE_t SetKeyArg (const IniChar_t *pszKey, const IniChar_t *pszArg)
 
ITERATE_t SetKeyInt (const IniChar_t *pszKey, int iArg)
 
void AllocComplete ()
 
virtual HRESULT PropSet (const IniChar_t *pszPropTag, const IniChar_t *pszValue) override
 
StrLen_t SetLinesParse (const IniChar_t *pszData, StrLen_t iLen=k_StrLen_UNK, const IniChar_t *pszSep=nullptr, STRP_MASK_t uFlags=(STRP_START_WHITE|STRP_MERGE_CRNL|STRP_END_WHITE|STRP_EMPTY_STOP))
 
cStringA GetStringAll (const IniChar_t *pszSep=nullptr) const
 
HRESULT ReadSectionData (cStringA &rsSectionNext, cStreamInput &stream, bool bStripComments)
 
HRESULT WriteSectionData (cStreamOutput &file)
 

Static Public Member Functions

static StrLen_t __stdcall IsLineTrigger (const IniChar_t *pszLine)
 
static StrLen_t __stdcall MakeLine (IniChar_t *pszTmp, StrLen_t iSizeMax, const IniChar_t *pszKey, const IniChar_t *pszArg, IniChar_t chSep='=')
 
- Static Public Member Functions inherited from Gray::cIniReader
static bool __stdcall IsSectionHeader (const IniChar_t *pszLine)
 
static bool __stdcall IsLineComment (const IniChar_t *pszLine)
 
static IniChar_t *__stdcall FindLineArg (const IniChar_t *pszLine, bool bAllowSpace=false)
 
static StrLen_t __stdcall FindScriptLineEnd (const IniChar_t *pLineStr)
 
static cStringI __stdcall GetLineParse2 (const IniChar_t *pszLine, IniChar_t **ppszArgs=nullptr)
 
static cStringI __stdcall GetLineParse3 (const IniChar_t *pszLine, OUT cStringI &rsArgs)
 

Static Public Attributes

static const StrLen_t k_SECTION_SIZE_MAX = (256 * 1024)
 (chars) max size for whole section. (Windows Me/98/95 = 32K for INI) More...
 
static const ITERATE_t k_LINE_QTY_MAX = (8 * 1024)
 max number of lines i support. (per section) More...
 
static const StrLen_t k_LINE_LEN_MAX = (4 * 1024)
 max size for a single line (in chars). More...
 
static const StrLen_t k_LINE_LEN_DEF = (1024)
 suggested/guessed/average size for lines (in chars). for alloc guessing. More...
 

Protected Member Functions

IniChar_tAllocBuffer (StrLen_t nSizeChars)
 For raw access to the m_Buffer. More...
 
void AllocLines (ITERATE_t iLinesAlloc)
 
IniChar_tAllocBeginMin (StrLen_t nSizeChars)
 

Protected Attributes

bool m_bStripComments
 has been stripped of blank lines, comments, leading and trailing line spaces. More...
 

Friends

class cIniFile
 

Detailed Description

An array of lines (typically) in "Tag=Val" format or "Tag: Val". (comments and junk space is preserved) Mostly used as read only. Typically the data inside a [section] in an INI file. similar to _WIN32 GetPrivateProfileSection()

Note
the [section] name itself is NOT stored here. That is in cIniSection
Allows ad hoc lines "hi this is a line" (with no = or formatting) Comments are decoded in cIniReader::FindScriptLineEnd()

Constructor & Destructor Documentation

◆ cIniSectionData()

Gray::cIniSectionData::cIniSectionData ( bool  bStripComments = false)
noexcept

◆ ~cIniSectionData()

Gray::cIniSectionData::~cIniSectionData ( )
virtual

Member Function Documentation

◆ AddKeyArg()

ITERATE_t Gray::cIniSectionData::AddKeyArg ( const IniChar_t pszKey,
const IniChar_t pszArg 
)

Add the line, even if it is duplicated key.

◆ AddKeyInt()

ITERATE_t Gray::cIniSectionData::AddKeyInt ( const IniChar_t pszKey,
int  iArg 
)
inline

◆ AddLine()

ITERATE_t Gray::cIniSectionData::AddLine ( const IniChar_t pszLine)

add a text line to the end of this section. ASSUME m_bStripped has already been applied if used. Allow IsLineComment() and blank lines if NOT m_bStripped. strip newlines off. strip extra spaces off the end. allow leading spaces

◆ AllocBeginMin()

IniChar_t * Gray::cIniSectionData::AllocBeginMin ( StrLen_t  nSizeChars)
protected

Alloc at least this estimated amount. Meant to be used with ProcessBuffer ASSUME AllocComplete() will be called later.

◆ AllocBuffer()

IniChar_t * Gray::cIniSectionData::AllocBuffer ( StrLen_t  nSizeChars)
protected

For raw access to the m_Buffer.

◆ AllocComplete()

void Gray::cIniSectionData::AllocComplete ( )

done loading, so trim to its used size.

◆ AllocLines()

void Gray::cIniSectionData::AllocLines ( ITERATE_t  iLinesAlloc)
protected

◆ ClearLineQty()

void Gray::cIniSectionData::ClearLineQty ( )

don't re-alloc. just clear what is used.

◆ DisposeThis()

void Gray::cIniSectionData::DisposeThis ( )

Dispose any data. we might reload it when needed. this might just be a stub.

◆ FindArgForKey()

const IniChar_t * Gray::cIniSectionData::FindArgForKey ( const IniChar_t pszKey,
const IniChar_t pszDefault = nullptr 
) const

Find pszKey in the section.

Note
this does not strip comments from the end of the line !
Returns
the corresponding Args (e.g.Key=Args) for the first instance of pszKey.

◆ FindIntForKey()

int Gray::cIniSectionData::FindIntForKey ( const IniChar_t pszKey,
int  iDefault = 0 
) const

Find pszKey in the section.

Returns
the corresponding Args (e.g.Key=Args) for the first instance of pszKey.

◆ FindKeyLine()

ITERATE_t Gray::cIniSectionData::FindKeyLine ( const IniChar_t pszKeyName,
bool  bPrefixOnly = false 
) const

Find a key in the section (key=args)

Find the first instance of a key in the section (key=args) From the top of the section find a specific key.

Note
There is no rule that keys should be unique!
  • pszKeyName = nullptr = "" bPrefixOnly = key is allowed to be just a prefix. else if must fully match. (default=false)
Returns
-1 = failed the line number.

◆ FindKeyLinePtr()

const IniChar_t * Gray::cIniSectionData::FindKeyLinePtr ( const IniChar_t pszKey) const

Find the line with this key in the section.

Returns
Text for the line.

◆ FindTriggerName()

ITERATE_t Gray::cIniSectionData::FindTriggerName ( const IniChar_t pszTrigName) const

Find Unique Named trigger/label in block.

  • pszTrigName = the script section we want.

◆ get_BufferSize()

StrLen_t Gray::cIniSectionData::get_BufferSize ( ) const
inlinenoexcept
Returns
total buffer size allocated.

◆ get_BufferUsed()

StrLen_t Gray::cIniSectionData::get_BufferUsed ( ) const
inlinenoexcept
Returns
actual buffer size used.

◆ get_LineQty()

ITERATE_t Gray::cIniSectionData::get_LineQty ( ) const
inlinenoexcept
Returns
index of the nullptr entry. at the end.

◆ GetLineEnum()

IniChar_t* Gray::cIniSectionData::GetLineEnum ( ITERATE_t  iLine = 0) const
inlinenoexcept

enum the lines in the section.

  • iLine = line in this section. 0 based.
    Returns
    The line text. nullptr = Last.

◆ GetStringAll()

cStringA Gray::cIniSectionData::GetStringAll ( const IniChar_t pszSep = nullptr) const

Build a single string with all the section lines.

◆ IsLineTrigger()

StrLen_t GRAYCALL Gray::cIniSectionData::IsLineTrigger ( const IniChar_t pszLine)
static

Is this line a script trigger/label in "@NAME" type format? Similar to other languages use of labels: ":DOSLabel" for .bat files. "CLabel:" for C++

Returns
prefix length

◆ isStripped()

bool Gray::cIniSectionData::isStripped ( ) const
inlinenoexcept

has been stripped of blank lines, comments, leading and trailing line spaces.

◆ IsValidLines()

bool Gray::cIniSectionData::IsValidLines ( ) const

All lines MUST be in the m_Buffer.

◆ MakeLine()

StrLen_t GRAYCALL Gray::cIniSectionData::MakeLine ( IniChar_t pszTmp,
StrLen_t  iSizeMax,
const IniChar_t pszKey,
const IniChar_t pszArg,
IniChar_t  chSep = '=' 
)
static

Build a line in the form of KEY=ARG chSep = ':' or '='

◆ PropEnum()

HRESULT Gray::cIniSectionData::PropEnum ( IPROPIDX_t  ePropIdx,
OUT cStringI rsValue,
cStringI psKey = nullptr 
) const
overridevirtual

IIniBaseEnumerator

  • = optionally return psKey. nullptr = don't care.

Implements Gray::IIniBaseEnumerator.

◆ PropGet()

HRESULT Gray::cIniSectionData::PropGet ( const IniChar_t pszPropTag,
OUT cStringI rsValue 
) const
overridevirtual

◆ PropSet()

HRESULT Gray::cIniSectionData::PropSet ( const IniChar_t pszPropTag,
const IniChar_t pszValue 
)
overridevirtual

◆ ReadSectionData()

HRESULT Gray::cIniSectionData::ReadSectionData ( cStringA rsSectionNext,
cStreamInput stream,
bool  bStripComments 
)

Read the cIniSectionData from a cStreamInput. Up to EOF or [next section] Might be first section (with no [Section header] text in rsSectionNext)

  • rsSectionNext = the name of this section. without []. bStripComments = strip leading spaces and trailing spaces and comments.
    Returns
    S_OK = read a section. S_FALSE = empty section rsSectionNext = the name of the next section. (if any)
    Note
    Never strip whole blank lines because the line count will not match for error reporting !

◆ RemoveLine()

bool Gray::cIniSectionData::RemoveLine ( ITERATE_t  iLine)
inline

◆ SetKeyArg()

ITERATE_t Gray::cIniSectionData::SetKeyArg ( const IniChar_t pszKey,
const IniChar_t pszArg 
)

Replace a line with an existing key. else just add to the end.

Returns
the line we changed.

◆ SetKeyInt()

ITERATE_t Gray::cIniSectionData::SetKeyInt ( const IniChar_t pszKey,
int  iArg 
)
inline

◆ SetLine()

bool Gray::cIniSectionData::SetLine ( ITERATE_t  iLine,
const IniChar_t pszLine = nullptr 
)

set the contents of a specific line. (NOT insert a line) pszLine = nullptr = delete.

◆ SetLinesCopy()

void Gray::cIniSectionData::SetLinesCopy ( const cIniSectionData section)

◆ SetLinesParse()

StrLen_t Gray::cIniSectionData::SetLinesParse ( const IniChar_t pszData,
StrLen_t  iLen = k_StrLen_UNK,
const IniChar_t pszSep = nullptr,
STRP_MASK_t  uFlags = (STRP_START_WHITE | STRP_MERGE_CRNL | STRP_END_WHITE | STRP_EMPTY_STOP) 
)

Set the section from a big data/text blob. Parse lines.

  • pszData = raw data blob to be parsed into lines. e.g. "TAG=Val\nTAG2=VAl2\n" iLen = max data string length to parse. pszSep = the separator = nullptr = Assume standard syntax. newlines at ends of lines. uFlags = STRP_START_WHITE|STRP_MERGE_CRNL|STRP_END_WHITE|STRP_EMPTY_STOP
    Returns
    size of pszData buffer actually used + 1 '\0'.

◆ WriteSectionData()

HRESULT Gray::cIniSectionData::WriteSectionData ( cStreamOutput file)

Friends And Related Function Documentation

◆ cIniFile

friend class cIniFile
friend

Member Data Documentation

◆ k_LINE_LEN_DEF

const StrLen_t Gray::cIniSectionData::k_LINE_LEN_DEF = (1024)
static

suggested/guessed/average size for lines (in chars). for alloc guessing.

◆ k_LINE_LEN_MAX

const StrLen_t Gray::cIniSectionData::k_LINE_LEN_MAX = (4 * 1024)
static

max size for a single line (in chars).

◆ k_LINE_QTY_MAX

const ITERATE_t Gray::cIniSectionData::k_LINE_QTY_MAX = (8 * 1024)
static

max number of lines i support. (per section)

◆ k_SECTION_SIZE_MAX

const StrLen_t Gray::cIniSectionData::k_SECTION_SIZE_MAX = (256 * 1024)
static

(chars) max size for whole section. (Windows Me/98/95 = 32K for INI)

◆ m_bStripComments

bool Gray::cIniSectionData::m_bStripComments
protected

has been stripped of blank lines, comments, leading and trailing line spaces.


The documentation for this class was generated from the following files: