本文整理汇总了C++中cconfigfile::CVar::size方法的典型用法代码示例。如果您正苦于以下问题:C++ CVar::size方法的具体用法?C++ CVar::size怎么用?C++ CVar::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cconfigfile::CVar
的用法示例。
在下文中一共展示了CVar::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void CConfiguration::init()
{
// verify data
nlassert(!m_ConfigCallbacks.size());
// load config
m_ConfigFile.load(NLQT_CONFIG_FILE);
// log config
CConfiguration::setAndCallback("NegFiltersDebug", CConfigCallback(this, &CConfiguration::cfcbLogFilter));
CConfiguration::setAndCallback("NegFiltersInfo", CConfigCallback(this, &CConfiguration::cfcbLogFilter));
CConfiguration::setAndCallback("NegFiltersWarning", CConfigCallback(this, &CConfiguration::cfcbLogFilter));
CConfiguration::setAndCallback("NegFiltersAssert", CConfigCallback(this, &CConfiguration::cfcbLogFilter));
CConfiguration::setAndCallback("NegFiltersError", CConfigCallback(this, &CConfiguration::cfcbLogFilter));
// set the search paths (kinda important)
CConfigFile::CVar *var;
var = m_ConfigFile.getVarPtr("SearchPaths");
uint varsize = var->size();
for (uint i = 0; i < varsize; ++i)
CPath::addSearchPath(var->asString(i), true, false);
var = m_ConfigFile.getVarPtr("RemapExtensions");
varsize = var->size();
for (uint i = 0; i < varsize; i += 2)
CPath::remapExtension(var->asString(i), var->asString(i + 1), true);
}
示例2: getValue
CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue)
{
if (var.size() >= 3)
{
if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values");
return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255);
}
nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A);
return defaultValue;
}
示例3: compile
// compile the source files to generate new object files
void CAIManager::compile()
{
// get the file names of input and output files
std::string srcFile=CAIFiles::fullSrcFileName(id());
std::string objFile=CAIFiles::fullObjFileName(id());
// make sure this file isn't in the ignore list
CConfigFile::CVar *varPtr;
varPtr=IService::getInstance()->ConfigFile.getVarPtr(std::string("IgnorePrimitives"));
if (varPtr==NULL)
{
nlwarning("Cannot compile file '%s' as IgnorePrimitives variable not found in .cfg file: Please add 'IgnorePrimitives={\"\"};' and try again",CAIFiles::fullSrcFileName(id()).c_str());
return;
}
for (uint i=0;i<varPtr->size();++i)
if (CAIFiles::srcName(id())==CFile::getFilenameWithoutExtension(varPtr->asString(i)))
{
nlinfo("Skipping file in .cfg ignoreList: %s",CAIFiles::fullSrcFileName(id()).c_str());
return;
}
// compile the input file
nlinfo("Compile %s => %s",srcFile.c_str(),objFile.c_str());
CAIDSActions::CurrentManager=id();
AI_SHARE::parsePrimFile(srcFile.c_str());
// make sure this file isn't in the ignore list (if the compiler found nothing interesting it will have been added)
varPtr=IService::getInstance()->ConfigFile.getVarPtr(std::string("IgnorePrimitives"));
for (uint i=0;i<varPtr->size();++i)
if (CAIFiles::srcName(id())==CFile::getFilenameWithoutExtension(varPtr->asString(i)))
{
nlinfo("- Skipping file as it has just been added to .cfg ignoreList: %s",CAIFiles::fullSrcFileName(id()).c_str());
return;
}
// write the output file
CAIFiles::writeObjFile(id());
// write the binary output file (for debugging only)
NLMISC::COFile file;
if (file.open(objFile+"_out"))
{
std::string s;
MgrDfnRootNode.serialToString(s);
file.serial(s);
file.close();
}
else
nlwarning("CAIManager::compile(): Failed to open the output file: %s",(objFile+"_out").c_str());
}
示例4: cbUpdateRadar
void cbUpdateRadar (CConfigFile::CVar &var)
{
if (var.Name == "RadarPosX") RadarPosX = var.asFloat ();
else if (var.Name == "RadarPosY") RadarPosY = var.asFloat ();
else if (var.Name == "RadarWidth") RadarWidth = var.asFloat ();
else if (var.Name == "RadarHeight") RadarHeight = var.asFloat ();
else if (var.Name == "RadarBackColor") RadarBackColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
else if (var.Name == "RadarFrontColor") RadarFrontColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
else if (var.Name == "RadarSelfColor") RadarSelfColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
else if (var.Name == "RadarOtherColor") RadarOtherColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
else if (var.Name == "RadarDynamicColor") RadarDynamicColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
else if (var.Name == "RadarPlaceColor") RadarPlaceColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
else if (var.Name == "RadarEntitySize") RadarEntitySize = var.asFloat ();
else if (var.Name == "RadarState") RadarState = var.asInt ();
else if (var.Name == "RadarDistance") RadarDistance = var.asInt ();
else if (var.Name == "RadarMinDistance") RadarMinDistance = var.asInt ();
else if (var.Name == "RadarMaxDistance") RadarMaxDistance = var.asInt ();
else if (var.Name == "URLSelectionTimeout") SelectionTimeOut = var.asInt ();
else if (var.Name == "RadarParticularPlaces")
{
RadarParticularPlaces.clear ();
for (sint i = 0; i < var.size(); i += 4)
{
RadarParticularPlaces.push_back (RadarParticularPlace(var.asFloat(i), var.asFloat(i+1), var.asString(i+2), var.asString(i+3)));
}
}
else if (var.Name == "RadarFontSize") RadarFontSize = var.asInt ();
else if (var.Name == "RadarLittlePosX") RadarLittlePosX = var.asFloat ();
else if (var.Name == "RadarLittlePosY") RadarLittlePosY = var.asFloat ();
else if (var.Name == "RadarLittleRadius") RadarLittleRadius = var.asFloat ();
else nlwarning ("Unknown variable update %s", var.Name.c_str());
}
示例5: var12Callback
// this function will be called when the variable var12 will be modified by
// an external program
void var12Callback (CConfigFile::CVar &var)
{
stringstream str;
for (uint i = 0; i < var.size (); i++)
str << var.asInt (i) << " ";
nlinfo("%s modified, new value: %s\n", var.Name.c_str (), str.str().c_str());
}
示例6: init
bool CConfiguration::init()
{
nlassert(!ConfigFile); ConfigFile = new CConfigFile(); nlassert(ConfigFile);
ConfigFile->load(SBCLIENT_CONFIG_FILE);
// set the search paths (kinda important)
CConfigFile::CVar *var;
var = ConfigFile->getVarPtr("SearchPaths");
uint varsize = var->size();
for (uint i = 0; i < varsize; ++i)
CPath::addSearchPath(var->asString(i), true, false);
var = ConfigFile->getVarPtr("RemapExtensions");
varsize = var->size();
for (uint i = 0; i < varsize; i += 2)
CPath::remapExtension(var->asString(i), var->asString(i + 1), true);
return true;
}
示例7:
/// Set expected instances. Ex: { "TICKS", "FS", "FS", "FS" }
void setExpectedInstances( CConfigFile::CVar& var )
{
// Reset "expected" counters (but don't clear the map, keep the running instances)
CInstances::iterator ici;
for ( ici=_Instances.begin(); ici!=_Instances.end(); ++ici )
{
(*ici).second.Expected = 0;
}
// Rebuild "expected" counters
for ( uint i=0; i!=var.size(); ++i )
{
++_Instances[var.asString(i)].Expected;
}
}
示例8: generateSpellList
/** Generate list of spell
*/
static void generateSpellList(CConfigFile &cf, const std::string &sheetName)
{
CConfigFile::CVar *spellList = cf.getVarPtr("spell_list");
if (!spellList)
{
nlwarning("Can't read spell list");
return;
}
COFile f;
if (!f.open(sheetName, false, true))
{
nlwarning("Can't write %s", sheetName.c_str());
return;
}
try
{
COXml xmlStreamOut;
xmlStreamOut.init(&f);
xmlStreamOut.xmlPush("FORM");
IStream &xmlStream = xmlStreamOut;
xmlStream.xmlPush("STRUCT");
xmlStream.xmlPushBegin("ARRAY");
xmlStream.xmlSetAttrib("Name");
std::string name = "List";
xmlStream.serial(name);
xmlStream.xmlPushEnd();
for(uint k = 0; k < (uint) spellList->size(); ++k)
{
std::vector<std::string> result;
NLMISC::splitString(spellList->asString(k), "|", result);
if (result.size() < 2)
{
nlwarning("Should provide at list spell name and id");
}
xmlStream.xmlPush("STRUCT");
writeAtom(xmlStream, "ID", result[1]);
writeAtom(xmlStream, "SheetBaseName", result[0]);
xmlStream.xmlPop();
}
xmlStream.xmlPop(); // STRUCT
xmlStream.xmlPop(); // FORM
}
catch(const EStream &)
{
nlwarning("Cant write %s", sheetName.c_str());
}
}
示例9: packedFileName
// @{
// \name Overload for IPluginCallback
void CPrimitivePlugin::init(IPluginAccess *pluginAccess)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
AfxEnableControlContainer();
_PluginAccess = pluginAccess;
string packedFileName("primitive_plugin.packed_sheets");
vector<string> paths;
string sheetIdPath;
// add the search path
CConfigFile &cf = pluginAccess->getConfigFile();
CConfigFile::CVar *pv = cf.getVarPtr("PrimitivePluginPath");
if (pv)
{
for (uint i=0; i<pv->size(); ++i)
paths.push_back(pv->asString(i));
}
// add the sheetId file
pv = cf.getVarPtr("PrimitivePluginSheetId");
sheetIdPath = pv->asString();
// Init the sheet id
CPath::addSearchFile(sheetIdPath);
CSheetId::init(false);
// Read the sheets
if (NLMISC::CFile::fileExists(packedFileName))
loadForm("creature", packedFileName, _CreatureInfos, false, false);
else
{
for (uint i=0; i<paths.size(); ++i)
{
CPath::addSearchPath(paths[i], true, false);
}
// build the packed sheet
loadForm("creature", packedFileName, _CreatureInfos, true, false);
}
vector<string> classNames;
classNames.push_back("npc_bot");
_PluginAccess->registerPrimitiveDisplayer(this, classNames);
}
示例10: loadPlugins
void CWorldEditorApp::loadPlugins()
{
// 1st load the plugin configuration file
// char curDir[MAX_PATH];
// GetCurrentDirectory (MAX_PATH, curDir);
PluginConfig.load((ExePath+"/world_editor_plugin.cfg").c_str());
// enumerate the plugin variable.
CConfigFile::CVar *plugins = PluginConfig.getVarPtr("PluginsLibrary");
if (plugins != 0)
{
for (uint i=0; i<plugins->size(); ++i)
{
string libname = plugins->asString(i)+nlLibSuffix+".dll";
//vl HMODULE h = AfxLoadLibrary(libname.c_str());
NL_LIB_HANDLE h = nlLoadLibrary(libname.c_str());
if (h == NULL)
continue;
//FCreateSoundPlugin *pf = (FCreateSoundPlugin*) GetProcAddress(h, "createSoundPlugin");
//JC: switch to the generic call as soon as possible
//vl FCreatePlugin *pf = (FCreatePlugin*) GetProcAddress(h, "createPlugin");
FCreatePlugin *pf = (FCreatePlugin*) nlGetSymbolAddress(h, "createPlugin");
if (pf == NULL)
continue;
// ok, the plugin is loaded.
IPluginCallback *pcb = (IPluginCallback*) pf();
if (pcb == 0)
continue;
nlinfo("Plugins '%s' loaded", libname.c_str());
Plugins.push_back(pcb);
// init the plugin.
pcb->init(getMainFrame());
}
}
}
示例11: cfcbLogFilter
void CConfiguration::cfcbLogFilter(CConfigFile::CVar &var)
{
// from nel/net/service.cpp
CLog *log = NULL;
if (var.Name == "NegFiltersDebug") log = DebugLog;
else if (var.Name == "NegFiltersInfo") log = InfoLog;
else if (var.Name == "NegFiltersWarning") log = WarningLog;
else if (var.Name == "NegFiltersAssert") log = AssertLog;
else if (var.Name == "NegFiltersError") log = ErrorLog;
else nlstop;
// remove all old filters from config file
CConfigFile::CVar &oldvar = m_ConfigFile.getVar(var.Name);
for (uint j = 0; j < oldvar.size(); j++)
log->removeFilter(oldvar.asString(j).c_str());
// add all new filters from config file
for (uint i = 0; i < var.size(); i++)
log->addNegativeFilter(var.asString(i).c_str());
}
示例12: main
//.........这里部分代码省略.........
std::vector<CUserParams> userParams(numSpellLevels);
// read user params set for each level
for(uint level = 0; level < numSpellLevels; ++level)
{
std::string varName = toString("user_params_level%d", (int) (level + 1));
CConfigFile::CVar *up = cf.getVarPtr(varName);
if (!up)
{
nlwarning("Can't read var %s", varName.c_str());
}
else
{
for(uint k = 0; k < CUserParams::NumUserParams; ++k)
{
userParams[level].UserParam[k] = up->asString(k);
}
}
}
// read types of spells (offensif, curatif ...)
CConfigFile::CVar *spellTypesList = cf.getVarPtr("spell_types");
if (!spellTypesList)
{
nlwarning("Can't read types of spells");
return -1;
}
// read modes of spells
CConfigFile::CVar *spellModesList = cf.getVarPtr("spell_modes");
// read name of ps for projectiles
std::vector<std::string> projPSNames;
projPSNames.resize(spellTypesList->size() * spellModesList->size());
CConfigFile::CVar *projectileNames = cf.getVarPtr("projectile_fx");
if (projectileNames)
{
for(uint k = 0; k < (uint) projectileNames->size(); ++k)
{
// entry are expected to have the following form :
// "type|mode|fx_name.ps"
std::vector<std::string> params;
NLMISC::splitString(projectileNames->asString(k), "|", params);
if (params.size() != 3)
{
nlwarning("Bad param for projectile ps name : %s", projectileNames->asString(k).c_str());
}
else
{
bool found = false;
// find the mode
for (uint mode = 0; mode < (uint) spellModesList->size(); ++mode)
{
if (spellModesList->asString(mode) == params[1])
{
for (uint type = 0; type < (uint) spellTypesList->size(); ++type)
{
if (spellTypesList->asString(type) == params[0])
{
projPSNames[type + mode * spellTypesList->size()] = params[2];
//nlwarning("%s : found", projectileNames->asString(k).c_str());
found = true;
break;
}
}
if (found) break;
示例13: init
/* Load the config file and the related words files. Return false in case of failure.
* Config file variables:
* - WordsPath: where to find <filter>_words_<languageCode>.txt
* - LanguageCode: language code (ex: en for English)
* - Utf8: results are in UTF8, otherwise in ANSI string
* - Filter: "*" for all files (default) or a name (ex: "item").
* - AdditionalFiles/AdditionalFileColumnTitles
*/
bool CWordsDictionary::init( const string& configFileName )
{
// Read config file
bool cfFound = false;
CConfigFile cf;
try
{
cf.load( configFileName );
cfFound = true;
}
catch ( EConfigFile& e )
{
nlwarning( "WD: %s", e.what() );
}
string wordsPath, languageCode, filter = "*";
vector<string> additionalFiles, additionalFileColumnTitles;
bool filterAll = true, utf8 = false;
if ( cfFound )
{
CConfigFile::CVar *v = cf.getVarPtr( "WordsPath" );
if ( v )
{
wordsPath = v->asString();
/*if ( (!wordsPath.empty()) && (wordsPath[wordsPath.size()-1]!='/') )
wordsPath += '/';*/
}
v = cf.getVarPtr( "LanguageCode" );
if ( v )
languageCode = v->asString();
v = cf.getVarPtr( "Utf8" );
if ( v )
utf8 = (v->asInt() == 1);
v = cf.getVarPtr( "Filter" );
if ( v )
{
filter = v->asString();
filterAll = (filter == "*");
}
v = cf.getVarPtr( "AdditionalFiles" );
if ( v )
{
for ( uint i=0; i!=v->size(); ++i )
additionalFiles.push_back( v->asString( i ) );
v = cf.getVarPtr( "AdditionalFileColumnTitles" );
if ( v->size() != additionalFiles.size() )
{
nlwarning( "AdditionalFiles and AdditionalFileColumnTitles have different size, ignoring second one" );
additionalFileColumnTitles.resize( v->size(), DefaultColTitle );
}
else
{
for ( uint i=0; i!=v->size(); ++i )
additionalFileColumnTitles.push_back( v->asString( i ) );
}
}
}
if ( languageCode.empty() )
languageCode = "en";
// Load all found words files
const string ext = ".txt";
vector<string> fileList;
CPath::getPathContent( wordsPath, false, false, true, fileList );
for ( vector<string>::const_iterator ifl=fileList.begin(); ifl!=fileList.end(); ++ifl )
{
const string& filename = (*ifl);
string::size_type p = string::npos;
bool isAdditionalFile = false;
// Test if filename is in additional file list
uint iAdditionalFile;
for ( iAdditionalFile=0; iAdditionalFile!=additionalFiles.size(); ++iAdditionalFile )
{
if ( (p = filename.find( additionalFiles[iAdditionalFile] )) != string::npos )
{
isAdditionalFile = true;
break;
}
}
// Or test if filename is a words_*.txt file
string pattern = string("_words_") + languageCode + ext;
if ( isAdditionalFile ||
((p = filename.find( pattern )) != string::npos) )
{
// Skip if a filter is specified and does not match the current file
if ( (!filterAll) && (filename.find( filter+pattern ) == string::npos) )
continue;
// Load file
nldebug( "WD: Loading %s", filename.c_str() );
//.........这里部分代码省略.........
示例14: if
/*
* CSV -> Georges
*/
void convertCsvFile( const string &file, bool generate, const string& sheetType )
{
const uint BUFFER_SIZE = 16*1024;
char lineBuffer[BUFFER_SIZE];
FILE *s;
vector<string> fields;
vector<string> args;
if ((s = fopen(file.c_str(), "r")) == NULL)
{
fprintf(stderr, "Can't find file %s to convert\n", file.c_str());
return;
}
loadSheetPath();
UFormLoader *formLoader = UFormLoader::createLoader ();
NLMISC::CSmartPtr<CForm> form;
NLMISC::CSmartPtr<UFormDfn> formDfn;
fgets(lineBuffer, BUFFER_SIZE, s);
explode(std::string(lineBuffer), std::string(SEPARATOR), fields);
vector<bool> activeFields( fields.size(), true );
// Load DFN (generation only)
set<CDfnField> dfnFields;
if ( generate )
{
formDfn = formLoader->loadFormDfn( (sheetType + ".dfn").c_str() );
if ( ! formDfn )
nlerror( "Can't find DFN for %s", sheetType.c_str() );
fillFromDFN( formLoader, dfnFields, formDfn, "", sheetType );
// Display missing fields and check fields against DFN
uint i;
for ( i=1; i!=fields.size(); ++i )
{
eraseCarriageReturnsAndMakeBlankNonAsciiChars( fields[i] );
if ( fields[i].empty() )
{
nlinfo( "Skipping field #%u (empty)", i );
activeFields[i] = false;
}
else if ( nlstricmp( fields[i], "parent" ) == 0 )
{
strlwr( fields[i] ); // non-const version
}
else
{
set<CDfnField>::iterator ist = dfnFields.find( CDfnField(fields[i]) );
if ( ist == dfnFields.end() )
{
nlinfo( "Skipping field #%u (%s, not found in %s DFN)", i, fields[i].c_str(), sheetType.c_str() );
activeFields[i] = false;
}
}
}
for ( i=1; i!=fields.size(); ++i )
{
if ( activeFields[i] )
nlinfo( "Selected field: %s", fields[i].c_str() );
}
}
string addExtension = "." + sheetType;
uint dirmapLetterIndex = ~0;
bool dirmapLetterBackward = false;
vector<string> dirmapDirs;
string dirmapSheetCode;
bool WriteEmptyProperties = false, WriteSheetsToDisk = true;
bool ForceInsertParents = false;
if ( generate )
{
// Get the directory mapping
try
{
CConfigFile dirmapcfg;
dirmapcfg.load( sheetType + "_dirmap.cfg" );
if ( OutputPath.empty() )
{
CConfigFile::CVar *path = dirmapcfg.getVarPtr( "OutputPath" );
if ( path )
OutputPath = path->asString();
if ( ! OutputPath.empty() )
{
if ( OutputPath[OutputPath.size()-1] != '/' )
OutputPath += '/';
else if ( ! CFile::isDirectory( OutputPath ) )
nlwarning( "Output path does not exist" );
}
}
//.........这里部分代码省略.........
示例15: init
///init
void CAIService::init (void)
{
// start any available system command.
CConfigFile::CVar *sysCmds = IService::getInstance()->ConfigFile.getVarPtr("SystemCmd");
if (sysCmds != NULL)
{
for (uint i=0; i<sysCmds->size(); ++i)
{
string cmd = sysCmds->asString(i);
nlinfo("Invoking system command '%s'...", cmd.c_str());
int ret = system(cmd.c_str());
nlinfo(" command returned %d", ret);
}
}
// read sheet_id.bin and don't prune out unknown files
CSheetId::init(false);
// Init singleton manager
CSingletonRegistry::getInstance()->init();
// init static fame manager
CStaticFames::getInstance();
setVersion (RYZOM_VERSION);
// Init ligo
if (!LigoConfig.readPrimitiveClass ("world_editor_classes.xml", false))
{
// Should be in l:\leveldesign\world_editor_files
nlerror ("Can't load ligo primitive config file world_editor_classes.xml");
}
// have ligo library register its own class types for its class factory
NLLIGO::Register();
// setup the update systems
setUpdateTimeout(100);
// init sub systems
CAIKeywords::init();
CMirrors::init(cbTick, NULL, cbTickRelease);
CMessages::init();
AISHEETS::CSheets::getInstance()->init();
// initialise the AI_SHARE library
AI_SHARE::init(&LigoConfig);
// set the primitive context
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig;
CAISActions::init();
CEGSInterface::init();
CTimeInterface::init();
CCombatInterface::init();
CVisualPropertiesInterface::init();
CAIDSInterface::init();
// register the service up and service down callbacks
CMirrors::Mirror.setServiceMirrorUpCallback("*", cbServiceMirrorUp, 0);
CMirrors::Mirror.setServiceDownCallback( "*", cbServiceDown, 0);
// CUnifiedNetwork::getInstance()->setServiceDownCallback( "*", cbServiceDown, 0);
CConfigFile::CVar *clientCreature=IService::getInstance()->ConfigFile.getVarPtr ("CreatureDebug");
if (clientCreature)
{
CAIS::instance().setClientCreatureDebug(clientCreature->asInt()!=0);
}
}