本文整理汇总了C++中StringVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ StringVector::size方法的具体用法?C++ StringVector::size怎么用?C++ StringVector::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringVector
的用法示例。
在下文中一共展示了StringVector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCentroidFiles
void ImportProjectFile::getCentroidFiles ()
{
for ( int i = 0 ; i < centroid.size () ; i++ ) {
centroidFiles.push_back ( genFilenameFromPath ( centroid [i] ) );
}
}
示例2: Execute
//****************************************************************************************************
ERMsg CEnvCanGribForecast::Execute(CCallback& callback)
{
ERMsg msg;
//string outputPath = GetDir(WORKING_DIR);
callback.AddMessage(GetString(IDS_UPDATE_DIR));
callback.AddMessage(m_workingDir, 1);
callback.AddMessage(GetString(IDS_UPDATE_FROM));
callback.AddMessage(SERVER_NAME, 1);
callback.AddMessage("");
//delete old files
msg = RemoveOldForecast(callback);
if (!msg)
return msg;
CInternetSessionPtr pSession;
CHttpConnectionPtr pConnection;
msg = GetHttpConnection(SERVER_NAME, pConnection, pSession);
if (!msg)
return msg;
//size_t type = as<size_t>(TYPE);
size_t delta_h = m_type == GT_HRDPS ? 1 : 3;
callback.PushTask("Download gribs list", (MAX_FORECAST_HOURS / delta_h) );
StringVector fileList;
//for (size_t HH = 0; HH < 24 && msg; HH+=6)
size_t HH = GetLatestHH(pConnection);
if (HH!=NOT_INIT)
{
for (size_t hhh = 0; hhh <= MAX_FORECAST_HOURS && msg; hhh += delta_h)
{
string remotePath = CEnvCanGribForecast::GetRemoteFilePath(HH, hhh, "*.grib2");
CFileInfoVector fileListTmp;
msg = FindFiles(pConnection, remotePath, fileListTmp);
//keep only some variables
for (CFileInfoVector::iterator it = fileListTmp.begin(); it != fileListTmp.end(); it++)
{
string fileName = GetFileName(it->m_filePath);
size_t hhh = Gethhh(fileName);
size_t vv = GetVariable(fileName);
if (hhh <= 48 && vv != NOT_INIT)
fileList.push_back(it->m_filePath);
}
msg += callback.StepIt();
}
}
callback.PopTask();
callback.AddMessage("Number of gribs to download: " + ToString(fileList.size()));
callback.PushTask("Download gribs (" + ToString(fileList.size()) +")", fileList.size());
int nbDownload = 0;
for (size_t i = 0; i < fileList.size() && msg; i++)
{
string outputFilePath = GetOutputFilePath(GetFileName(fileList[i]));
CreateMultipleDir(GetPath(outputFilePath));
msg = CopyFile(pConnection, fileList[i], outputFilePath.c_str(), INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_DONT_CACHE);
if (msg)
nbDownload++;
msg += callback.StepIt();
}
pConnection->Close();
pSession->Close();
callback.AddMessage("Number of gribs downloaded: " + ToString(nbDownload));
callback.PopTask();
return msg;
}
示例3: main
int main (int argc, const char** argv)
{
if (argc < 2)
{
printf ("USAGE: glsloptimizer testfolder\n");
return 1;
}
bool hasOpenGL = InitializeOpenGL ();
glslopt_ctx* ctx[2] = {
glslopt_initialize(true),
glslopt_initialize(false),
};
std::string baseFolder = argv[1];
clock_t time0 = clock();
static const char* kTypeName[2] = { "vertex", "fragment" };
size_t tests = 0;
size_t errors = 0;
for (int type = 0; type < 2; ++type)
{
std::string testFolder = baseFolder + "/" + kTypeName[type];
static const char* kAPIName[2] = { "OpenGL ES 2.0", "OpenGL" };
static const char* kApiIn [2] = {"-inES.txt", "-in.txt"};
static const char* kApiIR [2] = {"-irES.txt", "-ir.txt"};
static const char* kApiOut[2] = {"-outES.txt", "-out.txt"};
for (int api = 0; api < 2; ++api)
{
printf ("\n** running %s tests for %s...\n", kTypeName[type], kAPIName[api]);
StringVector inputFiles = GetFiles (testFolder, kApiIn[api]);
size_t n = inputFiles.size();
for (size_t i = 0; i < n; ++i)
{
std::string inname = inputFiles[i];
//if (inname != "ast-in.txt")
// continue;
std::string hirname = inname.substr (0,inname.size()-strlen(kApiIn[api])) + kApiIR[api];
std::string outname = inname.substr (0,inname.size()-strlen(kApiIn[api])) + kApiOut[api];
bool ok = TestFile (ctx[api], type==0, inname, testFolder + "/" + inname, testFolder + "/" + hirname, testFolder + "/" + outname, api==0, hasOpenGL);
if (!ok)
{
++errors;
}
++tests;
}
}
}
clock_t time1 = clock();
float timeDelta = float(time1-time0)/CLOCKS_PER_SEC;
if (errors != 0)
printf ("\n**** %i tests (%.2fsec), %i !!!FAILED!!!\n", tests, timeDelta, errors);
else
printf ("\n**** %i tests (%.2fsec) succeeded\n", tests, timeDelta);
// 3.25s
// with builtin call linking, 3.84s
for (int i = 0; i < 2; ++i)
glslopt_cleanup (ctx[i]);
return errors ? 1 : 0;
}
示例4: if
void X11EGLWindow::initNativeCreatedWindow(const NameValuePairList *miscParams)
{
if (miscParams)
{
NameValuePairList::const_iterator opt;
NameValuePairList::const_iterator end = miscParams->end();
mExternalWindow = 0;
mNativeDisplay = mGLSupport->getNativeDisplay();
mParentWindow = DefaultRootWindow((Display*)mNativeDisplay);
if ((opt = miscParams->find("parentWindowHandle")) != end)
{
//vector<String>::type tokens = StringUtil::split(opt->second, " :");
StringVector tokens = StringUtil::split(opt->second, " :");
if (tokens.size() == 3)
{
// deprecated display:screen:xid format
mParentWindow = (Window)StringConverter::parseUnsignedLong(tokens[2]);
}
else
{
// xid format
mParentWindow = (Window)StringConverter::parseUnsignedLong(tokens[0]);
}
}
else if ((opt = miscParams->find("externalWindowHandle")) != end)
{
//vector<String>::type tokens = StringUtil::split(opt->second, " :");
StringVector tokens = StringUtil::split(opt->second, " :");
LogManager::getSingleton().logMessage(
"EGLWindow::create: The externalWindowHandle parameter is deprecated.\n"
"Use the parentWindowHandle or currentGLContext parameter instead.");
if (tokens.size() == 3)
{
// Old display:screen:xid format
// The old EGL code always created a "parent" window in this case:
mParentWindow = (Window)StringConverter::parseUnsignedLong(tokens[2]);
}
else if (tokens.size() == 4)
{
// Old display:screen:xid:visualinfo format
mExternalWindow = (Window)StringConverter::parseUnsignedLong(tokens[2]);
}
else
{
// xid format
mExternalWindow = (Window)StringConverter::parseUnsignedLong(tokens[0]);
}
}
}
// Ignore fatal XErrorEvents during parameter validation:
oldXErrorHandler = XSetErrorHandler(safeXErrorHandler);
// Validate parentWindowHandle
if (mParentWindow != DefaultRootWindow((Display*)mNativeDisplay))
{
XWindowAttributes windowAttrib;
if (!XGetWindowAttributes((Display*)mNativeDisplay, mParentWindow, &windowAttrib) ||
windowAttrib.root != DefaultRootWindow((Display*)mNativeDisplay))
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Invalid parentWindowHandle (wrong server or screen)",
"EGLWindow::create");
}
}
// Validate externalWindowHandle
if (mExternalWindow != 0)
{
XWindowAttributes windowAttrib;
if (!XGetWindowAttributes((Display*)mNativeDisplay, mExternalWindow, &windowAttrib) ||
windowAttrib.root != DefaultRootWindow((Display*)mNativeDisplay))
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
"Invalid externalWindowHandle (wrong server or screen)",
"EGLWindow::create");
}
mEglConfig = 0;
mEglSurface = createSurfaceFromWindow(mEglDisplay, (NativeWindowType)mExternalWindow);
}
XSetErrorHandler(oldXErrorHandler);
mIsTopLevel = (!mIsExternal && mParentWindow == DefaultRootWindow((Display*)mNativeDisplay));
}
示例5: extractHaplotypeReads
// Extract reads from an FM-index that have a k-mer match to any given haplotypes
// Returns true if the reads were successfully extracted, false if there are
// more reads than maxReads
bool HapgenUtil::extractHaplotypeReads(const StringVector& haplotypes,
const BWTIndexSet& indices,
int k,
bool doReverse,
size_t maxReads,
SeqRecordVector* pOutReads,
SeqRecordVector* pOutMates)
{
// Skip repetitive kmers with more than this many occurrences
int64_t SKIP_INTERVAL_SIZE = 500;
// Extract the set of reads that have at least one kmer shared with these haplotypes
// This is a bit of a lengthy procedure with a few steps:
// 1) extract all the kmers in the haplotypes
// 2) find the intervals for the kmers in the fm-index
// 3) compute the set of read indices of the reads from the intervals (using the sampled suffix array)
// 4) finally, extract the read sequences from the index
// Make a set of kmers from the haplotypes
std::set<std::string> kmerSet;
for(size_t i = 0; i < haplotypes.size(); ++i)
{
const std::string& h = haplotypes[i];
if((int)h.size() < k)
continue;
for(size_t j = 0; j < h.size() - k + 1; ++j)
{
std::string ks = h.substr(j, k);
if(doReverse)
ks = reverseComplement(ks);
kmerSet.insert(ks);
}
}
// Compute suffix array intervals for the kmers
std::vector<BWTInterval> intervals;
for(std::set<std::string>::const_iterator iter = kmerSet.begin(); iter != kmerSet.end(); ++iter)
{
BWTInterval interval = BWTAlgorithms::findInterval(indices, *iter);
if(interval.size() > (int64_t)maxReads)
return false;
if(interval.size() < SKIP_INTERVAL_SIZE)
intervals.push_back(interval);
}
// Compute the set of reads ids
std::set<int64_t> readIndices;
for(size_t i = 0; i < intervals.size(); ++i)
{
BWTInterval interval = intervals[i];
for(int64_t j = interval.lower; j <= interval.upper; ++j)
{
// Get index from sampled suffix array
SAElem elem = indices.pSSA->calcSA(j, indices.pBWT);
readIndices.insert(elem.getID());
}
}
// Check if we have hit the limit of extracting too many reads
if(readIndices.size() > maxReads)
return false;
for(std::set<int64_t>::const_iterator iter = readIndices.begin(); iter != readIndices.end(); ++iter)
{
int64_t idx = *iter;
// Extract the read
std::stringstream namer;
namer << "idx-" << idx;
SeqRecord record;
record.id = namer.str();
record.seq = BWTAlgorithms::extractString(indices.pBWT, idx);
assert(indices.pQualityTable != NULL);
record.qual = indices.pQualityTable->getQualityString(idx, record.seq.length());
if(!record.seq.empty())
pOutReads->push_back(record);
// Optionally extract its mate
// If the index is constructed properly,
// paired reads are in adjacent indices with the
// first read at even indices
if(pOutMates != NULL)
{
int64_t mateIdx = idx;
if(idx % 2 == 0)
mateIdx += 1;
else
mateIdx -= 1;
std::stringstream mateName;
mateName << "idx-" << mateIdx;
SeqRecord mateRecord;
mateRecord.id = mateName.str();
mateRecord.seq = BWTAlgorithms::extractString(indices.pBWT, mateIdx);
mateRecord.qual = indices.pQualityTable->getQualityString(mateIdx, mateRecord.seq.length());
//.........这里部分代码省略.........
示例6: main
int main(int argc, char *argv[])
{
int count = 0; /* match count for each line */
int maxmatch = 0; /* max match for outout campaign */
string name;
if (argc < 2)
{
cout << "Please enter a file path\n";
return -1;
}
std::ifstream ifsReadFile( argv[1] );
if( ifsReadFile )
{
cout<<"Wait for user to type in the input data ..."<<endl;
string input_line;
getline(cin, input_line);
StringVector vInput;
StringVector vOutput;
Split( input_line, " ", vInput );
std::string sFileLine;
while( getline( ifsReadFile, sFileLine ) )
{
StringVector vResult;
Split( sFileLine, " ", vResult );
for(int i=1;i<vResult.size();i++)
{
for(int j=0;j<vInput.size();j++)
{
if(vResult[i].compare(vInput[j]) == 0)
{
count++;
break;
}
}
}
if(count > maxmatch || (count == maxmatch && count!= 0))
{
maxmatch = count;
count = 0;
vOutput.push_back( vResult[0] );
name = vResult[0];
}
else
{
count = 0;
}
}
if(maxmatch == 0)
{
cout<<"No campaign is matched "<<endl;
}
else
{
srand ( time(NULL) );
int index = rand() % vOutput.size();
cout<<"index"<<index<<"output size"<<vOutput.size()<<endl;
cout<<"Output Campaign is : "<<vOutput[index]<<name<<endl;
}
}
else
{
std::cerr << "Error: Cannot open the file." << std::endl;
return -1;
}
return 0;
}
示例7: parseCapabilitiesLines
void RenderSystemCapabilitiesSerializer::parseCapabilitiesLines(CapabilitiesLinesList& lines)
{
StringVector tokens;
for (CapabilitiesLinesList::iterator it = lines.begin(), end = lines.end(); it != end; ++it)
{
// restore the current line information for debugging
mCurrentLine = &(it->first);
mCurrentLineNumber = it->second;
tokens = StringUtil::split(it->first);
// check for incomplete lines
if(tokens.size() < 2)
{
logParseError("No parameters given for the capability keyword");
continue;
}
// the first token must the the keyword identifying the capability
// the remaining tokens are the parameters
String keyword = tokens[0];
String everythingElse = "";
for(unsigned int i = 1; i < tokens.size() - 1; i ++)
{
everythingElse = everythingElse + tokens[i] + " ";
}
everythingElse = everythingElse + tokens[tokens.size() - 1];
CapabilityKeywordType keywordType = getKeywordType(keyword);
switch(keywordType)
{
case UNDEFINED_CAPABILITY_TYPE:
logParseError("Unknown capability keyword: " + keyword);
break;
case SET_STRING_METHOD:
callSetStringMethod(keyword, everythingElse);
break;
case SET_INT_METHOD:
{
ushort integer = (ushort)StringConverter::parseInt(tokens[1]);
callSetIntMethod(keyword, integer);
break;
}
case SET_BOOL_METHOD:
{
bool b = StringConverter::parseBool(tokens[1]);
callSetBoolMethod(keyword, b);
break;
}
case SET_REAL_METHOD:
{
Real real = StringConverter::parseReal(tokens[1]);
callSetRealMethod(keyword, real);
break;
}
case ADD_SHADER_PROFILE_STRING:
{
addShaderProfile(tokens[1]);
break;
}
case SET_CAPABILITY_ENUM_BOOL:
{
bool b = StringConverter::parseBool(tokens[1]);
setCapabilityEnumBool(tokens[0], b);
break;
}
}
}
}
示例8: if
//-----------------------------------------------------------------------
void Quake3ShaderManager::parseShaderPassAttrib( const String& line, Quake3Shader* pShader, Quake3Shader::Pass* pPass)
{
StringVector vecparams;
vecparams = StringUtil::split(line, " \t");
StringVector::iterator params = vecparams.begin();
StringUtil::toLowerCase(params[0]);
if (params[0] != "map" && params[0] != "clampmap" && params[0] != "animmap")
{
// lower case all except textures
for (size_t i = 1; i < vecparams.size(); ++i)
StringUtil::toLowerCase(params[i]);
}
// MAP
if (params[0] == "map")
{
pPass->textureName = params[1];
StringUtil::toLowerCase(params[1]);
if (params[1] == "$lightmap")
pPass->texGen = TEXGEN_LIGHTMAP;
}
// CLAMPMAP
if (params[0] == "clampmap")
{
pPass->textureName = params[1];
StringUtil::toLowerCase(params[1]);
if (params[1] == "$lightmap")
pPass->texGen = TEXGEN_LIGHTMAP;
pPass->addressMode = TextureUnitState::TAM_CLAMP;
}
// ANIMMAP
else if (params[0] == "animmap")
{
pPass->animFps = atof(params[1].c_str());
pPass->animNumFrames = static_cast<unsigned int>( vecparams.size() - 2 );
for (unsigned int frame = 0; frame < pPass->animNumFrames; ++frame)
{
pPass->frames[frame] = params[frame+2];
}
}
// BLENDFUNC
else if (params[0] == "blendfunc")
{
if (params[1] == "add" || params[1] == "gl_add")
{
pPass->blend = LBO_ADD;
pPass->blendDest = SBF_ONE;
pPass->blendSrc = SBF_ONE;
}
else if (params[1] == "filter" || params[1] == "gl_filter")
{
pPass->blend = LBO_MODULATE;
pPass->blendDest = SBF_ZERO;
pPass->blendSrc = SBF_DEST_COLOUR;
}
else if (params[1] == "blend" || params[1] == "gl_blend")
{
pPass->blend = LBO_ALPHA_BLEND;
pPass->blendDest = SBF_ONE_MINUS_SOURCE_ALPHA;
pPass->blendSrc = SBF_SOURCE_ALPHA;
}
else
{
// Manual blend
pPass->blendSrc = convertBlendFunc(params[1]);
pPass->blendDest = convertBlendFunc(params[2]);
// Detect common blends
if (pPass->blendSrc == SBF_ONE && pPass->blendDest == SBF_ZERO)
pPass->blend = LBO_REPLACE;
else if (pPass->blendSrc == SBF_ONE && pPass->blendDest == SBF_ONE)
pPass->blend = LBO_ADD;
else if ((pPass->blendSrc == SBF_ZERO && pPass->blendDest == SBF_SOURCE_COLOUR) ||
(pPass->blendSrc == SBF_DEST_COLOUR && pPass->blendDest == SBF_ZERO))
pPass->blend = LBO_MODULATE;
else if (pPass->blendSrc == SBF_SOURCE_ALPHA && pPass->blendDest == SBF_ONE_MINUS_SOURCE_ALPHA)
pPass->blend = LBO_ALPHA_BLEND;
else
pPass->customBlend = true;
// NB other custom blends might not work due to OGRE trying to use multitexture over multipass
}
}
// RGBGEN
else if (params[0] == "rgbgen")
{
// TODO
}
// ALPHAGEN
else if (params[0] == "alphagen")
{
// TODO
}
// TCGEN
else if (params[0] == "tcgen")
{
//.........这里部分代码省略.........
示例9: createRuntime
NitRuntime* wxNitShellApp::createRuntime()
{
NitRuntime* rt = new DefaultRuntime(this);
rt->setArguments(this->argc, this->argv);
// NOTE: rt may be destroyed within this function.
// So do not use nit::string or RefCounted which is related MemManager
std::string error;
_shellConfig = new Settings();
nit::Ref<Settings> cs = new Settings();
nit::Ref<CmdLineParser> parser = new CmdLineParser();
LogManager::getSingleton().setDefaultLogLevel(LOG_LEVEL_ERROR);
try
{
parser->allowUnknownOptions(true);
parser->allowUnknownParams(true);
_shellConfig->add("switch", "[-v verbose] : full verbosity (overrides log_filter)");
_shellConfig->add("switch", "[-q quiet] : quiet mode (overrides log_filter, verbose)");
_shellConfig->add("option", "[-w log_filter] : show log level equal or higher than this (default: ***)");
_shellConfig->add("option", "[-p pack_path ...] : path to pack path (can use $(macro) in app.Settings), relative to work_path");
parser->addParam("app.cfg", "path to app.cfg");
parser->addSection(_shellConfig);
parser->parse(cs, rt, true);
}
catch (Exception& ex)
{
error = ex.getDescription().c_str();
}
if (error.empty() && !cs->has("app.cfg"))
{
error = "app.cfg path expected";
}
cs->dump();
if (!error.empty())
{
const char* appname = "nit.exe";
const char* logo =
"nit-shell: command line Noriter shell v1.0\n"
"nit: Noriter game-oriented app framework v1.0\n"
"Copyright (c) 2013 Jun-hyeok Jang.";
parser->showUsage(appname, logo, String("*** " ) + error.c_str());
// Release references before delete Mem Manager
_shellConfig = NULL;
cs = NULL;
parser = NULL;
safeDelete(rt);
_exitCode = -1;
return NULL;
}
LogManager& logMgr = LogManager::getSingleton();
if (cs->has("log_filter"))
{
const String& filter = _shellConfig->get("log_filter");
LogLevel lvl = logMgr.getLogLevel(logMgr.tagId(filter.c_str()));
logMgr.setDefaultLogLevel(lvl);
}
if (cs->get("verbose", "false") == "true")
logMgr.setDefaultLogLevel(LOG_LEVEL_VERBOSE);
if (cs->get("quiet", "false") == "true")
logMgr.setDefaultLogLevel(LOG_LEVEL_QUIET);
StringVector paths;
cs->find("pack_path", paths);
for (uint i=0; i<paths.size(); ++i)
_packPaths.push_back(paths[i].c_str());
_appConfigFilename = cs->get("app.cfg").c_str();
if (!StringUtil::endsWith(_appConfigFilename.c_str(), ".app.cfg"))
_appConfigFilename += ".app.cfg";
return rt;
}
示例10: addLookupPaths
void PackageManager::addLookupPaths(const StringVector& lookupPaths) {
_lookupPaths.reserve(_lookupPaths.size() + lookupPaths.size());
for (const auto& path : lookupPaths) {
_lookupPaths.push_back(path);
}
}
示例11: extractLayoutQualifiers
//-----------------------------------------------------------------------
void GLSLESProgramPipeline::extractLayoutQualifiers(void)
{
// Format is:
// layout(location = 0) attribute vec4 vertex;
if(mVertexProgram)
{
String shaderSource = mVertexProgram->getGLSLProgram()->getSource();
String::size_type currPos = shaderSource.find("layout");
while (currPos != String::npos)
{
VertexElementSemantic semantic;
GLint index = 0;
String::size_type endPos = shaderSource.find(";", currPos);
if (endPos == String::npos)
{
// Problem, missing semicolon, abort
break;
}
String line = shaderSource.substr(currPos, endPos - currPos);
// Skip over 'layout'
currPos += 6;
// Skip until '='
String::size_type eqPos = line.find("=");
String::size_type parenPos = line.find(")");
// Skip past '=' up to a ')' which contains an integer(the position). This could be a definition, does the preprocessor do replacement?
String attrLocation = line.substr(eqPos + 1, parenPos - eqPos - 1);
StringUtil::trim(attrLocation);
GLint attrib = StringConverter::parseInt(attrLocation);
// The rest of the line is a standard attribute definition.
// Erase up to it then split the remainder by spaces.
line.erase (0, parenPos + 1);
StringUtil::trim(line);
StringVector parts = StringUtil::split(line, " ");
if(parts.size() < 3)
{
// This is a malformed attribute
// It should contain 3 parts, i.e. "attribute vec4 vertex"
break;
}
String attrName = parts[2];
// Special case for attribute named position
if(attrName == "position")
semantic = getAttributeSemanticEnum("vertex");
else
semantic = getAttributeSemanticEnum(attrName);
// Find the texture unit index
String::size_type uvPos = attrName.find("uv");
if(uvPos != String::npos)
{
String uvIndex = attrName.substr(uvPos + 2, attrName.length() - 2);
index = StringConverter::parseInt(uvIndex);
}
mCustomAttributesIndexes[semantic-1][index] = attrib;
currPos = shaderSource.find("layout", currPos);
}
}
}
示例12: parseAttribute
void FontTranslator::parseAttribute(ScriptCompiler* compiler, FontPtr& pFont,
PropertyAbstractNode* prop)
{
String& attrib = prop->name;
String val;
if (attrib == "glyph")
{
float coords[4];
if (prop->values.size() != 5 || !getString(prop->values.front(), &val) ||
!getFloats(++prop->values.begin(), prop->values.end(), coords, 4))
{
compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line);
return;
}
// Set
// Support numeric and character glyph specification
Font::CodePoint cp;
if (val.size() > 1 && val[0] == 'u')
{
// Unicode glyph spec
String trimmed = val.substr(1);
cp = StringConverter::parseUnsignedInt(trimmed);
}
else
{
// Direct character
cp = val[0];
}
pFont->setGlyphTexCoords(cp, coords[0], coords[1], coords[2], coords[3],
1.0); // assume image is square
}
else if (attrib == "antialias_colour")
{
bool flag;
if (prop->values.empty() || !getBoolean(prop->values.front(), &flag))
{
compiler->addError(ScriptCompiler::CE_STRINGEXPECTED, prop->file, prop->line);
return;
}
pFont->setAntialiasColour(flag);
}
else if (attrib == "code_points")
{
if (prop->values.empty())
{
compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line);
return;
}
for (auto& v : prop->values)
{
bool succ = getString(v, &val);
StringVector itemVec = StringUtil::split(val, "-");
if (succ && itemVec.size() == 2)
{
pFont->addCodePointRange(
Font::CodePointRange(StringConverter::parseUnsignedInt(itemVec[0]),
StringConverter::parseUnsignedInt(itemVec[1])));
}
}
}
else if (prop->values.empty() || !getString(prop->values.front(), &val) ||
!pFont->setParameter(attrib, val))
{
compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line);
}
}
示例13: getRawFiles
void ImportProjectFile::getRawFiles ()
{
for ( int i = 0 ; i < raw.size () ; i++ ) {
rawFiles.push_back ( genFilenameFromPath ( raw [i] ) );
}
}
示例14: initialise
void Logger::initialise( const std::string &id, const Options &options )
{
char *envPtr;
if ( !id.empty() )
this->id( id );
std::string tempLogFile;
if ( options.mLogPath.size() )
{
mLogPath = options.mLogPath;
tempLogFile = mLogPath+"/"+mId+".log";
}
if ( options.mLogFile.size() )
tempLogFile = options.mLogFile;
else
tempLogFile = mLogPath+"/"+mId+".log";
if ( (envPtr = getTargettedEnv( "LOG_FILE" )) )
tempLogFile = envPtr;
Level tempLevel = INFO;
Level tempTermLevel = mTermLevel;
Level tempDatabaseLevel = mDatabaseLevel;
Level tempFileLevel = mFileLevel;
Level tempSyslogLevel = mSyslogLevel;
if ( options.mTermLevel != NOOPT )
tempTermLevel = options.mTermLevel;
if ( options.mDatabaseLevel != NOOPT )
tempDatabaseLevel = options.mDatabaseLevel;
else
tempDatabaseLevel = config.log_level_database >= DEBUG1 ? DEBUG9 : config.log_level_database;
if ( options.mFileLevel != NOOPT )
tempFileLevel = options.mFileLevel;
else
tempFileLevel = config.log_level_file >= DEBUG1 ? DEBUG9 : config.log_level_file;
if ( options.mSyslogLevel != NOOPT )
tempSyslogLevel = options.mSyslogLevel;
else
tempSyslogLevel = config.log_level_syslog >= DEBUG1 ? DEBUG9 : config.log_level_syslog;
// Legacy
if ( (envPtr = getenv( "LOG_PRINT" )) )
tempTermLevel = atoi(envPtr) ? DEBUG9 : NOLOG;
if ( (envPtr = getTargettedEnv( "LOG_LEVEL" )) )
tempLevel = atoi(envPtr);
if ( (envPtr = getTargettedEnv( "LOG_LEVEL_TERM" )) )
tempTermLevel = atoi(envPtr);
if ( (envPtr = getTargettedEnv( "LOG_LEVEL_DATABASE" )) )
tempDatabaseLevel = atoi(envPtr);
if ( (envPtr = getTargettedEnv( "LOG_LEVEL_FILE" )) )
tempFileLevel = atoi(envPtr);
if ( (envPtr = getTargettedEnv( "LOG_LEVEL_SYSLOG" )) )
tempSyslogLevel = atoi(envPtr);
if ( config.log_debug )
{
StringVector targets = split( config.log_debug_target, "|" );
for ( unsigned int i = 0; i < targets.size(); i++ )
{
const std::string &target = targets[i];
if ( target == mId || target == "_"+mId || target == "_"+mIdRoot || target == "_"+mIdRoot || target == "" )
{
if ( config.log_debug_level > NOLOG )
{
tempLevel = config.log_debug_level;
if ( config.log_debug_file[0] )
{
tempLogFile = config.log_debug_file;
tempFileLevel = tempLevel;
}
}
}
}
}
logFile( tempLogFile );
termLevel( tempTermLevel );
databaseLevel( tempDatabaseLevel );
fileLevel( tempFileLevel );
syslogLevel( tempSyslogLevel );
level( tempLevel );
mFlush = (envPtr = getenv( "LOG_FLUSH")) ? atoi( envPtr ) : false;
//mRuntime = (envPtr = getenv( "LOG_RUNTIME")) ? atoi( envPtr ) : false;
{
struct sigaction action;
memset( &action, 0, sizeof(action) );
action.sa_handler = usrHandler;
action.sa_flags = SA_RESTART;
if ( sigaction( SIGUSR1, &action, 0 ) < 0 )
{
Fatal( "sigaction(), error = %s", strerror(errno) );
//.........这里部分代码省略.........
示例15: ParseFunctionName
/*!
* Parses lines for function/method names.
*
* \param line line to be processed
* \param needIndentation last line processed
* \param functionStack stack of functions
* \param functionName function name found
*
* \return 1 if function name is found
*/
int CPythonCounter::ParseFunctionName(const string &line, string & needIndentation, StringVector &functionStack, string &functionName, vector<int> &indenStack, int & numWS)
{
string str;
size_t idx;
int functionWS = 0;
if(indenStack.empty()){
indenStack.push_back(0);
}
functionWS = indenStack.back(); // current function's indentation
if (functionStack.empty()) {
functionStack.push_back("");
needIndentation = "";
}
string tmp;
//get white spaces
tmp = line;
tmp = CUtil::TrimString(tmp, -1);
numWS = (unsigned)(line.length() - tmp.length());
//last line is with "def", if needIndentation=="YES"
//not consider the body of function is in the same line of "def"
if(needIndentation.length() >= 3 && needIndentation == "YES"){
indenStack.push_back(numWS);
needIndentation = "";
}
string mark = needIndentation;
idx = CUtil::FindKeyword(line, "def");
if (idx != string::npos)
{
if (idx + 4 < line.length())
{
str = line.substr(idx + 4);
functionStack.push_back(str);
needIndentation = "YES"; //indicate next line need to get the indentation
}
}
if (functionStack.size() == 1 || functionStack.size() == 0)
{
// dealing with some code out of any subroutines, it is a "main" code
return 2;
}
if(mark != "YES"){
if (functionWS > numWS && functionStack.size() > 1 ) {
//the first element in functionStack is ""
//we need to get the function and pop the function from the functionStack
if(needIndentation=="YES"){
//we have already pushed the new function to the functionStack
string tempp = functionStack.back(); //pop new function
functionStack.pop_back();
str = functionStack.back();
functionStack.pop_back();
functionStack.push_back(tempp); // push new function
indenStack.pop_back(); //pop the function's indentation in the stack
}
else{
str = functionStack.back();
functionStack.pop_back();
indenStack.pop_back(); //pop the function's indentation in the stack
}
//get function's name
idx = str.find("(");
if (idx != string::npos)
{
functionName = CUtil::ClearRedundantSpaces(str.substr(0, idx));
return 1;
}
}
}
return 0;
}