Ejemplo n.º 1
0
// Given a section name, locates that section in the list and returns a pointer
// to it. If the section was not found, returns NULL
IniSection* IniFile::GetSection(const string& Section, bool create)
{
	SectionItor s_pos;
	for (s_pos = mSections.begin(); s_pos != mSections.end(); s_pos++)
	{
    	if(s_pos == mSections.end())
        {
        	return NULL;
        }
        string secName = (*s_pos)->mName;
		if ( compareNoCase( secName, Section ) == 0 )
        {
        	IniSection* sec = (*s_pos);
			return sec;
        }
	}

    if(create)
    {
        CreateSection(Section);
        return GetSection(Section, false);
    }

	return NULL;
}
Ejemplo n.º 2
0
const CDFCObject *CDFCArray::locateDFC(const std::string &strLibraryName) const
{
	for (unsigned int ndx = 0; ndx < size(); ++ndx) {
		if (compareNoCase(strLibraryName, at(ndx)->GetLibraryName()) == 0) return at(ndx);
	}
	return NULL;
}
Ejemplo n.º 3
0
void TestModel::addWeights()
{
    TelluriumData &data = * (TelluriumData*) mTestDataWithNoise.getValueHandle();
    if(!data.hasWeights())
    {
        data.allocateWeights();
    }

    double sigma = mSigma;

    for(int r = 0; r < data.rSize(); r++)
    {
        for(int c = 0; c < data.cSize(); c++)
        {
            if( compareNoCase(data.getColumnName(c), "Time") == false )
            {
                double weight = data.getWeight(r,c);
                if(weight == 1)
                {
                    data.setWeight(r,c, weight * sigma * sigma);
                }
                else
                {
                    data.setWeight(r,c, weight + sigma * sigma);
                }
            }
        }
    }
}
Ejemplo n.º 4
0
bool TestHierarchy::doesCurrentTestCaseMatch()
{
    for (std::size_t i=0; i<mCurrentTestCase.size(); ++i)
    {
        if (i < mTestCaseToRun.size())
        {
            if (mCaseSensitive)
            {
                if (mCurrentTestCase[i] != mTestCaseToRun[i])
                {
                    return false;
                }

            }
            else
            {
                if (!compareNoCase(mCurrentTestCase[i], mTestCaseToRun[i]))
                {
                    return false;
                }
            }
        }
    }

    return true;
}
Ejemplo n.º 5
0
// Set's the mFileName member variable. For use when creating the IniFile
// object by hand versus loading it from a file
void IniFile::SetFileName(const string& FileName)
{
	if (mIniFileName.size() != 0 && compareNoCase(FileName, mIniFileName) != 0)
	{
		mIsDirty = true;
	}

	mIniFileName = FileName;
}
Ejemplo n.º 6
0
// check if string end with i_end, using case neutral string comparison
bool openm::endWithNoCase(const string & i_str, const char * i_end)
{
    if (i_end == NULL) return false;

    string::size_type len = strnlen(i_end, OM_STRLEN_MAX);
    return 
        (i_str.length() >= len) && 
        0 == compareNoCase(i_str.c_str() + (i_str.length() - len), i_end);
}
Ejemplo n.º 7
0
// check if string start with i_start, using case neutral string comparison
bool openm::startWithNoCase(const string & i_str, const char * i_start)
{
    if (i_start == NULL) return false;

    string::size_type len = strnlen(i_start, OM_STRLEN_MAX);
    return 
        (i_str.length() >= len) && 
        0 == compareNoCase(i_str.c_str(), i_start, len);
}
Ejemplo n.º 8
0
// Returns the key value as a bool type. Returns false if the key is
// not found.
bool IniFile::ReadBool(const string& mKey, const string& szSection, bool def_value)
{
	bool bValue = def_value;
	string mValue = ReadValue(mKey, szSection);

	if(mWasFound)
	{
		if ( mValue.find("1") 						== 0 	
				|| compareNoCase(mValue, "true") 	== 0 
				|| compareNoCase(mValue, "yes") 	== 0 )
		{
			bValue = true;
		}
        else
        {
        	bValue = false;
        }
	}	

	return bValue;
}
Ejemplo n.º 9
0
int StringData::findNoCase(const StringData& match, int start/*=0*/)
{
	const char* pStrCompare = match.getDataBuf();
	const char* pStr = getDataBuf();
	int iLen = match.length();
	int iMaxLen = length();
	for (int i = 0; i <= iMaxLen - iLen; i++)
	{
		if (!compareNoCase(pStr + i, pStrCompare, iLen))
			return i;
	}
	return -1;
}
Ejemplo n.º 10
0
int StringData::findlastNoCase(const StringData& match, int stop/*=-1*/) const
{
	if (stop >= (int) buf.size() || stop <= 0)
		stop = buf.size() - 1;
	const char* pStr = buf.c_str();
	const char* pCompare = match.getDataBuf();
	int len = match.length();
	for (int i = stop - len + 1; i >= 0; i--)
	{
		if (!compareNoCase(pStr + i, pCompare, len))
			return i;
	}
	return -1;
}
Ejemplo n.º 11
0
// Set the comment for a given section. Returns false if the section
// was not found.
bool IniFile::SetSectionComment(const string& Section, const string& Comment)
{
	SectionItor s_pos;

	for (s_pos = mSections.begin(); s_pos != mSections.end(); s_pos++)
	{
    	string name = (*s_pos)->mName;
		if ( compareNoCase( name , Section ) == 0 )
		{
		    (*s_pos)->mComment = Comment;
			mIsDirty = true;
			return true;
		}
	}

	return false;
}
Ejemplo n.º 12
0
// Delete a specific section. Returns false if the section cannot be
// found or true when sucessfully deleted.
bool IniFile::DeleteSection(const string& Section)
{
	SectionItor s_pos;

	for (s_pos = mSections.begin(); s_pos != mSections.end(); s_pos++)
	{
		if ( compareNoCase( (*s_pos)->mName, Section ) == 0 )
		{
        	//Found a section..
            IniSection *aSection =  (*s_pos);
			mSections.erase(s_pos);
            delete (aSection);
			return true;
		}
	}

	return false;
}
Ejemplo n.º 13
0
//IniKey function
IniKey*    IniSection::GetKey(const string& keyName, bool create)
{
    //Go trough the key list and return key with key name
       KeyItor k_pos;
    for (k_pos = mKeys.begin(); k_pos != mKeys.end(); k_pos++)
    {
        if ( compareNoCase( (*k_pos)->mKey, keyName ) == 0 )
            return *k_pos;
    }

    if(create)
    {
        CreateKey(keyName);
        return GetKey(keyName, false);
    }

    return NULL;
}
Ejemplo n.º 14
0
// Given a key and section name, looks up the key and if found, returns a
// pointer to that key, otherwise returns NULL.
IniKey*	IniFile::GetKey(const string& Key, const string& Section)
{
	IniSection* pSection;
	KeyItor k_pos;

	// Since our default section has a name value of string("") this should
	// always return a valid section, wether or not it has any keys in it is
	// another matter.
	if ( (pSection = GetSection(Section)) == NULL )
		return NULL;

	for (k_pos = pSection->mKeys.begin(); k_pos != pSection->mKeys.end(); k_pos++)
	{
		if ( compareNoCase( (*k_pos)->mKey, Key ) == 0 )
			return (*k_pos);
	}

	return NULL;
}
Ejemplo n.º 15
0
bool StringData::isEndWith(const StringData& str, bool bCase) const
{
	if (buf.length() < str.length())
		return false;
	StringData subStr = buf.substr(buf.length() - str.length());
	if (bCase)
	{
		if (subStr == str)
			return true;
		else
			return false;
	}
	else
	{
		if (compareNoCase(subStr.getData(), str.getData(), str.length()) == 0)
			return true;
		else
			return false;
	}
}
Ejemplo n.º 16
0
// Set the comment of a given key. Returns true if the key is not found.
bool IniFile::SetKeyComment(const string& mKey, const string& mComment, const string& szSection)
{
	KeyItor k_pos;
	IniSection* pSection;

	if ( (pSection = GetSection(szSection)) == NULL )
		return false;

	for (k_pos = pSection->mKeys.begin(); k_pos != pSection->mKeys.end(); k_pos++)
	{
		if ( compareNoCase( (*k_pos)->mKey, mKey ) == 0 )
		{
			(*k_pos)->mComment = mComment;
			mIsDirty = true;
			return true;
		}
	}

	return false;
}
Ejemplo n.º 17
0
// Delete a specific key in a specific section. Returns false if the key
// cannot be found or true when sucessfully deleted.
bool IniFile::DeleteKey(const string& Key, const string& FromSection)
{
	KeyItor k_pos;
	IniSection* pSection;

	if ( (pSection = GetSection(FromSection)) == NULL )
		return false;

	for (k_pos = pSection->mKeys.begin(); k_pos != pSection->mKeys.end(); k_pos++)
	{
		if ( compareNoCase( (*k_pos)->mKey, Key ) == 0 )
		{
        	IniKey* aKey = (*k_pos);
			pSection->mKeys.erase(k_pos);
            delete aKey;
			return true;
		}
	}

	return false;
}
Ejemplo n.º 18
0
	//------------------------------------------------------------------------
	bool StrUtil::equalsNoCase(const char* _text1, const char* _text2)
	{
		return compareNoCase(_text1, _text2) == 0;
	}
Ejemplo n.º 19
0
// case neutral string equal comparison
bool openm::equalNoCase(const char * i_left, const char * i_right, size_t i_length)
{
    return compareNoCase(i_left, i_right, i_length) == 0;
}