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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? inireader.cpp

?? KeePassX用于保護密碼的安全
?? CPP
字號:
// IniFile.cpp:  Implementation of the CIniFile class.
// Written by:   Adam Clauss
// Email: cabadam@houston.rr.com
// You may use this class/code as you wish in your programs.  Feel free to distribute it, and
// email suggested changes to me.
//
// Rewritten by: Shane Hill
// Date:         21/08/2001
// Email:        Shane.Hill@dsto.defence.gov.au
// Reason:       Remove dependancy on MFC. Code should compile on any
//               platform.
//////////////////////////////////////////////////////////////////////


// C++ Includes
#include <iostream>
#include <fstream>
#include <strstream>

// C Includes
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>

// Local Includes
#include "IniReader.h"
#include <qglobal.h>

#if defined(Q_WS_WIN)
#define iniEOL endl
#else
#define iniEOL '\r' << endl
#endif

CIniFile::CIniFile( string const iniPath)
{
  Path( iniPath);
  caseInsensitive = true;
}

bool CIniFile::ReadFile()
{
  // Normally you would use ifstream, but the SGI CC compiler has
  // a few bugs with ifstream. So ... fstream used.
  fstream f;
  string   line;
  string   keyname, valuename, value;
  string::size_type pLeft, pRight;

  f.open( path.c_str(), ios::in);
  if ( f.fail())
    return false;
  
  while( getline( f, line)) {
    // To be compatible with Win32, check for existence of '\r'.
    // Win32 files have the '\r' and Unix files don't at the end of a line.
    // Note that the '\r' will be written to INI files from
    // Unix so that the created INI file can be read under Win32
    // without change.
	if( !line.length())continue;
    if ( line[line.length() - 1] == '\r')
      line = line.substr( 0, line.length() - 1);
    
    if ( line.length()) {
      // Check that the user hasn't openned a binary file by checking the first
      // character of each line!
      if ( !isprint( line[0])) {
	printf( "Failing on char %d\n", line[0]);
	f.close();
	return false;
      }
      if (( pLeft = line.find_first_of(";#[=")) != string::npos) {
	switch ( line[pLeft]) {
	case '[':
	  if ((pRight = line.find_last_of("]")) != string::npos &&
	      pRight > pLeft) {
	    keyname = line.substr( pLeft + 1, pRight - pLeft - 1);
	    AddKeyName( keyname);
	  }
	  break;
	  
	case '=':
	  valuename = line.substr( 0, pLeft);
	  value = line.substr( pLeft + 1);
	  SetValue( keyname, valuename, value);
	  break;
	  
	case ';':
	case '#':
	  if ( !names.size())
	    HeaderComment( line.substr( pLeft + 1));
	  else
	    KeyComment( keyname, line.substr( pLeft + 1));
	  break;
	}
      }
    }
  }

  f.close();
  if ( names.size())
    return true;
  return false;
}

bool CIniFile::WriteFile()
{
  unsigned commentID, keyID, valueID;
  // Normally you would use ofstream, but the SGI CC compiler has
  // a few bugs with ofstream. So ... fstream used.
  fstream f;

  f.open( path.c_str(), ios::out);
  if ( f.fail())
    return false;

  // Write header comments.
  for ( commentID = 0; commentID < comments.size(); ++commentID)
    f << ';' << comments[commentID] << iniEOL;
  if ( comments.size())
    f << iniEOL;

  // Write keys and values.
  for ( keyID = 0; keyID < keys.size(); ++keyID) {
    f << '[' << names[keyID] << ']' << iniEOL;
    // Comments.
    for ( commentID = 0; commentID < keys[keyID].comments.size(); ++commentID)
      f << ';' << keys[keyID].comments[commentID] << iniEOL;
    // Values.
    for ( valueID = 0; valueID < keys[keyID].names.size(); ++valueID)
      f << keys[keyID].names[valueID] << '=' << keys[keyID].values[valueID] << iniEOL;
    f << iniEOL;
  }
  f.close();
  
  return true;
}

