Esempio n. 1
0
bool IniFile::readIntArrayU32(const AnsiStr& section, const AnsiStr& variable, int ctExpected, std::vector<U32>& arrayInt)
{
    AnsiStr strVal;
    if(readValue(section, variable, strVal))
    {
        int pos;
        int iComp = 0;
        AnsiStr strTemp;
        if(strVal.firstChar() == '(')
            strVal = strVal.substr(1);
        else
            return false;
        while(strVal.lfind(',', pos))
        {
            strTemp = strVal.substr(0, pos);
            strVal = strVal.substr(pos + 1);
            strVal.removeStartEndSpaces();
            arrayInt.push_back(atoi(strTemp.ptr()));
            iComp++;
        }

        if(strVal.length() >= 1)
        {
            if(strVal.lastChar() == ')')
            {
                strTemp = strVal.substr(0, strVal.length() - 1);
                strTemp.removeStartEndSpaces();
                if(strTemp.length() > 0)
                    arrayInt.push_back(atoi(strTemp.ptr()));
            }
        }
    }
    return ((int)arrayInt.size() == ctExpected);
}
Esempio n. 2
0
//====================================================================================
vec4f IniFile::readVec4f(const AnsiStr& section, const AnsiStr& variable)
{
    AnsiStr strVal;
    vec4f res;
    if(readValue(section, variable, strVal))
    {
        float f[4];
        int pos;
        int iComp = 0;
        AnsiStr strTemp;

        if(strVal.firstChar() == '(')
            strVal = strVal.substr(1);
        else
            return res;
        while(strVal.lfind(',', pos))
        {
            strTemp = strVal.substr(0, pos);
            strVal = strVal.substr(pos + 1);
            strVal.removeStartEndSpaces();
            f[iComp] = static_cast<float>(atof(strTemp.ptr()));
            iComp++;
        }

        if(strVal.length() >= 1 && iComp < 4)
        {
            if(strVal.lastChar() == ')')
            {
                strTemp = strVal.substr(0, strVal.length() - 1);
                strTemp.removeStartEndSpaces();
                f[iComp] = static_cast<float>(atof(strTemp.ptr()));
            }
        }

        res = vec4f(f[0], f[1], f[2], f[3]);
    }
    return res;
}
Esempio n. 3
0
bool ReadTextFile(const AnsiStr& strFN, std::vector<AnsiStr>& content )
{
	ifstream ifs(strFN.ptr(), ios::in);
	if(!ifs.is_open())
		return false;

	AnsiStr strLine;
	char buffer[2048];

	while( !ifs.eof())
	{
		ifs.getline(buffer, 2048);
		//ifs >> strLine;
		strLine.copyFromT(buffer);
		strLine.trim();
        strLine.removeStartEndSpaces();
		content.push_back(strLine);
	}	
	ifs.close();

	return true;
}
Esempio n. 4
0
//====================================================================================
bool IniFile::readFile()
{

    ifstream ifs(m_strFileName.ptr(), ios::in);
    if(!ifs.is_open())
        return false;


    AnsiStr strLine;
    char buffer[2048];

    while( !ifs.eof())
    {
        ifs.getline(buffer, 2048);
        //ifs >> strLine;
        strLine.copyFromT(buffer);
        strLine.trim();
        strLine.removeStartEndSpaces();
        m_content.push_back(strLine);
    }
    ifs.close();

    return true;
}