本文整理汇总了C++中CONFIG类的典型用法代码示例。如果您正苦于以下问题:C++ CONFIG类的具体用法?C++ CONFIG怎么用?C++ CONFIG使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CONFIG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Delete
/*
Delete()
Elimina della lista il valore relativo alla coppia sezione/chiave.
Non elimina fisicamente l'elemento ma si limita a marcarlo in modo tale che quando la lista
viene salvata sul registro si possano individuare le chiavi da eliminare fisicamente.
LPCSTR lpcszSectionName nome sezione
LPCSTR lpcszKeyName nome chiave
*/
BOOL CConfig::Delete(LPCSTR lpcszSectionName,LPCSTR lpcszKeyName)
{
BOOL bDeleted = FALSE;
CONFIG* c;
ITERATOR iter;
// scorre la lista cercando l'entrata relativa alla coppia sezione/chiave
if((iter = m_plistConfig->First())!=(ITERATOR)NULL)
{
do
{
c = (CONFIG*)iter->data;
if(c)
if(strcmp(lpcszSectionName,c->GetSection())==0)
{
if(strcmp(lpcszKeyName,c->GetName())==0)
{
// marca l'elemento per l'eliminazione
c->SetType(NULL_TYPE);
SetModified(TRUE);
bDeleted = TRUE;
break;
}
}
iter = m_plistConfig->Next(iter);
} while(iter!=(ITERATOR)NULL);
}
return(bDeleted);
}
示例2: Load
void SETTINGS::Load(const std::string & settingsfile, std::ostream & error)
{
CONFIG config;
if (!config.Load(settingsfile))
{
error << "Failed to load " << settingsfile << std::endl;
}
Serialize(false, config);
}
示例3: parse_config
int
parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type)
{
int ok;
CONFIG *config = new_config_parser();
config->init(cf, scan_error, err_type, (void *)&res_all, res_all_size,
r_first, r_last, resources, res_head);
ok = config->parse_config();
free(config);
return ok;
}
示例4: Save
void SETTINGS::Save(const std::string & settingsfile, std::ostream & error)
{
CONFIG config;
if (!config.Load(settingsfile))
{
error << "Failed to load " << settingsfile << std::endl;
}
Serialize(true, config);
if (!config.Write())
{
error << "Failed to save " << settingsfile << std::endl;
}
}
示例5: read_config_file
int read_config_file(bool init) {
FILE* f;
if (!init) {
msg_printf(NULL, MSG_INFO, "Re-reading cc_config.xml");
config.clear();
}
f = boinc_fopen(CONFIG_FILE, "r");
if (!f) return ERR_FOPEN;
config.parse(f);
fclose(f);
return 0;
}
示例6: save
static void save(const tomo::Color3& _c, const tbd::ConfigPath& _path, CONFIG& _config)
{
std::ostringstream _os;
_os << _c.r() << " " << _c.g() << " ";
_os << _c.b() << " ";
_config.put(_path,_os.str());
}
示例7: Param
static void Param(
CONFIG & config,
bool write,
CONFIG::iterator & section,
const std::string & name,
T & value)
{
if (write)
{
config.SetParam(section, name, value);
}
else
{
config.GetParam(section, name, value);
}
}
示例8: Serialize
void SETTINGS::Get(std::map<std::string, std::string> & options)
{
CONFIG tempconfig;
Serialize(true, tempconfig);
for (CONFIG::const_iterator ic = tempconfig.begin(); ic != tempconfig.end(); ++ic)
{
std::string section = ic->first;
for (CONFIG::SECTION::const_iterator is = ic->second.begin(); is != ic->second.end(); ++is)
{
if (section.length() > 0)
options[section + "." + is->first] = is->second;
else
options[is->first] = is->second;
}
}
}
示例9: Insert
/*
Insert()
Inserisce nella lista il valore (numerico) per la sezione/chiave specificati.
LPCSTR lpcszSectionName nome sezione
LPCSTR lpcszKeyName nome chiave
LPCSTR lpcszKeyValue valore chiave (numero)
*/
BOOL CConfig::Insert(LPCSTR lpcszSectionName,LPCSTR lpcszKeyName,DWORD dwKeyValue)
{
BOOL bInserted = FALSE;
if(m_plistConfig)
{
CONFIG* c = (CONFIG*)m_plistConfig->Add();
if(c)
{
c->Init(lpcszSectionName,lpcszKeyName,dwKeyValue);
SetModified(TRUE);
bInserted = TRUE;
}
}
return(bInserted);
}
示例10: Set
void SETTINGS::Set(const std::map<std::string, std::string> & options)
{
CONFIG tempconfig;
for (std::map<std::string, std::string>::const_iterator i = options.begin(); i != options.end(); ++i)
{
std::string section;
std::string param = i->first;
size_t n = param.find(".");
if (n < param.length())
{
section = param.substr(0, n);
param.erase(0, n + 1);
}
tempconfig.SetParam(section, param, i->second);
}
Serialize(false, tempconfig);
}
示例11: SaveSection
/*
SaveSection()
Salva nel registro i valori presenti nella lista relativi alla sezione.
LPCSTR lpcszRootKey nome della chiave base
LPCSTR lpcszSectionKey nome della sezione
*/
void CConfig::SaveSection(LPCSTR lpcszRootKey,LPCSTR lpcszSectionKey)
{
CONFIG* c;
ITERATOR iter;
LONG lRet;
char szKey[REGKEY_MAX_KEY_VALUE+1];
if(m_pRegistry)
{
m_pRegistry->Attach(HKEY_CURRENT_USER);
// scorre la lista aggiornando la sezione
if((iter = m_plistConfig->First())!=(ITERATOR)NULL)
{
do
{
c = (CONFIG*)iter->data;
if(c)
// non inserisce nel registro le chiavi eliminate
if(c->GetType()!=NULL_TYPE && strcmp(c->GetSection(),lpcszSectionKey)==0)
{
// salva la chiave nel registro
_snprintf(szKey,sizeof(szKey)-1,DEFAULT_REG_KEY"\\%s\\%s",lpcszRootKey,c->GetSection());
if((lRet = m_pRegistry->Open(HKEY_CURRENT_USER,szKey))!=ERROR_SUCCESS)
lRet = m_pRegistry->Create(HKEY_CURRENT_USER,szKey);
if(lRet==ERROR_SUCCESS)
{
if(c->GetType()==LPSTR_TYPE)
m_pRegistry->SetValue(c->GetValue((LPCSTR)NULL),c->GetName());
else if(c->GetType()==DWORD_TYPE)
m_pRegistry->SetValue(c->GetValue((DWORD)0L),c->GetName());
m_pRegistry->Close();
}
}
iter = m_plistConfig->Next(iter);
} while(iter!=(ITERATOR)NULL);
}
m_pRegistry->Detach();
}
}
示例12:
int algorithms::Planner<IROBOT>::find_next_owner(int cell, const CONFIG& bnd_cfg ) const
{
for (int index : get_cell(cell).get_boundaries()) {
int neighbor = get_boundary(index).otherside(cell);
if(get_cell(neighbor).on_boundary(bnd_cfg.vector(), 1e-15))
return neighbor;
}
return NOT_FOUND;
}
示例13: Export
/*
Export()
Esporta la configurazione corrente nel file specificato.
*/
BOOL CConfig::Export(LPCSTR /*lpcszRootKey*/,LPCSTR lpcszFileName)
{
BOOL bSaved = FALSE;
FILE* fp;
if((fp = fopen(lpcszFileName,"w"))!=(FILE*)NULL)
{
CONFIG* c;
ITERATOR iter;
fprintf(fp,"[%s]\n","Configuration File");
// salva nel file le chiavi presenti nella lista
if((iter = m_plistConfig->First())!=(ITERATOR)NULL)
{
do
{
c = (CONFIG*)iter->data;
if(c)
// non inserisce le chiavi eliminate
if(c->GetType()!=NULL_TYPE)
{
if(c->GetType()==LPSTR_TYPE)
fprintf(fp,"%s;%s;%s;%s\n",c->GetSection(),c->GetName(),c->GetValue((LPCSTR)NULL),"SZ");
else if(c->GetType()==DWORD_TYPE)
fprintf(fp,"%s;%s;%ld;%s\n",c->GetSection(),c->GetName(),c->GetValue((DWORD)0L),"DW");
}
iter = m_plistConfig->Next(iter);
} while(iter!=(ITERATOR)NULL);
}
fclose(fp);
bSaved = TRUE;
}
return(bSaved);
}
示例14: DeleteAll
/*
DeleteAll()
Elimina della lista tutti i valori, rimuovendoli anche dal registro.
*/
BOOL CConfig::DeleteAll(LPCSTR lpcszRootKey)
{
BOOL bDeleted = TRUE;
CONFIG* c;
ITERATOR iter;
char szKey[REGKEY_MAX_KEY_VALUE+1];
if(m_pRegistry)
{
m_pRegistry->Attach(HKEY_CURRENT_USER);
if((iter = m_plistConfig->First())!=(ITERATOR)NULL)
{
do
{
c = (CONFIG*)iter->data;
if(c)
{
_snprintf(szKey,sizeof(szKey)-1,DEFAULT_REG_KEY"\\%s\\%s",lpcszRootKey,c->GetSection());
if(m_pRegistry->Open(HKEY_CURRENT_USER,szKey)==ERROR_SUCCESS)
{
m_pRegistry->DeleteValue(c->GetName());
m_pRegistry->Close();
}
}
iter = m_plistConfig->Next(iter);
} while(iter!=(ITERATOR)NULL);
}
m_pRegistry->Detach();
SetModified(TRUE);
}
m_plistConfig->RemoveAll();
return(bDeleted);
}
示例15: Convolution
unsigned Convolution(CONFIG &config)
{
time_t time1, time2;
time(&time1);
int dim;
cout << "Add " << config.atoms_box << " atoms to the box" << endl;
for(int i = 0; i < config.atoms_box; i++) // check all atoms of this grain
{
for(dim=0; dim < 3; dim++)
{
if (config.atom_box[i].r(dim) > config.shift(dim)) config.atom_box[i].r(dim) -= config.l(dim);
else
if (config.atom_box[i].r(dim) < -config.shift(dim)) config.atom_box[i].r(dim) += config.l(dim);
}
}
time(&time2);
if (config.time) cout << "Done in " << time2-time1 << " s." << endl;
return 0;
}