long CIniFile::FindKey( string const keyname) const
{
  for ( unsigned keyID = 0; keyID < names.size(); ++keyID)
    if ( CheckCase( names[keyID]) == CheckCase( keyname))
      return long(keyID);
  return noID;
}

long CIniFile::FindValue( unsigned const keyID, string const valuename) const
{
  if ( !keys.size() || keyID >= keys.size())
    return noID;

  for ( unsigned valueID = 0; valueID < keys[keyID].names.size(); ++valueID)
    if ( CheckCase( keys[keyID].names[valueID]) == CheckCase( valuename))
      return long(valueID);
  return noID;
}

unsigned CIniFile::AddKeyName( string const keyname)
{
  names.resize( names.size() + 1, keyname);
  keys.resize( keys.size() + 1);
  return names.size() - 1;
}

string CIniFile::KeyName( unsigned const keyID) const
{
  if ( keyID < names.size())
    return names[keyID];
  else
    return "";
}

unsigned CIniFile::NumValues( unsigned const keyID)
{
  if ( keyID < keys.size())
    return keys[keyID].names.size();
  return 0;
}

unsigned CIniFile::NumValues( string const keyname)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return 0;
  return keys[keyID].names.size();
}

string CIniFile::ValueName( unsigned const keyID, unsigned const valueID) const
{
  if ( keyID < keys.size() && valueID < keys[keyID].names.size())
    return keys[keyID].names[valueID];
  return "";
}

string CIniFile::ValueName( string const keyname, unsigned const valueID) const
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return "";
  return ValueName( keyID, valueID);
}

bool CIniFile::SetValue( unsigned const keyID, unsigned const valueID, string const value)
{
  if ( keyID < keys.size() && valueID < keys[keyID].names.size())
    keys[keyID].values[valueID] = value;

  return false;
}

bool CIniFile::SetValue( string const keyname, string const valuename, string const value, bool const create)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID) {
    if ( create)
      keyID = long( AddKeyName( keyname));
    else
      return false;
  }

  long valueID = FindValue( unsigned(keyID), valuename);
  if ( valueID == noID) {
    if ( !create)
      return false;
    keys[keyID].names.resize( keys[keyID].names.size() + 1, valuename);
    keys[keyID].values.resize( keys[keyID].values.size() + 1, value);
  } else
    keys[keyID].values[valueID] = value;

  return true;
}

bool CIniFile::SetValueI( string const keyname, string const valuename, int const value, bool const create)
{
  char svalue[MAX_VALUEDATA];

  sprintf( svalue, "%d", value);
  return SetValue( keyname, valuename, svalue);
}

bool CIniFile::SetValueF( string const keyname, string const valuename, double const value, bool const create)
{
  char svalue[MAX_VALUEDATA];

  sprintf( svalue, "%f", value);
  return SetValue( keyname, valuename, svalue);
}

bool CIniFile::SetValueV( string const keyname, string const valuename, char *format, ...)
{
  va_list args;
  char value[MAX_VALUEDATA];

  va_start( args, format);
  vsprintf( value, format, args);
  va_end( args);
  return SetValue( keyname, valuename, value);
}

string CIniFile::GetValue( unsigned const keyID, unsigned const valueID, string const defValue) const
{
  if ( keyID < keys.size() && valueID < keys[keyID].names.size())
    return keys[keyID].values[valueID];
  return defValue;
}

string CIniFile::GetValue( string const keyname, string const valuename, string const defValue) const
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return defValue;

  long valueID = FindValue( unsigned(keyID), valuename);
  if ( valueID == noID)
    return defValue;

  return keys[keyID].values[valueID];
}

int CIniFile::GetValueI(string const keyname, string const valuename, int const defValue) const
{
  char svalue[MAX_VALUEDATA];

  sprintf( svalue, "%d", defValue);
  return atoi( GetValue( keyname, valuename, svalue).c_str()); 
}

