📄 vminifileloader.h
字号:
#ifndef CONFIG_FILE_LOADER_CLASS_H_INCLUDED
#define CONFIG_FILE_LOADER_CLASS_H_INCLUDED
/*****************************************************************************/
/* HEADER FILE */
/*****************************************************************************/
/*
$Archive: $
$Revision: $
Last Checkin:
$Date: $
By:
$Author: $
Last Modification:
$ModTime: $
Description: Class that creates a structured data store representing
the contents of an ini file
TOOL And XML FORMS License
==========================
Except where otherwise noted, all of the documentation
and software included in the TOOL package is
copyrighted by Michael Swartzendruber.
Copyright (C) 2005 Michael John Swartzendruber.
All rights reserved.
Access to this code, whether intentional or accidental,
does NOT IMPLY any transfer of rights.
This software is provided "as-is," without any express
or implied warranty. In no event shall the author be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for
any purpose, including commercial applications, and to
alter and redistribute it, provided that the following
conditions are met:
1. All redistributions of source code files must retain
all copyright notices that are currently in place,
and this list of conditions without modification.
2. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
3. If you use this software in another product, an acknowledgment
in the product documentation would be appreciated but is
not required.
4. Modified versions in source or binary form must be plainly
marked as such, and must not be misrepresented as being
the original software.
*/
/*****************************************************************************/
#include <map>#include <string>typedef std::map< std::string, std::string > STRING_MAP;typedef STRING_MAP::iterator STRING_MAP_ITER;typedef std::map< std::string, STRING_MAP*> SECTION_MAP;typedef SECTION_MAP::iterator SECTION_MAP_ITER;const char cchBadFile[] = "bad_file_name";const char cchGlobal[] = "[Global]";const char cchCmdline[] = "[Cmdline]";const int ciMaxLineLength = 255;
const int ciParamNameLength = 80;
class VMIniFileLoader{public: VMIniFileLoader( void ); virtual ~VMIniFileLoader( void );public: bool LoadConfigFromFile( const std::string oFileName );
bool IsGood( void ); bool ContainsEntry( std::string oSection, std::string oKey ); bool ContainsEntry( std::string oKey ); std::string GetSectionValueAsString( std::string oSection, std::string oKey ); int GetSectionValueAsInteger( std::string oSection, std::string oKey ); bool GetSectionValueAsBool( std::string oSection, std::string oKey ); std::string GetValueAsString( std::string oKey, std::string oDefaultValue, bool bStoreDefault = false ); int GetValueAsInteger( std::string oKey, int iDefaultValue, bool bStoreDefault = false ); bool GetValueAsBool( std::string oKey, bool defaultValue, bool bStoreDefault = false); std::string GetValueAsString( std::string oSection, std::string oKey, std::string oDefaultValue, bool bStoreDefault = false ); int GetValueAsInteger( std::string oSection, std::string oKey, int iDefaultValue, bool bStoreDefault = false ); bool GetValueAsBool( std::string oSection, std::string oKey, bool bDefaultValue, bool bStoreDefault = false );
void SetProfileSectionName( std::string oName ); void SetValue( std::string oSection, std::string oKey, std::string oValue ); void SetValue( std::string oKey, std::string oValue ); void SetValue( std::string oSection, std::string oKey, int iValue ); void SetValue( std::string oKey, int iValue ); void SetValue( std::string oSection, std::string oKey, bool bValue ); void SetValue( std::string oKey, bool bValue );
int GetSection( std::string oSection, STRING_MAP& roOutput ); void SetSection( std::string oSection, STRING_MAP& roSectionValues ); SECTION_MAP* GetSectionMap( void ); std::string m_oProfileSection; std::string m_oCmdlineSection;protected: char* TrimLeft( char* pchToTrim ); char* TrimRight( char* pchToTrim ); char* TrimBoth( char* pchToTrim ); int CloneMap( STRING_MAP& roSource, STRING_MAP& roTarget );private: SECTION_MAP m_oEntries; std::string m_oFileName; std::string m_oCurrentSection; bool m_bCanLoad;};
#endif
/*****************************************************************************/
/* Check-in history
$WorkFile: $
$Archive: $
*$Log: $
*/
/*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -