亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? datafile.cpp

?? Convert Interface on a embedded System
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//
// CDataFile Class Implementation
//
// The purpose of this class is to provide a simple, full featured means to
// store persistent data to a text file.  It uses a simple key/value paradigm
// to achieve this.  The class can read/write to standard Windows .ini files,
// and yet does not rely on any windows specific calls.  It should work as
// well in a linux environment (with some minor adjustments) as it does in
// a Windows one.
//
// Written July, 2002 by Gary McNickle <gary#sunstorm.net>
// If you use this class in your application, credit would be appreciated.
//

//
// CDataFile
// The purpose of this class is to provide the means to easily store key/value
// pairs in a config file, seperated by independant sections. Sections may not
// have duplicate keys, although two or more sections can have the same key.
// Simple support for comments is included. Each key, and each section may have
// it's own multiline comment.
//
// An example might look like this;
//
// [UserSettings]
// Name=Joe User
// Date of Birth=12/25/01
//
// ;
// ; Settings unique to this server
// ;
// [ServerSettings]
// Port=1200
// IP_Address=127.0.0.1
// MachineName=ADMIN
//

#include <vector>
#include <string>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
//#include <fstream.h>
#include <float.h>

#ifdef WIN32
#include <windows.h>
#endif

#include "DataFile.h"

using namespace std;
#include <iosfwd>
#include <fstream>

// Compatibility Defines ////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
#ifdef WIN32
  #define snprintf  _snprintf
  #define vsnprintf _vsnprintf
#endif


// CDataFile
// Our default contstructor.  If it can load the file, it will do so and populate
// the section list with the values from the file.
CDataFile::CDataFile(t_Str szFileName)
{
	m_bDirty = false;
	m_szFileName = szFileName;
	m_Flags = (AUTOCREATE_SECTIONS | AUTOCREATE_KEYS);
	m_Sections.push_back( *(new t_Section) );

	Load(m_szFileName);
}

CDataFile::CDataFile()
{
	Clear();
	m_Flags = (AUTOCREATE_SECTIONS | AUTOCREATE_KEYS);
	m_Sections.push_back( *(new t_Section) );
}

// ~CDataFile
// Saves the file if any values have changed since the last save.
CDataFile::~CDataFile()
{
	if ( m_bDirty )
		Save();
}

// Clear
// Resets the member variables to their defaults
void CDataFile::Clear()
{
	m_bDirty = false;
	m_szFileName = t_Str("");
	m_Sections.clear();
}

// SetFileName
// Set's the m_szFileName member variable. For use when creating the CDataFile
// object by hand (-vs- loading it from a file
void CDataFile::SetFileName(t_Str szFileName)
{
	if (m_szFileName.size() != 0 && CompareNoCase(szFileName, m_szFileName) != 0)
	{
		m_bDirty = true;

		Report(E_WARN, "[CDataFile::SetFileName] The filename has changed from <%s> to <%s>.",
			   m_szFileName.c_str(), szFileName.c_str());
	}

	m_szFileName = szFileName;
}

// Load
// 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 CDataFile::Load(t_Str szFileName)
{
	// We dont want to create a new file here.  If it doesn't exist, just
	// return false and report the failure.
	fstream File(szFileName.c_str(), ios::in/*|ios::nocreate*/);

	if ( File.is_open() )
	{
		bool bDone = false;
		bool bAutoKey = (m_Flags & AUTOCREATE_KEYS) == AUTOCREATE_KEYS;
		bool bAutoSec = (m_Flags & AUTOCREATE_SECTIONS) == AUTOCREATE_SECTIONS;
		
		t_Str szLine;
		t_Str szComment;
		char buffer[MAX_BUFFER_LEN]; 
		t_Section* pSection = GetSection("");

		// These need to be set, we'll restore the original values later.
		m_Flags |= AUTOCREATE_KEYS;
		m_Flags |= AUTOCREATE_SECTIONS;

		while ( !bDone )
		{
			memset(buffer, 0, MAX_BUFFER_LEN);
			File.getline(buffer, MAX_BUFFER_LEN);

			szLine = buffer;
			Trim(szLine);

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

			if ( szLine.find_first_of(CommentIndicators) == 0 )
			{
				szComment += "\n";
				szComment += szLine;
			}
			else
			if ( szLine.find_first_of('[') == 0 ) // new section
			{
				szLine.erase( 0, 1 );
				szLine.erase( szLine.find_last_of(']'), 1 );

				CreateSection(szLine, szComment);
				pSection = GetSection(szLine);
				szComment = t_Str("");
			}
			else 
			if ( szLine.size() > 0 ) // we have a key, add this key/value pair
			{
				t_Str szKey = GetNextWord(szLine);
				t_Str szValue = szLine;

				if ( szKey.size() > 0 && szValue.size() > 0 )
				{
					SetValue(szKey, szValue, szComment, pSection->szName);
					szComment = t_Str("");
				}
			}
		}

		// Restore the original flag values.
		if ( !bAutoKey )
			m_Flags &= ~AUTOCREATE_KEYS;

		if ( !bAutoSec )
			m_Flags &= ~AUTOCREATE_SECTIONS;
	}
	else
	{
		Report(E_INFO, "[CDataFile::Load] Unable to open file. Does it exist?");
		return false;
	}

	File.close();

	return true;
}