double CIniFile::GetValueF(string const keyname, string const valuename, double const defValue) const
{
  char svalue[MAX_VALUEDATA];

  sprintf( svalue, "%f", defValue);
  return atof( GetValue( keyname, valuename, svalue).c_str()); 
}

// 16 variables may be a bit of over kill, but hey, it's only code.
unsigned CIniFile::GetValueV( string const keyname, string const valuename, char *format,
			      void *v1, void *v2, void *v3, void *v4,
  			      void *v5, void *v6, void *v7, void *v8,
  			      void *v9, void *v10, void *v11, void *v12,
  			      void *v13, void *v14, void *v15, void *v16)
{
  string   value;
  // va_list  args;
  unsigned nVals;


  value = GetValue( keyname, valuename);
  if ( !value.length())
    return false;
  // Why is there not vsscanf() function. Linux man pages say that there is
  // but no compiler I've seen has it defined. Bummer!
  //
  // va_start( args, format);
  // nVals = vsscanf( value.c_str(), format, args);
  // va_end( args);

  nVals = sscanf( value.c_str(), format,
		  v1, v2, v3, v4, v5, v6, v7, v8,
		  v9, v10, v11, v12, v13, v14, v15, v16);

  return nVals;
}

bool CIniFile::DeleteValue( string const keyname, string const valuename)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return false;

  long valueID = FindValue( unsigned(keyID), valuename);
  if ( valueID == noID)
    return false;

  // This looks strange, but is neccessary.
  vector<string>::iterator npos = keys[keyID].names.begin() + valueID;
  vector<string>::iterator vpos = keys[keyID].values.begin() + valueID;
  keys[keyID].names.erase( npos, npos + 1);
  keys[keyID].values.erase( vpos, vpos + 1);

  return true;
}

bool CIniFile::DeleteKey( string const keyname)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return false;

  // Now hopefully this destroys the vector lists within keys.
  // Looking at <vector> source, this should be the case using the destructor.
  // If not, I may have to do it explicitly. Memory leak check should tell.
  // memleak_test.cpp shows that the following not required.
  //keys[keyID].names.clear();
  //keys[keyID].values.clear();

  vector<string>::iterator npos = names.begin() + keyID;
  vector<key>::iterator    kpos = keys.begin() + keyID;
  names.erase( npos, npos + 1);
  keys.erase( kpos, kpos + 1);

  return true;
}

void CIniFile::Erase()
{
  // This loop not needed. The vector<> destructor seems to do
  // all the work itself. memleak_test.cpp shows this.
  //for ( unsigned i = 0; i < keys.size(); ++i) {
  //  keys[i].names.clear();
  //  keys[i].values.clear();
  //}
  names.clear();
  keys.clear();
  comments.clear();
}

void CIniFile::HeaderComment( string const comment)
{
  comments.resize( comments.size() + 1, comment);
}

string CIniFile::HeaderComment( unsigned const commentID) const
{
  if ( commentID < comments.size())
    return comments[commentID];
  return "";
}

bool CIniFile::DeleteHeaderComment( unsigned commentID)
{
  if ( commentID < comments.size()) {
    vector<string>::iterator cpos = comments.begin() + commentID;
    comments.erase( cpos, cpos + 1);
    return true;
  }
  return false;
}

unsigned CIniFile::NumKeyComments( unsigned const keyID) const
{
  if ( keyID < keys.size())
    return keys[keyID].comments.size();
  return 0;
}

unsigned CIniFile::NumKeyComments( string const keyname) const
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return 0;
  return keys[keyID].comments.size();
}

bool CIniFile::KeyComment( unsigned const keyID, string const comment)
{
  if ( keyID < keys.size()) {
    keys[keyID].comments.resize( keys[keyID].comments.size() + 1, comment);
    return true;
  }
  return false;
}

bool CIniFile::KeyComment( string const keyname, string const comment)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return false;
  return KeyComment( unsigned(keyID), comment);
}

