Example #1
0
IniKey* MIniFile::GetNextKey(const char* currentSectionName,const char* currentKeyName)
{
	IniSection* pSection = GetSection(currentSectionName);

	if (pSection != NULL)
	{

		IniKey* pKey = pSection->GetNextKey(currentKeyName);

		if (pKey != NULL)
		{
			return pKey;
		}
	}

	return 0;
}
Example #2
0
// Given a section name, this function first checks to see if the given section
// allready exists in the list or not, if not, it creates the new section and
// assigns it the comment given in mComment.  The function returns true if
// sucessfully created, or false otherwise.
bool IniFile::CreateSection(const string& Section, const string& mComment)
{
	IniSection* pSection = GetSection(Section);

	if ( pSection )
	{
		Log(lDebug5)<<"[IniFile::CreateSection] Section "<<Section.c_str()<<" already exists. Aborting.";
		return false;
	}

	pSection = new IniSection;
	pSection->mName = Section;
	pSection->mComment = mComment;
	mSections.push_back(pSection);
	mIsDirty = true;
	return true;
}
Example #3
0
// ALL FACE
void NPC::AllFace(int identity, int section, double x) {
    bool anyID = (identity == -1 ? true : false);
    bool anySec = (section == -1 ? true : false);
    NPCMOB* thisnpc;
    for(int i = 0; i < GM_NPCS_COUNT; i++) {
        thisnpc = Get(i);
        if (anyID || thisnpc->id == identity) {
            if(anySec || GetSection(thisnpc) == section) {
                if(x < thisnpc->momentum.x) {
                    FaceDirection(thisnpc, -1);
                } else {
                    FaceDirection(thisnpc, 1);
                }
            }
        }
    }	
}
Example #4
0
HRESULT
PEFileT<T>::GetSectionByFOA(PEAddress nFOA, IPESection **ppSection)
{
    LIBPE_ASSERT_RET(NULL != ppSection, E_POINTER);

    UINT32 nSectionCount = GetSectionCount();
    for(UINT32 nSectionIndex = 0; nSectionIndex < nSectionCount; ++nSectionIndex) {
        LibPEPtr<IPESection> pSection;
        if(SUCCEEDED(GetSection(nSectionIndex, &pSection)) && NULL != pSection) {
            if(pSection->GetFOA() <= nFOA && nFOA <= pSection->GetFOA() + pSection->GetSizeInMemory()) {
                *ppSection = pSection.Detach();
                return S_OK;
            }
        }
    }

    return E_FAIL;
}
Example #5
0
DWORD RegReadInt(const char *sect,const  char *what, DWORD def)
{
	HKEY hsect = GetSection(sect);
	if (!hsect) return def;
	DWORD dwValue;
	DWORD dwType;
	DWORD dwCount = sizeof(DWORD);
	LONG lResult = RegQueryValueEx(hsect, (LPTSTR)what, NULL, &dwType,
		(LPBYTE)&dwValue, &dwCount);
	RegCloseKey(hsect);
	if (lResult == ERROR_SUCCESS)
	{
		ASSERT(dwType == REG_DWORD);
		ASSERT(dwCount == sizeof(dwValue));
		return (UINT)dwValue;
	}
	return def;
}
Example #6
0
int32_t
HTMLTableRowElement::SectionRowIndex() const
{
  HTMLTableSectionElement* section = GetSection();
  if (!section) {
    return -1;
  }

  nsCOMPtr<nsIHTMLCollection> coll = section->Rows();
  uint32_t numRows = coll->Length();
  for (uint32_t i = 0; i < numRows; i++) {
    if (coll->GetElementAt(i) == this) {
      return i;
    }
  }

  return -1;
}
Example #7
0
// GetKey
// Given a key and section name, looks up the key and if found, returns a
// pointer to that key, otherwise returns NULL.
t_Key*   CDataFile::GetKey(t_Str szKey, t_Str szSection)
{
   KeyItor k_pos;
   t_Section* pSection;

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

   for (k_pos = pSection->Keys.begin(); k_pos != pSection->Keys.end(); k_pos++)
      {
         if ( CompareNoCase( (*k_pos).szKey, szKey ) == 0 )
            return (t_Key*)&(*k_pos);
      }

   return NULL;
}
Example #8
0
// DeleteKey
// Delete a specific key in a specific section. Returns false if the key
// cannot be found or true when sucessfully deleted.
bool CDataFile::DeleteKey(t_Str szKey, t_Str szFromSection)
{
   KeyItor k_pos;
   t_Section* pSection;

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

   for (k_pos = pSection->Keys.begin(); k_pos != pSection->Keys.end(); k_pos++)
      {
         if ( CompareNoCase( (*k_pos).szKey, szKey ) == 0 )
            {
               pSection->Keys.erase(k_pos);
               return true;
            }
      }

   return false;
}
Example #9
0
    // Get value
    const Urho3D::Variant ConfigManager::Get(const Urho3D::String& section, const Urho3D::String& parameter, const Urho3D::Variant& defaultValue)
    {
        auto sectionMap = GetSection(section);

        // Section Doesn't exist
        if (!sectionMap)
        {
            return defaultValue;
        }

        // Section exists, parmeter doesn't exist
        if (sectionMap->Find(parameter) == sectionMap->End())
        {
            return defaultValue;
        }

        // Section exists, parameter exists
        return (*sectionMap)[parameter];
    }