// Save
// Attempts to save the Section list and keys to the file. Note that if Load
// was never called (the CDataFile object was created manually), then you
// must set the m_szFileName variable before calling save.
bool CDataFile::Save()
{
	if ( KeyCount() == 0 && SectionCount() == 0 )
	{
		// no point in saving
		Report(E_INFO, "[CDataFile::Save] Nothing to save.");
		return false; 
	}

	if ( m_szFileName.size() == 0 )
	{
		Report(E_ERROR, "[CDataFile::Save] No filename has been set.");
		return false;
	}

	fstream File(m_szFileName.c_str(), ios::out|ios::trunc);

	if ( File.is_open() )
	{
		SectionItor s_pos;
		KeyItor k_pos;
		t_Section Section;
		t_Key Key;

		for (s_pos = m_Sections.begin(); s_pos != m_Sections.end(); s_pos++)
		{
			Section = (*s_pos);
			bool bWroteComment = false;

			if ( Section.szComment.size() > 0 )
			{
				bWroteComment = true;
				WriteLn(File, "\n%s", CommentStr(Section.szComment).c_str());
			}

			if ( Section.szName.size() > 0 )
			{
				WriteLn(File, "%s[%s]", 
						bWroteComment ? "" : "\n", 
						Section.szName.c_str());
			}

			for (k_pos = Section.Keys.begin(); k_pos != Section.Keys.end(); k_pos++)
			{
				Key = (*k_pos);

				if ( Key.szKey.size() > 0 && Key.szValue.size() > 0 )
				{
					WriteLn(File, "%s%s%s%s%c%s", 
						Key.szComment.size() > 0 ? "\n" : "",
						CommentStr(Key.szComment).c_str(),
						Key.szComment.size() > 0 ? "\n" : "",
						Key.szKey.c_str(),
						EqualIndicators[0],
						Key.szValue.c_str());
				}
			}
		}
		
	}
	else
	{
		Report(E_ERROR, "[CDataFile::Save] Unable to save file.");
		return false;
	}

	m_bDirty = false;
	
	File.flush();
	File.close();

	return true;
}

// 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;

}

// SetSectionComment
// Set the comment for a given section. Returns false if the section
// was not found.
bool CDataFile::SetSectionComment(t_Str szSection, t_Str szComment)
{
	SectionItor s_pos;

	for (s_pos = m_Sections.begin(); s_pos != m_Sections.end(); s_pos++)
	{
		if ( CompareNoCase( (*s_pos).szName, szSection ) == 0 ) 
		{
		    (*s_pos).szComment = szComment;
			m_bDirty = true;
			return true;
		}
	}

	return false;
}


// SetValue
// Given a key, a value and a section, this function will attempt to locate the
// Key within the given section, and if it finds it, change the keys value to
// the new value. If it does not locate the key, it will create a new key with
// the proper value and place it in the section requested.
bool CDataFile::SetValue(t_Str szKey, t_Str szValue, t_Str szComment, t_Str szSection)
{
	t_Key* pKey = GetKey(szKey, szSection);
	t_Section* pSection = GetSection(szSection);

	if (pSection == NULL)
	{
		if ( !(m_Flags & AUTOCREATE_SECTIONS) || !CreateSection(szSection,""))
			return false;

		pSection = GetSection(szSection);
	}

	// Sanity check...
	if ( pSection == NULL )
		return false;

	// if the key does not exist in that section, and the value passed 
	// is not t_Str("") then add the new key.
	if ( pKey == NULL && szValue.size() > 0 && (m_Flags & AUTOCREATE_KEYS))
	{
		pKey = new t_Key;

		pKey->szKey = szKey;
		pKey->szValue = szValue;
		pKey->szComment = szComment;
		
		m_bDirty = true;
		
		pSection->Keys.push_back(*pKey);

		return true;
	}

	if ( pKey != NULL )
	{
		pKey->szValue = szValue;
		pKey->szComment = szComment;

		m_bDirty = true;
		
		return true;
	}

	return false;
}