string CIniFile::KeyComment( unsigned const keyID, unsigned const commentID) const
{
  if ( keyID < keys.size() && commentID < keys[keyID].comments.size())
    return keys[keyID].comments[commentID];
  return "";
}

string CIniFile::KeyComment( string const keyname, unsigned const commentID) const
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return "";
  return KeyComment( unsigned(keyID), commentID);
}

bool CIniFile::DeleteKeyComment( unsigned const keyID, unsigned const commentID)
{
  if ( keyID < keys.size() && commentID < keys[keyID].comments.size()) {
    vector<string>::iterator cpos = keys[keyID].comments.begin() + commentID;
    keys[keyID].comments.erase( cpos, cpos + 1);
    return true;
  }
  return false;
}

bool CIniFile::DeleteKeyComment( string const keyname, unsigned const commentID)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return false;
  return DeleteKeyComment( unsigned(keyID), commentID);
}

bool CIniFile::DeleteKeyComments( unsigned const keyID)
{
  if ( keyID < keys.size()) {
    keys[keyID].comments.clear();
    return true;
  }
  return false;
}

bool CIniFile::DeleteKeyComments( string const keyname)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return false;
  return DeleteKeyComments( unsigned(keyID));
}

string CIniFile::CheckCase( string s) const
{
  if ( caseInsensitive)
    for ( string::size_type i = 0; i < s.length(); ++i)
      s[i] = tolower(s[i]);
  return s;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美欧美欧美欧美首页| 欧美无砖砖区免费| 精品一区二区三区免费观看 | 精品一区二区在线免费观看| 亚洲一二三级电影| 亚洲福利一区二区| 亚洲成人动漫精品| 日韩av电影一区| 另类小说视频一区二区| 韩国理伦片一区二区三区在线播放| 日本美女一区二区| 精品一区二区在线播放| 国产精品资源网| 成人免费高清视频在线观看| 成人国产精品免费观看| 在线欧美一区二区| 欧美一区永久视频免费观看| 精品国产乱码久久久久久浪潮| 久久精品男人的天堂| 亚洲人成人一区二区在线观看 | 91精选在线观看| 欧美成人精品3d动漫h| 久久久久久**毛片大全| 国产精品剧情在线亚洲| 亚洲va天堂va国产va久| 国精产品一区一区三区mba桃花 | 一区二区三区四区乱视频| 亚洲不卡av一区二区三区| 九一久久久久久| 91女神在线视频| 欧美一区二区免费视频| 国产精品久久免费看| 亚洲成人av一区| 国产精品一级片| 色狠狠一区二区| 久久久久久久久久久久久女国产乱| 日韩伦理免费电影| 极品少妇xxxx精品少妇| 91女人视频在线观看| 精品国产免费人成电影在线观看四季| 中文字幕制服丝袜一区二区三区 | 欧美极品aⅴ影院| 一区二区欧美在线观看| 国产精品自拍av| 6080国产精品一区二区| 亚洲欧美综合另类在线卡通| 蜜臀av一区二区在线免费观看| va亚洲va日韩不卡在线观看| 日韩欧美国产电影| 亚洲综合色在线| av网站免费线看精品| 欧美第一区第二区| 亚州成人在线电影| 色综合久久久久久久久久久| 久久综合国产精品| 蜜臀91精品一区二区三区| 欧美亚洲自拍偷拍| 亚洲欧洲三级电影| 国产成人免费网站| 亚洲精品一区二区三区影院| 天堂成人免费av电影一区| 日本高清不卡一区| 国产精品视频yy9299一区| 国产一区二区三区在线观看免费 | 亚洲成人一区二区| 在线看国产日韩| 亚洲蜜臀av乱码久久精品| 成人午夜伦理影院| 国产精品亲子伦对白| 成人涩涩免费视频| 国产精品毛片久久久久久| 懂色av一区二区三区蜜臀| 日韩精品专区在线影院观看 | 26uuu亚洲综合色| 久久精品国产99| 欧美精品一区二区三区久久久 | 最新国产成人在线观看| 波多野结衣一区二区三区| 欧美韩日一区二区三区四区| 国产ts人妖一区二区| 国产精品久久久久久亚洲毛片| 国产精品一区在线观看你懂的| 26uuu国产电影一区二区| 国产伦精品一区二区三区免费迷| 久久视频一区二区| 国产高清久久久| 国产精品短视频| 色婷婷精品久久二区二区蜜臀av | 中文字幕av不卡| av电影一区二区| 夜夜爽夜夜爽精品视频| 欧美美女喷水视频| 激情丁香综合五月| 国产精品每日更新| 欧美日韩激情一区二区三区| 青青草成人在线观看| 国产亚洲一区二区三区四区| 99久久综合精品| 亚洲成a人在线观看| 精品欧美一区二区在线观看| 成人一区二区三区视频| 亚洲国产精品自拍| 久久久久久久国产精品影院| 99久久精品情趣| 丝袜亚洲另类欧美综合| 国产亚洲精品资源在线26u| 91免费在线播放| 青青青爽久久午夜综合久久午夜| 国产日韩欧美一区二区三区乱码| 色综合 综合色| 激情丁香综合五月| 亚洲一区二三区| 欧美草草影院在线视频| 91美女片黄在线| 久久国产三级精品| 亚洲人xxxx| 精品国产免费视频| 欧美色网站导航| 成人a免费在线看| 久久成人av少妇免费| 亚洲品质自拍视频| 久久精品一区八戒影视| 91精品国产综合久久小美女| av在线一区二区三区| 精品一区二区三区在线播放视频 | 欧美一区二区三区爱爱| 99久久伊人网影院| 国产一区在线精品| 日韩成人午夜电影| 亚洲一区二区成人在线观看| 中文字幕在线观看一区| 国产亚洲一区二区三区| 日韩欧美精品在线视频| 欧美日韩在线免费视频| 91视视频在线直接观看在线看网页在线看| 美女久久久精品| 五月激情综合色| 欧美性色黄大片| 日韩av电影免费观看高清完整版 | 国产欧美精品一区| 欧美videossexotv100| 欧美视频完全免费看| 91小视频在线| 成人av一区二区三区| 国产精品亚洲人在线观看| 精品一区二区三区免费毛片爱 | 久久久久99精品国产片| 欧美成人bangbros| 精品免费日韩av| 欧美一级二级在线观看| 欧美日韩精品免费观看视频| 欧美亚洲一区三区| 在线亚洲人成电影网站色www| 91理论电影在线观看| 色一情一伦一子一伦一区| 91原创在线视频| 99视频精品在线| 在线这里只有精品| 欧美特级限制片免费在线观看| 91国产免费看| 欧美三区免费完整视频在线观看| 欧美亚洲综合在线| 欧美另类z0zxhd电影| 3d成人h动漫网站入口| 欧美大片在线观看一区| 国产欧美一区二区三区沐欲| 亚洲国产成人一区二区三区| 亚洲欧美一区二区视频| 亚洲与欧洲av电影| 奇米一区二区三区av| 国产麻豆精品95视频| 成人美女在线视频| 欧美视频在线观看一区二区| 欧美一区二区久久久| 国产嫩草影院久久久久| 一区二区三区美女视频| 日韩**一区毛片| 国产精一区二区三区| av激情亚洲男人天堂| 69p69国产精品| 国产精品国产三级国产aⅴ原创| 亚洲卡通动漫在线| 麻豆国产精品官网| 99久久精品一区二区| 欧美一区二区三区四区视频| 久久九九99视频| 亚洲午夜久久久久久久久久久| 免费精品视频最新在线| 成人一区二区三区视频在线观看 | 91官网在线免费观看| 欧美一区二区三区四区视频| 久久久91精品国产一区二区精品| 亚洲精品国久久99热| 国产一区二三区好的| 欧美男生操女生| 亚洲视频一区在线| 国产一区二区久久| 在线成人免费观看| 亚洲日本在线观看| 国产成人在线看|