本文整理汇总了C++中CONFIG::GetSection方法的典型用法代码示例。如果您正苦于以下问题:C++ CONFIG::GetSection方法的具体用法?C++ CONFIG::GetSection怎么用?C++ CONFIG::GetSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CONFIG
的用法示例。
在下文中一共展示了CONFIG::GetSection方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registro
/*
DeleteSection()
Elimina dal registro (e dalla lista) i valori presenti nella lista relativi alla sezione.
LPCSTR lpcszRootKey nome della chiave base
LPCSTR lpcszSectionKey nome della sezione
BOOL bDeleteFromRegistry flag per eliminazione delle chiavi dal registro
*/
void CConfig::DeleteSection(LPCSTR lpcszRootKey,LPCSTR lpcszSectionKey,BOOL bDeleteFromRegistry/*=FALSE*/)
{
CONFIG* c;
ITERATOR iter;
char szKey[REGKEY_MAX_KEY_VALUE+1];
if(m_pRegistry)
{
m_pRegistry->Attach(HKEY_CURRENT_USER);
// elimina (dalla lista e dal registro) le chiavi relative alla sezione
if((iter = m_plistConfig->First())!=(ITERATOR)NULL)
{
do
{
c = (CONFIG*)iter->data;
if(c)
// chiave da eliminare
if(c->GetType()!=NULL_TYPE && strcmp(c->GetSection(),lpcszSectionKey)==0)
{
// elimina la chiave dal registro
if(bDeleteFromRegistry)
{
_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();
}
}
// elimina la chiave dalla lista
//m_plistConfig->Remove(iter);
// eliminando l'elemento della lista (iter) e non la chiave (marcandola come cancellata) i salvataggi successivi
// non possono eliminare dal registro le serie di chiavi come Key[0]...Key[n]
//Delete(c->GetSection(),c->GetName());
c->SetType(NULL_TYPE);
SetModified(TRUE);
}
iter = m_plistConfig->Next(iter);
} while(iter!=(ITERATOR)NULL);
}
m_pRegistry->Detach();
SetModified(TRUE);
}
}
示例2: 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);
}
示例3: 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();
}
}
示例4: if
/*
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);
}
示例5: valore
/*
String()
Restituisce o aggiorna il valore (stringa) associato alla sezione/chiave a seconda del parametro
associato al valore (NULL/-1 recupera, in caso contrario aggiorna).
LPCSTR lpcszSectionName nome sezione
LPCSTR lpcszKeyName nome chiave
LPCSTR lpcszKeyValue valore chiave (stringa)
*/
LPCSTR CConfig::String(LPCSTR lpcszSectionName,LPCSTR lpcszKeyName,LPCSTR lpcszKeyValue/*=NULL*/)
{
static char* p;
CONFIG* c;
ITERATOR iter;
p = "";
// 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)
{
// salta i valori marcati per l'eliminazione (NULL_TYPE)
if(c->GetType()!=NULL_TYPE)
{
if(lpcszKeyValue!=NULL)
{
// aggiorna il valore
c->SetValue(lpcszKeyValue);
p = (char*)c->GetValue(p);
break;
}
else
{
// ricava il valore
p = (char*)c->GetValue(p);
if(!*p)
p = "";
break;
}
}
}
}
iter = m_plistConfig->Next(iter);
} while(iter!=(ITERATOR)NULL);
}
return(p);
}
示例6: 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);
}
示例7: RegisterActions
void GUICONTROL::RegisterActions(
const std::map<std::string, Slot1<const std::string &>*> & vactionmap,
const std::map<std::string, Slot0*> & actionmap,
const std::string & name,
const CONFIG & cfg)
{
CONFIG::const_iterator section;
cfg.GetSection(name, section);
std::string actionstr;
if (cfg.GetParam(section, "onselectx", actionstr))
SetActions(vactionmap, actionstr, onselectx);
if (cfg.GetParam(section, "onselecty", actionstr))
SetActions(vactionmap, actionstr, onselecty);
if (cfg.GetParam(section, "onselect", actionstr))
SetActions(actionmap, actionstr, onselect);
if (cfg.GetParam(section, "onfocus", actionstr))
SetActions(actionmap, actionstr, onfocus);
if (cfg.GetParam(section, "onblur", actionstr))
SetActions(actionmap, actionstr, onblur);
if (cfg.GetParam(section, "onmoveup", actionstr))
SetActions(actionmap, actionstr, onmoveup);
if (cfg.GetParam(section, "onmovedown", actionstr))
SetActions(actionmap, actionstr, onmovedown);
if (cfg.GetParam(section, "onmoveleft", actionstr))
SetActions(actionmap, actionstr, onmoveleft);
if (cfg.GetParam(section, "onmoveright", actionstr))
SetActions(actionmap, actionstr, onmoveright);
}
示例8: Serialize
void SETTINGS::Serialize(bool write, CONFIG & config)
{
CONFIG::iterator section;
config.GetSection("game", section);
Param(config, write, section, "vehicle_damage", vehicle_damage);
Param(config, write, section, "ai_difficulty", ai_difficulty);
Param(config, write, section, "track", track);
Param(config, write, section, "antilock", abs);
Param(config, write, section, "traction_control", tcs);
Param(config, write, section, "record", recordreplay);
Param(config, write, section, "selected_replay", selected_replay);
Param(config, write, section, "player", player);
Param(config, write, section, "player_paint", player_paint);
Param(config, write, section, "player_color", player_color);
Param(config, write, section, "opponent", opponent);
Param(config, write, section, "opponent_paint", opponent_paint);
Param(config, write, section, "opponent_color", opponent_color);
Param(config, write, section, "reverse", trackreverse);
Param(config, write, section, "track_dynamic", trackdynamic);
Param(config, write, section, "batch_geometry", batch_geometry);
Param(config, write, section, "number_of_laps", number_of_laps);
Param(config, write, section, "camera_mode", camera_mode);
config.GetSection("display", section);
if (!res_override)
{
Param(config, write, section, "width", resolution_x);
Param(config, write, section, "height", resolution_y);
}
Param(config, write, section, "depth", bpp);
Param(config, write, section, "zdepth", depthbpp);
Param(config, write, section, "fullscreen", fullscreen);
Param(config, write, section, "shaders", shaders);
Param(config, write, section, "skin", skin);
Param(config, write, section, "language", language);
Param(config, write, section, "show_fps", show_fps);
Param(config, write, section, "anisotropic", anisotropic);
Param(config, write, section, "antialiasing", antialiasing);
Param(config, write, section, "trackmap", trackmap);
Param(config, write, section, "show_hud", show_hud);
Param(config, write, section, "FOV", FOV);
Param(config, write, section, "mph", mph);
Param(config, write, section, "view_distance", view_distance);
Param(config, write, section, "racingline", racingline);
Param(config, write, section, "texture_size", texturesize);
Param(config, write, section, "shadows", shadows);
Param(config, write, section, "shadow_distance", shadow_distance);
Param(config, write, section, "shadow_quality", shadow_quality);
Param(config, write, section, "reflections", reflections);
Param(config, write, section, "input_graph", input_graph);
Param(config, write, section, "lighting", lighting);
Param(config, write, section, "bloom", bloom);
Param(config, write, section, "normalmaps", normalmaps);
Param(config, write, section, "camerabounce", camerabounce);
Param(config, write, section, "contrast", contrast);
config.GetSection("sound", section);
Param(config, write, section, "volume", mastervolume);
config.GetSection("joystick", section);
Param(config, write, section, "type", joytype);
Param(config, write, section, "two_hundred", joy200);
joy200 = false;
Param(config, write, section, "calibrated", joystick_calibrated);
Param(config, write, section, "ff_device", ff_device);
Param(config, write, section, "ff_gain", ff_gain);
Param(config, write, section, "ff_invert", ff_invert);
Param(config, write, section, "hgateshifter", hgateshifter);
config.GetSection("control", section);
Param(config, write, section, "speed_sens_steering", speed_sensitivity);
Param(config, write, section, "autoclutch", autoclutch);
Param(config, write, section, "autotrans", autoshift);
Param(config, write, section, "mousegrab", mousegrab);
Param(config, write, section, "button_ramp", button_ramp);
}
示例9: Save
/*
Save()
Salva nel registro i valori presenti nella lista.
LPCSTR lpcszRootKey nome della chiave base
*/
void CConfig::Save(LPCSTR lpcszRootKey)
{
CONFIG* c;
ITERATOR iter;
LONG lRet;
char szKey[REGKEY_MAX_KEY_VALUE+1];
memset(szKey,'\0',sizeof(szKey));
if(m_pRegistry)
{
m_pRegistry->Attach(HKEY_CURRENT_USER);
// elimina (dalla lista e dal registro) le chiavi marcate per la cancellazione
if((iter = m_plistConfig->First())!=(ITERATOR)NULL)
{
do
{
c = (CONFIG*)iter->data;
if(c)
// chiave da eliminare
if(c->GetType()==NULL_TYPE)
{
// elimina la chiave dal registro
_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();
}
// elimina la chiave dalla lista
m_plistConfig->Remove(iter);
}
iter = m_plistConfig->Next(iter);
} while(iter!=(ITERATOR)NULL);
}
// salva nel registro le chiavi presenti nella lista
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)
{
_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();
SetModified(FALSE);
}
}
示例10: Save
void CARCONTROLMAP_LOCAL::Save(CONFIG & controls_config, std::ostream & info_output, std::ostream & error_output)
{
int id = 0;
for (std::map <CARINPUT::CARINPUT, std::vector <CONTROL> >::iterator n = controls.begin(); n != controls.end(); ++n)
{
for (std::vector <CONTROL>::iterator i = n->second.begin(); i != n->second.end(); ++i)
{
std::string ctrl_name = "INVALID";
CARINPUT::CARINPUT inputid = n->first;
for (std::map <std::string, CARINPUT::CARINPUT>::const_iterator s = carinput_stringmap.begin(); s != carinput_stringmap.end(); ++s)
{
if (s->second == inputid) ctrl_name = s->first;
}
std::stringstream ss;
ss << "control mapping " << std::setfill('0') << std::setw(2) << id;
CONFIG::iterator section;
controls_config.GetSection(ss.str(), section);
controls_config.SetParam(section, "name", ctrl_name);
CONTROL & curctrl = *i;
if (curctrl.type == CONTROL::JOY)
{
controls_config.SetParam(section, "type", "joy");
controls_config.SetParam(section, "joy_index", curctrl.joynum);
if (curctrl.joytype == CONTROL::JOYAXIS)
{
controls_config.SetParam(section, "joy_type", "axis");
controls_config.SetParam(section, "joy_axis", curctrl.joyaxis );
switch (curctrl.joyaxistype) {
case CONTROL::POSITIVE:
controls_config.SetParam(section, "joy_axis_type", "positive");
break;
case CONTROL::NEGATIVE:
controls_config.SetParam(section, "joy_axis_type", "negative");
break;
case CONTROL::BOTH:
controls_config.SetParam(section, "joy_axis_type", "both");
break;
}
controls_config.SetParam(section, "deadzone", curctrl.deadzone);
controls_config.SetParam(section, "exponent", curctrl.exponent);
controls_config.SetParam(section, "gain", curctrl.gain);
}
else if (curctrl.joytype == CONTROL::JOYBUTTON)
{
controls_config.SetParam(section, "joy_type", "button");
controls_config.SetParam(section, "joy_button", curctrl.joybutton);
controls_config.SetParam(section, "once", curctrl.onetime);
controls_config.SetParam(section, "down", curctrl.joypushdown);
}
}
else if (curctrl.type == CONTROL::KEY)
{
controls_config.SetParam(section, "type", "key");
std::string keyname = "UNKNOWN";
for (std::map <std::string, int>::iterator k = legacy_keycodes.begin(); k != legacy_keycodes.end(); k++)
if (k->second == curctrl.keycode)
keyname = k->first;
controls_config.SetParam(section, "key", keyname);
controls_config.SetParam(section, "keycode", curctrl.keycode);
controls_config.SetParam(section, "once", curctrl.onetime);
controls_config.SetParam(section, "down", curctrl.keypushdown);
}
else if (curctrl.type == CONTROL::MOUSE)
{
controls_config.SetParam(section, "type", "mouse");
if (curctrl.mousetype == CONTROL::MOUSEBUTTON)
{
controls_config.SetParam(section, "mouse_type", "button");
controls_config.SetParam(section, "mouse_button", curctrl.mbutton );
controls_config.SetParam(section, "once", curctrl.onetime );
controls_config.SetParam(section, "down", curctrl.mouse_push_down );
}
else if (curctrl.mousetype == CONTROL::MOUSEMOTION)
{
std::string direction = "invalid";
CONTROL::MOUSEDIRECTION mdir = curctrl.mdir;
if ( mdir == CONTROL::UP )
{
direction = "up";
}
else if ( mdir == CONTROL::DOWN )
{
direction = "down";
}
else if ( mdir == CONTROL::LEFT )
{
direction = "left";
}
else if ( mdir == CONTROL::RIGHT )
{
direction = "right";
}
controls_config.SetParam(section, "mouse_type", "motion");
controls_config.SetParam(section, "mouse_motion", direction);
//.........这里部分代码省略.........
示例11: Save
void CARCONTROLMAP_LOCAL::Save(CONFIG & controls_config)
{
int id = 0;
for (size_t n = 0; n < controls.size(); ++n)
{
std::string ctrl_name = GetStringFromInput(CARINPUT::CARINPUT(n));
if (ctrl_name.empty())
continue;
for (size_t i = 0; i < controls[n].size(); ++i)
{
std::stringstream ss;
ss << "control mapping " << std::setfill('0') << std::setw(2) << id;
CONFIG::iterator section;
controls_config.GetSection(ss.str(), section);
controls_config.SetParam(section, "name", ctrl_name);
CONTROL & curctrl = controls[n][i];
if (curctrl.type == CONTROL::JOY)
{
controls_config.SetParam(section, "type", "joy");
controls_config.SetParam(section, "joy_index", curctrl.joynum);
if (curctrl.joytype == CONTROL::JOYAXIS)
{
controls_config.SetParam(section, "joy_type", "axis");
controls_config.SetParam(section, "joy_axis", curctrl.joyaxis );
switch (curctrl.joyaxistype) {
case CONTROL::POSITIVE:
controls_config.SetParam(section, "joy_axis_type", "positive");
break;
case CONTROL::NEGATIVE:
controls_config.SetParam(section, "joy_axis_type", "negative");
break;
}
controls_config.SetParam(section, "deadzone", curctrl.deadzone);
controls_config.SetParam(section, "exponent", curctrl.exponent);
controls_config.SetParam(section, "gain", curctrl.gain);
}
else if (curctrl.joytype == CONTROL::JOYBUTTON)
{
controls_config.SetParam(section, "joy_type", "button");
controls_config.SetParam(section, "joy_button", curctrl.keycode);
controls_config.SetParam(section, "once", curctrl.onetime);
controls_config.SetParam(section, "down", curctrl.pushdown);
}
}
else if (curctrl.type == CONTROL::KEY)
{
controls_config.SetParam(section, "type", "key");
std::string keyname = GetStringFromKeycode(curctrl.keycode);
controls_config.SetParam(section, "key", keyname);
controls_config.SetParam(section, "keycode", curctrl.keycode);
controls_config.SetParam(section, "once", curctrl.onetime);
controls_config.SetParam(section, "down", curctrl.pushdown);
}
else if (curctrl.type == CONTROL::MOUSE)
{
controls_config.SetParam(section, "type", "mouse");
if (curctrl.mousetype == CONTROL::MOUSEBUTTON)
{
controls_config.SetParam(section, "mouse_type", "button");
controls_config.SetParam(section, "mouse_button", curctrl.keycode );
controls_config.SetParam(section, "once", curctrl.onetime );
controls_config.SetParam(section, "down", curctrl.pushdown );
}
else if (curctrl.mousetype == CONTROL::MOUSEMOTION)
{
std::string direction = "invalid";
CONTROL::MOUSEDIRECTION mdir = curctrl.mdir;
if ( mdir == CONTROL::UP )
{
direction = "up";
}
else if ( mdir == CONTROL::DOWN )
{
direction = "down";
}
else if ( mdir == CONTROL::LEFT )
{
direction = "left";
}
else if ( mdir == CONTROL::RIGHT )
{
direction = "right";
}
controls_config.SetParam(section, "mouse_type", "motion");
controls_config.SetParam(section, "mouse_motion", direction);
controls_config.SetParam(section, "deadzone", curctrl.deadzone);
controls_config.SetParam(section, "exponent", curctrl.exponent);
controls_config.SetParam(section, "gain", curctrl.gain);
}
}
id++;
}
}
//.........这里部分代码省略.........