Example #10
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;
}
Example #11
0
// CreateSection
// Given a section name, this function first checks to see if the given section
// allready exists in the list or not, if not, it creates the new section and
// assigns it the comment given in szComment.  The function returns true if
// sucessfully created, or false otherwise.
bool CDataFile::CreateSection(t_Str szSection, t_Str szComment)
{
   t_Section* pSection = GetSection(szSection);

   if ( pSection )
      {
         Report(E_INFO, "[CDataFile::CreateSection] Section <%s> allready exists. Aborting.", szSection.c_str());
         return false;
      }

   t_Section section;

   section.szName = szSection;
   section.szComment = szComment;
   m_Sections.push_back(section);

   m_bDirty = true;

   return true;
}
Example #12
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;
}
Example #13
0
// remove list //return num of remove 0 nothing to remove 1 is success
wyInt32 
wyIni::Remove(const wyChar *sec,const wyChar *key)
{	
	struct tagSection *temp_sec = GetSection(sec);
	struct tagRecord *tmp,*tmp2;
	wyInt32	remove = 0;
	
	if(temp_sec == NULL)
		return 0;

	tmp = temp_sec->m_datafirst;
	
	if(tmp == NULL)
		return 0;
	
    if(strcmp(key,tmp->m_key.GetString()) == 0)
	{
		temp_sec->m_datafirst = tmp->m_next;
		temp_sec->m_datasize--;
        delete tmp;
		return 1;
	}
	
	while(tmp != NULL)
	{
		if(tmp->m_next != NULL)
		{
            if(strcmp(key,tmp->m_next->m_key.GetString()) == 0)
			{	
				tmp2 = tmp->m_next;				
				tmp->m_next = tmp->m_next->m_next;
				temp_sec->m_datasize--;
				delete tmp2;				
				remove = 1;
				break;
			}
		}		
		tmp = tmp->m_next;
	}		
	return remove;
}
Example #14
0
// SetKeyComment
// Set the comment of a given key. Returns true if the key is not found.
bool CDataFile::SetKeyComment(t_Str szKey, t_Str szComment, t_Str szSection)
{
   KeyItor k_pos;
   t_Section* pSection;

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

   for (k_pos = pSection->Keys.begin(); k_pos != pSection->Keys.end(); k_pos++)
      {
         if ( CompareNoCase( (*k_pos).szKey, szKey ) == 0 )
            {
               (*k_pos).szComment = szComment;
               m_bDirty = true;
               return true;
            }
      }

   return false;

}
Example #15
0
// remove all record
wyInt32 
wyIni::RemoveAll(const wyChar *sec)
{
	struct tagSection *temp_sec = GetSection(sec);
	struct tagRecord *tmp;
	wyInt32 remove = 0;
	
	if(temp_sec == NULL)
		return 0;

	tmp = temp_sec->m_datafirst;
	while(tmp != NULL)
	{
		temp_sec->m_datafirst = tmp->m_next;
		temp_sec->m_datasize--;
		free(tmp);
		remove++;
		tmp = temp_sec->m_datafirst;
	}
	return remove;
}
int32_t
HTMLTableRowElement::SectionRowIndex() const
{
  nsCOMPtr<nsIDOMHTMLTableSectionElement> section = GetSection();
  if (!section) {
    return -1;
  }

  nsCOMPtr<nsIDOMHTMLCollection> rows;
  section->GetRows(getter_AddRefs(rows));

  nsCOMPtr<nsIHTMLCollection> coll = do_QueryInterface(rows);
  uint32_t numRows = coll->Length();
  for (uint32_t i = 0; i < numRows; i++) {
    if (coll->GetElementAt(i) == this) {
      return i;
    }
  }

  return -1;
}
Example #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;
}
Example #18
0
    bool ConfigManager::Load(ConfigFile& configFile, bool overwriteExisting)
    {
        auto map = configFile.GetMap();

        SettingsMap* section = 0;
        for (auto itr = map->Begin(); itr != map->End(); itr++)
        {
            if (itr->Begin() == itr->End())
                continue;

            Urho3D::String header = Urho3D::String::EMPTY;

            if (itr != map->Begin())
            {
                header = *(itr->Begin());
                header = ConfigFile::ParseHeader(header);
            }

            auto section = GetSection(header, true);

            for (auto section_itr = ++itr->Begin(); section_itr != itr->End(); section_itr++)
            {
                auto line = *section_itr;

                Urho3D::String parameter;
                Urho3D::String value;

                ConfigFile::ParseProperty(line, parameter, value);
                
                if (parameter != Urho3D::String::EMPTY && value != Urho3D::String::EMPTY)
                {
                    Set(header, parameter, value);
                }
            }
        }

        return true;
    }