// SetFloat
// Passes the given float to SetValue as a string
bool CDataFile::SetFloat(t_Str szKey, float fValue, t_Str szComment, t_Str szSection)
{
	char szStr[64];

	_snprintf(szStr, 64, "%f", fValue);

	return SetValue(szKey, szStr, szComment, szSection);
}

// SetInt
// Passes the given int to SetValue as a string
bool CDataFile::SetInt(t_Str szKey, int nValue, t_Str szComment, t_Str szSection)
{
	char szStr[64];

	_snprintf(szStr, 64, "%d", nValue);

	return SetValue(szKey, szStr, szComment, szSection);

}

// SetBool
// Passes the given bool to SetValue as a string
bool CDataFile::SetBool(t_Str szKey, bool bValue, t_Str szComment, t_Str szSection)
{
	t_Str szValue = bValue ?  "True" : "False";

	return SetValue(szKey, szValue, szComment, szSection);
}

// GetValue
// Returns the key value as a t_Str object. A return value of
// t_Str("") indicates that the key could not be found.
t_Str CDataFile::GetValue(t_Str szKey, t_Str szSection) 
{
	t_Key* pKey = GetKey(szKey, szSection);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99这里只有精品| 91精品久久久久久久久99蜜臂| 欧美精品第1页| 国产精品欧美一区喷水| 久久激五月天综合精品| 不卡电影一区二区三区| 国产精品美女久久久久高潮| 极品少妇xxxx精品少妇| 日韩久久久久久| 久久狠狠亚洲综合| 88在线观看91蜜桃国自产| 日韩—二三区免费观看av| 欧美日韩视频第一区| 亚洲成人1区2区| 91国偷自产一区二区三区观看| 中文字幕一区二区三区精华液| 国产一区二区三区四区在线观看| 精品久久久久久久久久久院品网| 日本欧美在线看| 日韩欧美国产综合| 国产成人日日夜夜| 亚洲人成影院在线观看| 91麻豆精品国产91久久久资源速度| 日产国产欧美视频一区精品| 日韩久久免费av| caoporn国产一区二区| 亚洲免费在线电影| 欧美成人一区二区三区在线观看| 国产精品综合一区二区| 亚洲美腿欧美偷拍| 久久久国产一区二区三区四区小说| 成人综合婷婷国产精品久久| 亚洲国产va精品久久久不卡综合| 日韩精品一区二区三区swag| 色哦色哦哦色天天综合| 捆绑调教一区二区三区| 亚洲免费观看在线观看| 欧美v国产在线一区二区三区| 国产在线一区二区| 亚洲国产成人av| 国产精品久久久久桃色tv| 88在线观看91蜜桃国自产| 日本久久一区二区| 99re8在线精品视频免费播放| 美女视频网站黄色亚洲| 国产精品久久久久久久久久久免费看 | 91丝袜国产在线播放| 秋霞影院一区二区| 日韩电影在线免费观看| 亚洲一本大道在线| 亚洲自拍偷拍av| 综合亚洲深深色噜噜狠狠网站| 国产三级三级三级精品8ⅰ区| 日韩欧美在线1卡| 欧美大片日本大片免费观看| 青青草国产精品97视觉盛宴| 在线综合亚洲欧美在线视频| 国产成人精品免费一区二区| 国产一区二区三区四| 国产一区三区三区| 国产成人免费视频网站 | 粉嫩久久99精品久久久久久夜| 精品一区二区在线观看| 粉嫩高潮美女一区二区三区| 成人深夜在线观看| 成人h动漫精品一区二区| 91啪九色porn原创视频在线观看| 99国产精品国产精品毛片| 色综合久久久久综合体桃花网| 欧美做爰猛烈大尺度电影无法无天| 色欧美88888久久久久久影院| 欧美三级蜜桃2在线观看| 精品久久久久久久久久久院品网| 国产欧美va欧美不卡在线| 亚洲女女做受ⅹxx高潮| 韩国中文字幕2020精品| 东方aⅴ免费观看久久av| 欧美在线制服丝袜| 久久久噜噜噜久噜久久综合| 亚洲精品国产品国语在线app| 日韩中文字幕一区二区三区| 成人综合在线视频| 91麻豆精品国产91久久久久久| 国产视频亚洲色图| 日韩中文字幕区一区有砖一区| 成人自拍视频在线| 日韩欧美激情在线| 亚洲一区二区精品3399| 国产精品一区二区久激情瑜伽| 在线观看av一区| 亚洲欧美aⅴ...| 99r国产精品| 国产精品区一区二区三区| 精品影视av免费| 欧美一二三四在线| 日韩高清欧美激情| 欧美精品一卡二卡| 亚洲成av人片观看| 欧美体内she精高潮| 一区二区国产视频| 色妹子一区二区| 亚洲高清视频的网址| 不卡免费追剧大全电视剧网站| 欧美激情一区在线观看| 国产精品亚洲视频| 国产精品视频一二三区| 国产a级毛片一区| 国产精品天干天干在观线| 国内精品久久久久影院薰衣草 | 自拍偷拍国产精品| 91视视频在线观看入口直接观看www | 日韩国产欧美一区二区三区| 88在线观看91蜜桃国自产| 麻豆精品久久精品色综合| 精品欧美久久久| 成人免费高清视频在线观看| 亚洲天堂网中文字| 欧美高清你懂得| 国产一区二区三区av电影 | 亚洲品质自拍视频| 欧美三区在线观看| 久久超碰97人人做人人爱| 国产亚洲欧美中文| 欧美蜜桃一区二区三区| 国产成人av电影在线| 亚洲精品日韩一| 久久久精品日韩欧美| 欧美在线一二三四区| 国内成人免费视频| 亚洲成人777| 自拍偷拍亚洲激情| 久久久亚洲精品一区二区三区| 99久久精品国产导航| 久久机这里只有精品| 亚洲电影你懂得| 亚洲欧美日韩国产综合| 精品国产一区久久| 欧美精品久久天天躁| av亚洲精华国产精华| 国产一区二区毛片| 九一九一国产精品| 日韩精品一级二级| 亚洲午夜免费视频| 国产精品亲子伦对白| 青青草国产成人99久久| 欧美一区永久视频免费观看| 91在线视频网址| 成人免费观看视频| 国产91丝袜在线播放| 国产一区激情在线| 国产精品一区二区黑丝| 国产精品一区免费视频| 国产福利视频一区二区三区| 激情综合网av| 国产suv精品一区二区三区| 国产九色精品成人porny| 国产成人av自拍| 成人av影视在线观看| 色网综合在线观看| 欧美日韩国产123区| 51精品国自产在线| 日韩久久精品一区| 国产日韩欧美麻豆| 亚洲婷婷在线视频| 午夜精品免费在线观看| 日本不卡一二三区黄网| 国产经典欧美精品| 欧美专区在线观看一区| 日韩欧美一级精品久久| 久久精品欧美一区二区三区不卡| 国产精品国产自产拍高清av| ●精品国产综合乱码久久久久| 亚洲成人动漫在线免费观看| 日本成人在线网站| av午夜精品一区二区三区| 欧美伊人久久久久久午夜久久久久| 欧美日本国产一区| 欧美国产一区二区在线观看| 亚洲精品日日夜夜| 国产成人午夜精品影院观看视频 | 亚洲桃色在线一区| 极品少妇一区二区| 欧美最新大片在线看| 国产精品另类一区| 久久成人免费网站| 欧美精品高清视频| 亚洲视频在线一区二区| 国产露脸91国语对白| 日韩欧美国产精品| 日韩在线卡一卡二| 欧美日韩综合在线| 亚洲图片另类小说| 99精品一区二区| 中文字幕一区二区三区乱码在线| 国产精品一区在线观看乱码| 精品久久久久久亚洲综合网| 免费av成人在线| 精品国产电影一区二区| 免费高清在线视频一区·| 91麻豆精品国产无毒不卡在线观看|