Esempio n. 1
0
BOOL	CInifile::line_exist( LPCSTR S, LPCSTR L )
{
    if (!section_exist(S)) return FALSE;
    Sect&	I = r_section(S);
    SectCIt A = std::lower_bound(I.Data.begin(),I.Data.end(),L,item_pred);
    return (A!=I.Data.end() && xr_strcmp(*A->first,L)==0);
}
Esempio n. 2
0
//--------------------------------------------------------------------------------------------------------
// Write functions
//--------------------------------------------------------------------------------------
void CInifile::w_string( LPCSTR S, LPCSTR L, LPCSTR V, LPCSTR comment)
{
    R_ASSERT			(!m_flags.test(eReadOnly));

    // section
    string256			sect;
    _parse				(sect,S);
    _strlwr				(sect);

    if (!section_exist(sect))
    {
        // create _new_ section
        Sect			*NEW = new Sect();
        NEW->Name		= sect;
        RootIt I		= std::lower_bound(DATA.begin(),DATA.end(),sect,sect_pred);
        DATA.insert		(I,NEW);
    }

    // parse line/value
    string4096			line;
    _parse				(line,L);
    string4096			value;
    _parse				(value,V);

    // duplicate & insert
    Item	I;
    Sect&	data	= r_section	(sect);
    I.first			= (line[0]?line:0);
    I.second		= (value[0]?value:0);

#ifdef DEBUG
    I.comment		= (comment?comment:0);
#endif
    SectIt_	it		= std::lower_bound(data.Data.begin(),data.Data.end(),*I.first,item_pred);

    if (it != data.Data.end())
    {
        // Check for "first" matching
        if (0==xr_strcmp(*it->first, *I.first))
        {
            BOOL b = m_flags.test(eOverrideNames);
            R_ASSERT2(b,make_string("name[%s] already exist in section[%s]",line,sect).c_str());
            *it  = I;
        } else
        {
            data.Data.insert(it,I);
        }
    } else {
        data.Data.insert(it,I);
    }
}
Esempio n. 3
0
//--------------------------------------------------------------------------------------------------------
// Write functions
//--------------------------------------------------------------------------------------
void	CInifile::w_string	( LPCSTR S, LPCSTR L, LPCSTR			V, LPCSTR comment)
{
	R_ASSERT	(!bReadOnly);

	// section
	char	sect	[256];
	_parse	(sect,S);
	_strlwr	(sect);
	if (!section_exist(sect))	{
		// create _new_ section
		Sect			*NEW = xr_new<Sect>();
		NEW->Name		= sect;
		RootIt I		= std::lower_bound(DATA.begin(),DATA.end(),sect,sect_pred);
		DATA.insert		(I,NEW);
	}

	// parse line/value
	char	line	[256];	_parse	(line,L);
	char	value	[256];	_parse	(value,V);

	// duplicate & insert
	Item	I;
	Sect&	data	= r_section	(sect);
	I.first			= (line[0]?line:0);
	I.second		= (value[0]?value:0);
#ifdef DEBUG
	I.comment		= (comment?comment:0);
#endif
	SectIt_	it		= std::lower_bound(data.Data.begin(),data.Data.end(),*I.first,item_pred);

    if (it != data.Data.end()) {
	    // Check for "first" matching
    	if (0==xr_strcmp(*it->first,*I.first)) {
            *it  = I;
        } else {
			data.Data.insert(it,I);
        }
    } else {
		data.Data.insert(it,I);
    }
}
Esempio n. 4
0
BOOL			CInifile::section_exist	( const shared_str& S	)					{
    return	section_exist(*S);
}