Example #19
0
string CConfigFileParser::GetValue(const char *secname,const char *keyname)
{
	if (NULL==secname || NULL==keyname)
	{
		return string("");
	}

	map<string,string> *mapSection=GetSection(secname);

	if (NULL==mapSection)
	{
		return string("");
	}

	map<string,string>::iterator it=mapSection->find(string(keyname));
	if (it!=mapSection->end())
	{
		return it->second;
	}
	else
	{
		return string("");
	}
}
Example #20
0
bool RegReadBin(const char *sect, const char *what, const void *data, int size)
{
	HKEY hsect = GetSection(sect);
	if (hsect == NULL) return false;

	DWORD dwType, dwCount;
	LONG lResult = RegQueryValueEx(hsect, (LPTSTR)what, NULL, &dwType,
		NULL, &dwCount);

	if (lResult != ERROR_SUCCESS || dwCount!=(DWORD)size) {
		RegCloseKey(hsect);	
		return false;
	}

	if (lResult == ERROR_SUCCESS)
	{
		ASSERT(dwType == REG_BINARY);
		lResult = RegQueryValueEx(hsect, (LPTSTR)what, NULL, &dwType,
			(LPBYTE)data, &dwCount);
	}

	RegCloseKey(hsect);
	return (lResult == ERROR_SUCCESS);
}
Example #21
0
/*
 *
 * Return the attribute of the polygon at a specified point, or
 * -1 if there is no polygon there.
 *
 */
int vtLULCFile::FindAttribute(double world_x, double world_z)
{
	// for speed, remember the polygon that we found last time
	static LULCPoly *previous_poly = NULL;

	DPoint2 pos2;
	pos2.x = world_x;
	pos2.y = world_z;

	if (previous_poly)
	{
		if (CrossingsTest(previous_poly->m_p, previous_poly->m_iCoords, pos2))
			return previous_poly->Attribute;
	}
	for (uint s = 0; s < NumSections(); s++)
	{
		LULCSection *section = GetSection(s);

		for (uint p = 0; p < section->m_iNumPolys; p++)
		{
			LULCPoly *poly = section->m_pPoly+p;

			if (world_x < poly->xmin || world_x > poly->xmax ||
				world_z < poly->zmin || world_z > poly->zmax)
				continue;

			if (CrossingsTest(poly->m_p, poly->m_iCoords, pos2))
			{
				previous_poly = poly;
				return poly->Attribute;
			}
		}
	}
	previous_poly = NULL;
	return -1;
}
Example #22
0
ObjExpression *ObjIeeeAscii::GetExpression(const char *buffer, int *pos)
{
    std::stack<ObjExpression *> stack;
    bool done = false;
    while (!done)
    {
        char ch = buffer[(*pos)++];
        switch(ch)
        {
            case 'I':
            case 'N':
            case 'X':
            {
                int index = ObjUtil::FromHex(buffer, pos);
                ObjSymbol *sym = FindSymbol(ch, index);
                if (!sym)
                    ThrowSyntax(buffer, eAll);
                ObjExpression *exp = factory->MakeExpression(sym);
                stack.push(exp);
                break;
            }
            case 'R':
            {
                int index = ObjUtil::FromHex(buffer, pos);
                ObjSection *sect = GetSection(index);
                if (!sect)
                    ThrowSyntax(buffer, eAll);
                ObjExpression *exp = factory->MakeExpression(sect);
                stack.push(exp);
                break;
            }
            case 'P':
            {
                ObjExpression *exp = factory->MakeExpression(ObjExpression::ePC);
                stack.push(exp);
                break;
            }
            case '+':
            case '-':
            case '/':
            case '*':
            {
                ObjExpression::eOperator type;
                switch(ch)
                {
                    case '+':
                        type = ObjExpression::eAdd;
                        break;
                    case '-':
                        type = ObjExpression::eSub;
                        break;
                    case '/':
                        type = ObjExpression::eDiv;
                        break;
                    case '*':
                        type = ObjExpression::eMul;
                        break;
                    default:
                        ThrowSyntax(buffer, eAll);
                        break;
                }
                if (stack.size() < 2)
                    ThrowSyntax(buffer, eAll);
                ObjExpression *right = stack.top(); stack.pop();
                ObjExpression *left = stack.top(); stack.pop();
                ObjExpression *exp = factory->MakeExpression(type, left, right);
                stack.push(exp);
                break;
            }
            default:
                (*pos)--;
                if (isxdigit(ch))
                {
                    int value = ObjUtil::FromHex(buffer, pos);
                    ObjExpression *exp = factory->MakeExpression(value);
                    stack.push(exp);
                }
                else
                    done = true;
        }
        if (buffer[*pos] != ',')
            done = true;
        else if (!done)
            (*pos)++;
    }
    ObjExpression *rv = NULL;
    if (stack.empty())
        ThrowSyntax(buffer, eAll);
    while (!stack.empty())
    {
        ObjExpression *exp = stack.top(); stack.pop();
        if (rv)
            rv = factory->MakeExpression(ObjExpression::eNonExpression, exp, rv);
        else
            rv = exp;
    }
    return rv;
}
Example #23
0
File: Config.cpp Project: jitrc/p3d
 bool Config::ReadBool(const std::string& section, const std::string& name, bool def)
 {
     const TiXmlElement* tag = GetSection(section.c_str());
     if (tag == NULL) return def;
     return XmlReadBool(tag, name.c_str(), def);
 }
Example #24
0
// Attempts to load in the text file. If successful it will populate the
// Section list with the key/value pairs found in the file. Note that comments
// are saved so that they can be rewritten to the file later.
bool IniFile::Load(const string& newfName)
{
	if(newfName.size())
    {
    	mIniFileName = newfName;
    }

	if(mIniFileName.size() < 1)
	{
									Log(lError)<<"Ini file name is not set!";
		return false;
	}
	else
	{
									Log(lDebug3)<<"Loading IniFile: " <<mIniFileName.Get();
	}

    if(!fileExists(mIniFileName))
    {
									Log(lDebug2)<<"The ini file: \"" <<mIniFileName.Get()<<"\" does not exist. It will be created";
        if(!createFile(mIniFileName))
        {
    								Log(lError)<<"Failed to create ini file.. returning..";
            return false;
        }
	}

	string fName(mIniFileName);
    fstream file;
	file.open(fName.c_str(), ios::in|ios::out);
	if(file.fail())
    {
    								Log(lError)<<"Opening file caused failbit to be set";
    }

	if (!file.is_open() )
	{
									Log(lError)<<"The ini file: '" <<mIniFileName<<"' could not be opened";
		return false;
	}
	else
	{
		bool bDone = false;
		bool bAutoKey = (mFlags & mAutoCreateKeys) 		== mAutoCreateKeys;
		bool bAutoSec = (mFlags & mAutoCreateSections) 	== mAutoCreateSections;
		IniSection* pSection = GetSection("");

		// These need to be set, we'll restore the original values later.
		mFlags |= mAutoCreateKeys;
		mFlags |= mAutoCreateSections;

		char* buffer = new char[MAX_LINE_BUFFER_SIZE];
        int lines = 0;
		while(!bDone)
		{
			string Comment;
			memset(buffer, 0, MAX_LINE_BUFFER_SIZE);
			file.getline(buffer, MAX_LINE_BUFFER_SIZE);
			lines++;

			string Line = buffer;
			Trim(Line);

			bDone = ( file.eof() || file.bad() || file.fail() );

			if ( Line.find_first_of(mCommentIndicators) == 0 )
			{
				Comment += "\n";
				Comment += Line;
			}
			else if ( Line.find_first_of('[') == 0 ) // Found a section
			{
				Line.erase( 0, 1 );
				Line.erase( Line.find_last_of(']'), 1 );
				pSection = GetSection(Line, true);
            	Log(lDebug3)<<"Located section: " + pSection->mName;
				Comment = string("");
			}
			else if ( Line.size() > 0 ) // we have a key, add this key/value pair
			{
                string Comment = "";
                string Key = "";
                string Value = "";

            	vector<string> record = splitString(Line, mEqualIndicator + mCommentIndicators);
                if(record.size() > 1)
				{
	                string Comment = "";
                	string Key = Trim(record[0]);
                    string Value = Trim(record[1]);
                    if(record.size() > 2)
                    {
                    	Comment = record[2];
                    }

					if(pSection)
					{
						WriteValue(Key, Value, Comment, pSection->mName);
						Log(lDebug5)<<Key << " = "  <<Value;
					}
					else
					{
                		Log(lDebug5)<<Key << " = " << Value;
						Log(lWarning)<<"No section for key"<<Key<<". Key was ignored..";
					}
					Comment = string("");
				}
				else	//Not a valid Key. Store as a NonKey
				{
					if(pSection)
					{
						WriteNonKey(Line, pSection->mName);
					}
					Log(lDebug5)<<"Read NonKey on line: " << lines;
				}
			}
		}

        delete [] buffer;
		// Restore the original flag values.
		if(!bAutoKey)
        {
			mFlags &= ~mAutoCreateKeys;
        }

		if(!bAutoSec)
        {
			mFlags &= ~mAutoCreateSections;
        }
	}
	file.close();
	return true;
}
Example #25
0
int IniFile::KeyCount(const string& section)
{
	//Get the section
    IniSection* iniSection = GetSection(section);
    return iniSection->KeyCount();
}
Example #26
0
//向一个节中添加一个键,若没有这个节则新建一个节
int MIniFile::SetValue(const char* sectionName,const char* keyName,const char* value)
{
	IniSection* pSection = GetSection(sectionName);

	if (pSection != NULL)
	{
		IniKey* pKey = GetKey(sectionName,keyName);

		LineInfo* pLineInfo =NULL;

		if (pKey != NULL)
		{
			pKey->SetValue(value);
			pLineInfo =  FindLineInfo(pKey->m_nLineNo);

		}
		else
		{
			IniKey* pLastKey = pSection->GetLastKey();

			pKey = new IniKey(pSection);
			pSection->AddKey(pKey);
			pKey->SetKeyName(keyName);
			pKey->SetValue(value);

			if (pLastKey == NULL)
			{
				//该节没有键值对
				pKey->m_nLineNo = pSection->m_nLineNo + 1;
			}
			else
			{
				pKey->m_nLineNo = pLastKey->m_nLineNo+1;
			}

			pSection->m_nKeyCount++;
			pLineInfo = new LineInfo;
			pLineInfo->type = LINE_KEYPAIR;
			pLineInfo->nLineNo = pKey->m_nLineNo;

			AdjustAllLineInfo(pLineInfo);
		}

		pLineInfo->strMainData = "\t";
		pLineInfo->strMainData += pKey->m_Key;
		pLineInfo->strMainData += "\t=\t";
		pLineInfo->strMainData += pKey->m_Value;


	}
	else
	{
		//新增节和键
		pSection = new IniSection;
		IniKey* pKey = new IniKey(pSection);

		LineInfo* pSectionLineInfo = new LineInfo;
		LineInfo* pKeyLineInfo = new LineInfo;

		pSection->SetSectionName(sectionName);
		pKey->SetKeyName(keyName);
		pKey->SetValue(value);

		pSection->AddKey(pKey);

		pSection->m_nLineNo = m_nLineCount;
		pKey->m_nLineNo = m_nLineCount + 1;

		pSectionLineInfo->nLineNo = pSection->m_nLineNo;
		pSectionLineInfo->strMainData = "[";
		pSectionLineInfo->strMainData += sectionName;
		pSectionLineInfo->strMainData += "]";

		pKeyLineInfo->nLineNo = pKey->m_nLineNo;
		pKeyLineInfo->strMainData = "\t";
		pKeyLineInfo->strMainData += pKey->m_Key;
		pKeyLineInfo->strMainData += "\t=\t";
		pKeyLineInfo->strMainData += pKey->m_Value;

		AdjustAllLineInfo(pSectionLineInfo);
		AdjustAllLineInfo(pKeyLineInfo);

		AddSection(pSection);
	}

	m_bChange = true;

	return 0;
}
Example #27
0
BOOL CEZGenericSkin::Load(IEZSkinIni* pIni,BOOL bLoadDefaultOnFailure  )
{
	
	ASSERT(pIni);
	Destroy();
	CString strSection = GetSection();
	
	CString strBmp;
	CString strType;
	CString strFont;
	CString strFontOptions;
	int nFontSize;

	BOOL bSuxs = TRUE;
		
	if(!pIni->GetValue(strSection,K_BMP,strBmp))
	{
		if(bLoadDefaultOnFailure)
			LoadDefaultBmp();
		bSuxs = FALSE;
		
		
	}
	
	if(!pIni->GetValue(strSection,K_DRAW,strType))
	{
		if(bLoadDefaultOnFailure)
			LoadDefaultBmp();
		
		bSuxs =FALSE;
	}
	
	if(!pIni->GetValue(strSection,K_BCOLOR,m_clrBk))
	{
		if(bLoadDefaultOnFailure)
			LoadDefaultBackColor();
		
		bSuxs = FALSE;
	}
	
	if(!pIni->GetValue(strSection,K_TFONT,strFont))
	{
		if(bLoadDefaultOnFailure)
			LoadDefaultFont();
		bSuxs =FALSE;
	}
	
	if(!pIni->GetValue(strSection,K_TCOLOR,m_clrTxt))
	{
		if(bLoadDefaultOnFailure)
			LoadDefaultTextColor();
		bSuxs =FALSE;
	}
	
	
	BOOL bStatus=TRUE;
	int nCount=0;
	
	CString strRGB[3];	
	while(bStatus && nCount < 3)
	{
		bStatus=AfxExtractSubString(strRGB[nCount],strFont,nCount,TCHAR(','));
		nCount++;
	}
    
	if(nCount== 3) 
	{
		
		strFont = strRGB[0];
		strFont.TrimLeft();
		strFont.TrimRight();
		
		strFontOptions = strRGB[1];
		strFontOptions.TrimLeft();
		strFontOptions.TrimRight();
		nFontSize =atol(strRGB[2]);
		
	}
	
	if(!LoadFont(strFont,strFontOptions,nFontSize))
	{
		if(bLoadDefaultOnFailure)
			LoadDefaultFont();
		bSuxs =FALSE;
	}

	strBmp = GetCurrentSkinPath()+(CString)_T('\\')+strBmp;
	if(!m_Dib.Load(strBmp))
	{
		LoadDefaultBmp();
		bSuxs =FALSE;
	}
	else
		m_Dib.SetType(GetDrawTypeFromString(strType));

	m_bLoaded = TRUE;
	return bSuxs;
	
}
Example #28
0
Ns_Set *
Ns_ConfigGetSection(char *section)
{
    return (section ? GetSection(section, 0) : NULL);
}
Example #29
0
// get size of selection section
wyInt32 
wyIni::SectionSize(wyChar *sec)
{
	struct tagSection *temp = GetSection(sec);
	return temp->m_datasize;
}
Example #30
0
IniSection* IniFile::LoadSection(const string& theSection)
{
    IniSection* pSection = NULL;
	if(mIniFileName.size() < 1)
	{
									Log(lError)<<"Ini file name is not set!";
		return NULL;
	}
	else
	{
									Log(lDebug3)<<"Loading IniFile: " <<mIniFileName.Get();
	}

    fstream file;
    if(!fileExists(mIniFileName))
    {
									Log(lDebug2)<<"The ini file: \"" <<mIniFileName.Get()<<"\" does not exist. It will be created";
	}

	string fName(mIniFileName);
	file.open(fName.c_str(), ios::in|ios::out);
	if(file.fail())
    {
    								Log(lError)<<"Opening file caused failbit to be set";
    }

	if (!file.is_open() )
	{
									Log(lError)<<"The ini file: '" <<mIniFileName<<"' could not be opened";
		return NULL;
	}
	else
	{
		bool bDone = false;
		bool bAutoKey = (mFlags & mAutoCreateKeys) 		== mAutoCreateKeys;
		bool bAutoSec = (mFlags & mAutoCreateSections) 	== mAutoCreateSections;

		char* buffer = new char[MAX_LINE_BUFFER_SIZE];
		pSection = GetSection("");

		// These need to be set, we'll restore the original values later.
		mFlags |= mAutoCreateKeys;
		mFlags |= mAutoCreateSections;

		while(!bDone)
		{
			string Comment;
			memset(buffer, 0, MAX_LINE_BUFFER_SIZE);
			file.getline(buffer, MAX_LINE_BUFFER_SIZE);

			string Line = buffer;
			Trim(Line);

			bDone = ( file.eof() || file.bad() || file.fail() );

			if ( Line.find_first_of(mCommentIndicators) == 0 )
			{
				Comment += "\n";
				Comment += Line;
			}
			else
			if ( Line.find_first_of('[') == 0 ) // Found a section
			{
				Line.erase( 0, 1 );
				Line.erase( Line.find_last_of(']'), 1 );

                if(theSection == Line)
                {
    				CreateSection(Line, Comment);
	    			pSection = GetSection(Line);
										Log(lDebug3)<<"Located ini section: " + pSection->mName;
				    Comment = string("");
                    bDone = true;
                }
			}
			else if ( Line.size() > 0 ) // we have a key, add this key/value pair
			{
				string Key = GetNextWord(Line);
				string Value = Line;

				if ( Key.size() > 0 && Value.size() > 0 )
				{
					if(pSection)
					{
						WriteValue(Key, Value, Comment, pSection->mName);
										Log(lDebug5)<<"Read Key " + Key + " Value = " + Value;
					}
					else
					{
										Log(lDebug5)<<"Read Key " + Key + " Value = " + Value;
										Log(lWarning)<<"No section for key" + Key + ". Key was ignored..";
					}
					Comment = string("");
				}
				else	//Not a valid Key. Store as a NonKey
				{
					if(pSection)
					{
						WriteNonKey(Key, pSection->mName);
						Log(lDebug5)<<"Read a NonKey: " + Key;
					}
				}
			}
		}

		// Restore the original flag values.
		if (!bAutoKey)
		{
			mFlags &= ~mAutoCreateKeys;
		}

		if (!bAutoSec)
		{
			mFlags &= ~mAutoCreateSections;
		}
	}

	file.close();
	return pSection;
}