本文整理汇总了C++中Parse函数的典型用法代码示例。如果您正苦于以下问题:C++ Parse函数的具体用法?C++ Parse怎么用?C++ Parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SetHasHotkeys
myMenuCommands::myMenuCommands(const char *_Title,cList<cNestedItem> *_Commands,const char *Parameters):cOsdMenu(_Title)
#else
myMenuCommands::myMenuCommands(const char *_Title,cCommands *_Commands, const char *Parameters):cOsdMenu(_Title)
#endif
{
SetHasHotkeys();
commands=_Commands;
#if VDRVERSNUM > 10713
result=NULL;
parameters=Parameters;
for(cNestedItem *Command=commands->First();Command;Command=commands->Next(Command)) {
const char *s=Command->Text();
if(Command->SubItems())
Add(new cOsdItem(hk(cString::sprintf("%s...", s))));
else if(Parse(s))
Add(new cOsdItem(hk(title)));
}
#else
parameters=Parameters?strdup(Parameters):NULL;
for(cCommand *command=commands->First();command;command=commands->Next(command))
Add(new cOsdItem(hk(command->Title())));
#endif
}
myMenuCommands::~myMenuCommands()
{
#if VDRVERSNUM > 10713
free(result);
#else
free(parameters);
#endif
}
#if VDRVERSNUM > 10713
bool myMenuCommands::Parse(const char *s)
{
const char *p=strchr(s,':');
if(p) {
int l=p-s;
if(l>0) {
char t[l+1];
stripspace(strn0cpy(t,s,l+1));
l=strlen(t);
if(l>1&&t[l-1]=='?') {
t[l-1]=0;
confirm=true;
}
else
confirm=false;
title=t;
command=skipspace(p+1);
return true;
}
}
return false;
}
#endif
#if VDRVERSNUM > 10713
eOSState myMenuCommands::Execute()
{
cNestedItem *Command=commands->Get(Current());
if(Command) {
if(Command->SubItems())
return AddSubMenu(new myMenuCommands(Title(),Command->SubItems(),parameters));
if(Parse(Command->Text())) {
if(!confirm||Interface->Confirm(cString::sprintf("%s?",*title))) {
Skins.Message(mtStatus,cString::sprintf("%s...",*title));
free(result);
result=NULL;
cString cmdbuf;
if(!isempty(parameters))
cmdbuf=cString::sprintf("%s %s",*command,*parameters);
const char *cmd=*cmdbuf?*cmdbuf:*command;
dsyslog("executing command '%s'",cmd);
cPipe p;
if(p.Open(cmd,"r")) {
int l=0;
int c;
while((c=fgetc(p))!=EOF) {
if(l%20==0)
result=(char *)realloc(result,l+21);
result[l++]=char(c);
}
if(result)
result[l]=0;
p.Close();
}
else
esyslog("ERROR: can't open pipe for command '%s'",cmd);
Skins.Message(mtStatus,NULL);
if(result)
return AddSubMenu(new cMenuText(title,result,fontFix));
return osEnd;
}
}
}
return osContinue;
}
#else
//.........这里部分代码省略.........
开发者ID:FFTEAM,项目名称:evolux-spark-sh4,代码行数:101,代码来源:mymenucommands.c
示例2: mActiveProfile
//.........这里部分代码省略.........
int cgVStatus = system(command.c_str());
// Delete the old pixel shader output (if it exists).
command = "del " + fxName + "." + msPProfileName[i] + ".txt";
system(command.c_str());
// Compile the pixel shader.
command = "cgc -profile " + msPProfileName[i];
command += " -entry p_" + fxName + " -o " + fxName + ".";
command += msPProfileName[i] + ".txt " + fxName + ".fx";
int cgPStatus = system(command.c_str());
if (cgVStatus == 0 && cgPStatus == 0)
{
// At least one profile compiled.
compileSucceeded = true;
Messages.push_back("The profile pair " + msVProfileName[i] +
" and " + msPProfileName[i] + " compiled.\n");
}
else
{
// Delete the output file when only one of the shaders
// compiled.
if (cgVStatus == 0)
{
// The vertex shader compiled but the pixel shader did
// not.
command = "del " + fxName + "." + msVProfileName[i] +
".txt";
system(command.c_str());
}
else
{
Messages.push_back("Profile " + msVProfileName[i] +
" did not compile.\n");
}
if (cgPStatus == 0)
{
// The pixel shader compiled but the vertex shader did
// not.
command = "del " + fxName + "." + msPProfileName[i];
command += ".txt";
system(command.c_str());
}
else
{
Messages.push_back("Profile " + msPProfileName[i] +
" did not compile.\n");
}
Messages.push_back("The profile pair " + msVProfileName[i] +
" and " + msPProfileName[i] + " did not compile.\n");
}
}
if (!compileSucceeded)
{
Messages.push_back("All profiles failed to compile.\n");
return;
}
}
InitializeMaps();
Program vProgram[Shader::MAX_PROFILES];
Program pProgram[Shader::MAX_PROFILES];
for (int i = 1; i < Shader::MAX_PROFILES; ++i)
{
mActiveProfile = i;
std::string inVName = fxName + "." + msVProfileName[i] + ".txt";
bool hasVProfile = Parse(inVName, msVProfileName[i], vProgram[i]);
std::string inPName = fxName + "." + msPProfileName[i] + ".txt";
bool hasPProfile = Parse(inPName, msPProfileName[i], pProgram[i]);
if (hasVProfile && hasPProfile)
{
if (mEffect == 0)
{
if (!CreateEffect(vProgram[i], pProgram[i]))
{
return;
}
}
else
{
if (!UpdateEffect(vProgram[i], pProgram[i]))
{
return;
}
}
}
}
if (mEffect)
{
mEffect->SaveWMFX(fxName + ".wmfx");
}
}
开发者ID:vijaynerella,项目名称:GeometricTools,代码行数:101,代码来源:FxCompiler.cpp
示例3: throw
void CxxPreProcessorScanner::Parse(CxxPreProcessor* pp) throw(CxxLexerException)
{
CxxLexerToken token;
bool searchingForBranch = false;
CxxPreProcessorToken::Map_t& ppTable = pp->GetTokens();
while(::LexerNext(m_scanner, token)) {
// Pre Processor state
switch(token.type) {
case T_PP_INCLUDE_FILENAME: {
// we found an include statement, recurse into it
wxFileName include;
if(pp->ExpandInclude(m_filename, token.text, include)) {
CxxPreProcessorScanner* scanner = new CxxPreProcessorScanner(include, pp->GetOptions());
try {
scanner->Parse(pp);
} catch(CxxLexerException& e) {
// catch the exception
CL_DEBUG("Exception caught: %s\n", e.message);
}
// make sure we always delete the scanner
wxDELETE(scanner);
DEBUGMSG("<== Resuming parser on file: %s\n", m_filename.GetFullPath());
}
break;
}
case T_PP_IFDEF: {
searchingForBranch = true;
// read the identifier
ReadUntilMatch(T_PP_IDENTIFIER, token);
if(IsTokenExists(ppTable, token)) {
DEBUGMSG("=> ifdef condition is TRUE (line: %d)\n", token.lineNumber);
searchingForBranch = false;
// condition is true
Parse(pp);
} else {
DEBUGMSG("=> ifdef condition is FALSE (line: %d)\n", token.lineNumber);
// skip until we find the next:
// else, elif, endif (but do not consume these tokens)
if(!ConsumeCurrentBranch()) return;
}
break;
}
case T_PP_IFNDEF: {
searchingForBranch = true;
// read the identifier
ReadUntilMatch(T_PP_IDENTIFIER, token);
if(!IsTokenExists(ppTable, token)) {
DEBUGMSG("=> ifndef condition is TRUE (line: %d)\n", token.lineNumber);
searchingForBranch = false;
// condition is true
Parse(pp);
} else {
DEBUGMSG("=> ifndef condition is FALSE (line: %d)\n", token.lineNumber);
// skip until we find the next:
// else, elif, endif (but do not consume these tokens)
if(!ConsumeCurrentBranch()) return;
}
break;
}
case T_PP_IF:
searchingForBranch = true;
case T_PP_ELIF: {
if(searchingForBranch) {
// We expect a condition
if(!CheckIf(ppTable)) {
DEBUGMSG("=> if condition is FALSE (line: %d)\n", token.lineNumber);
// skip until we find the next:
// else, elif, endif (but do not consume these tokens)
if(!ConsumeCurrentBranch()) return;
} else {
DEBUGMSG("=> if condition is TRUE (line: %d)\n", token.lineNumber);
searchingForBranch = false;
// condition is true
Parse(pp);
}
} else {
ConsumeBlock();
return;
}
break;
}
case T_PP_ELSE: {
if(searchingForBranch) {
// if we reached an else, it means that we could not match
// a if/elif/ifdef condition until now - enter it
Parse(pp);
searchingForBranch = false;
} else {
// we already found the branch for the current block
// this means that the 'else' is a stop sign for us
ConsumeBlock();
return;
}
break;
}
case T_PP_ENDIF: {
return;
}
case T_PP_DEFINE: {
//.........这里部分代码省略.........
开发者ID:GaganJotSingh,项目名称:codelite,代码行数:101,代码来源:CxxPreProcessorScanner.cpp
示例4: Parse
bool CXBMCTinyXML::Parse(const std::string& data, const std::string& dataCharset)
{
m_SuggestedCharset = dataCharset;
StringUtils::ToUpper(m_SuggestedCharset);
return Parse(data, TIXML_ENCODING_UNKNOWN);
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:6,代码来源:XBMCTinyXML.cpp
示例5: GetCACerts
//.........这里部分代码省略.........
"9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq\n"
"fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv\n"
"iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU\n"
"1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+\n"
"bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW\n"
"MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA\n"
"ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l\n"
"uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn\n"
"Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS\n"
"tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF\n"
"PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un\n"
"hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV\n"
"5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\n"
"-----END CERTIFICATE-----\n\n"
// Equifax root CA cert
// Exported from Mozilla Firefox's built-in CA repository
"-----BEGIN CERTIFICATE-----\n"
"MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV\n"
"UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy\n"
"dGlmaWNhdG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technologies, the CA that used to sign sessionserver.mojang.com's cert
// Downloaded from https://certs.starfieldtech.com/repository/
"-----BEGIN CERTIFICATE-----\n"
"MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n"
"EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n"
"HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs\n"
"ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw\n"
"MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6\n"
"b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj\n"
"aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp\n"
"Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n"
"ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg\n"
"nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1\n"
"HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N\n"
"Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN\n"
"dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0\n"
"HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO\n"
"BgNVHQ8BAf8EBAMCAQYwHQYDV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z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n"
"X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n"
"K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n"
"1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n"
"A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n"
"zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n"
"YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n"
"bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n"
"DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n"
"L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n"
"eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n"
"xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n"
"VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n"
"WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n"
"-----END CERTIFICATE-----\n"
;
static auto X509Cert = [&]()
{
auto Cert = std::make_shared<cX509Cert>();
VERIFY(0 == Cert->Parse(CertString, sizeof(CertString)));
return Cert;
}();
return X509Cert;
}
开发者ID:ThuGie,项目名称:MCServer,代码行数:101,代码来源:MojangAPI.cpp
示例6: SetError
bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
{
if ( !file )
{
SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
return false;
}
// Delete the existing data:
Clear();
location.Clear();
// Get the file size, so we can pre-allocate the string. HUGE speed impact.
long length = 0;
fseek( file, 0, SEEK_END );
length = ftell( file );
fseek( file, 0, SEEK_SET );
// Strange case, but good to handle up front.
if ( length <= 0 )
{
SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
return false;
}
// Subtle bug here. TinyXml did use fgets. But from the XML spec:
// 2.11 End-of-Line Handling
// <snip>
// <quote>
// ...the XML processor MUST behave as if it normalized all line breaks in external
// parsed entities (including the document entity) on input, before parsing, by translating
// both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
// a single #xA character.
// </quote>
//
// It is not clear fgets does that, and certainly isn't clear it works cross platform.
// Generally, you expect fgets to translate from the convention of the OS to the c/unix
// convention, and not work generally.
/*
while( fgets( buf, sizeof(buf), file ) )
{
data += buf;
}
*/
char* buf = new char[ length+1 ];
buf[0] = 0;
if ( fread( buf, length, 1, file ) != 1 ) {
delete [] buf;
SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
return false;
}
// Process the buffer in place to normalize new lines. (See comment above.)
// Copies from the 'p' to 'q' pointer, where p can advance faster if
// a newline-carriage return is hit.
//
// Wikipedia:
// Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or
// CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)...
// * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others
// * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS
// * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9
const char* p = buf; // the read head
char* q = buf; // the write head
const char CR = 0x0d;
const char LF = 0x0a;
buf[length] = 0;
while( *p ) {
assert( p < (buf+length) );
assert( q <= (buf+length) );
assert( q <= p );
if ( *p == CR ) {
*q++ = LF;
p++;
if ( *p == LF ) { // check for CR+LF (and skip LF)
p++;
}
}
else {
*q++ = *p++;
}
}
assert( q <= (buf+length) );
*q = 0;
Parse( buf, 0, encoding );
delete [] buf;
return !Error();
}
开发者ID:regedit-lv,项目名称:metamorphosis,代码行数:96,代码来源:tinyxml.cpp
示例7: Parse
DateTime DateTime::Parse(const core::string& str)
{
DateTime ret;
Parse(str, ret);
return ret;
}
开发者ID:yingzhang536,项目名称:mrayy-Game-Engine,代码行数:6,代码来源:DateTime.cpp
示例8: MGL_TO_WCS
//-----------------------------------------------------------------------------
int mglParser::Parse(mglGraph *gr, const char *str, long pos)
{
int r=0;
MGL_TO_WCS(str,r = Parse(gr,wcs,pos));
return r;
}
开发者ID:nickjhathaway,项目名称:mathgl,代码行数:7,代码来源:parser.cpp
示例9: ParseDef
//-----------------------------------------------------------------------------
// return values: 0 - OK, 1 - wrong arguments, 2 - wrong command, 3 - string too long, 4 -- unclosed string
int mglParser::Parse(mglGraph *gr, std::wstring str, long pos)
{
if(Stop || gr->NeedStop()) return 0;
curGr = gr->Self();
std::wstring arg[1024];
str=mgl_trim_ws(str);
long n,k=0,m=0,mm=0,res;
// try parse ':' -- several commands in line
for(n=0;n<long(str.length());n++)
{
if(str[n]=='\'' && (n==0 || str[n-1]!='\\')) k++;
if(k%2) continue;
if(str[n]=='(') m++; if(str[n]==')') m--;
if(str[n]=='{') mm++; if(str[n]=='}') mm--;
if(str[n]=='#') break;
if((str[n]==':' || str[n]=='\n') && k%2==0 && m==0 && mm==0)
{
res=Parse(gr,str.substr(0,n),pos);
if(!res) res=Parse(gr,str.substr(n+1),pos);
return res;
}
}
if(k%2 || m || mm) return 4; // strings is not closed
// define parameters or start cycle
res = ParseDef(str); if(res) return res-1;
// parse arguments (parameters $1, ..., $9)
PutArg(str,false); str=mgl_trim_ws(str);
std::wstring opt;
for(k=0;k<1024;k++) // parse string to substrings (by spaces)
{
n = mglFindArg(str);
if(n<1) // this is option
{
if(str[-n]==';') opt = str.substr(-n+1);
if(n<0) str = str.substr(0,-n);
break;
}
arg[k] = str.substr(0,n);
str = mgl_trim_ws(str.substr(n+1));
}
// try to find last argument
if(str[0]!=0 && str[0]!='#' && str[0]!=';') { arg[k] = str; k++; }
if(k<1) n =0;
else
{
// fill arguments by its values
mglArg *a = new mglArg[k];
FillArg(gr, k, arg, a);
// execute first special (program-flow-control) commands
if(!skip() && !arg[0].compare(L"stop"))
{ Stop = true; delete []a; return 0; }
if(!arg[0].compare(L"func"))
{ Stop = true; delete []a; return 0; }
n = FlowExec(gr, arg[0].c_str(),k-1,a);
if(n) { delete []a; return n-1; }
if(skip()) { delete []a; return 0; }
if(!arg[0].compare(L"load"))
{
int n = a[0].type==1?0:1;
a[0].s.assign(a[0].w.begin(),a[0].w.end());
if(!n) mgl_parser_load(this,a[0].s.c_str());
delete []a; return n;
}
if(!arg[0].compare(L"define"))
{
if(k==3)
{
DeleteVar(arg[1].c_str()); // force to delete variable with the same name
mglNum *v=AddNum(arg[1].c_str());
if(arg[2][0]=='!') // complex number is added
{ HADT dd = mglFormulaCalcC(arg[2].substr(1),this, DataList);
v->d=NAN; v->c = dd->a[0]; delete dd; }
else
{ HMDT dd = mglFormulaCalc(arg[2],this, DataList);
v->c = v->d = dd->a[0]; delete dd; }
}
delete []a; return k==3?0:1;
}
if(!arg[0].compare(L"rkstep"))
{
int res=1;
if(k>2 && a[0].type==1 && a[1].type==1)
{
std::wstring a1 = arg[1], a2=arg[2]; res = 0;
if(a1[0]=='\'') a1 = a1.substr(1,a1.length()-2);
if(a2[0]=='\'') a2 = a2.substr(1,a2.length()-2);
mgl_rk_step_w(this, a1.c_str(), a2.c_str(), (k>=3 && a[2].type==2)?a[2].v:1);
}
delete []a; return res;
}
if(!arg[0].compare(L"call"))
{
n = 1;
if(a[0].type==1)
{
int na=0;
a[0].s.assign(a[0].w.begin(),a[0].w.end());
//.........这里部分代码省略.........
开发者ID:nickjhathaway,项目名称:mathgl,代码行数:101,代码来源:parser.cpp
示例10: parse
static void parse(int tok, SToken *tok_data)
{
Parse(parser, tok, tok_data);
}
开发者ID:jsimmons,项目名称:steady,代码行数:4,代码来源:parse.c
示例11: Parse
JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) {
Parse(jsonPath, &fJsonRoot);
fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults];
}
开发者ID:Adenilson,项目名称:skia,代码行数:4,代码来源:gm_expectations.cpp
示例12: TJS_F_TRACE
void tTJSScriptBlock::SetText(tTJSVariant *result, const tjs_char *text,
iTJSDispatch2 * context, bool isexpression)
{
TJS_F_TRACE("tTJSScriptBlock::SetText");
// compiles text and executes its global level scripts.
// the script will be compiled as an expression if isexpressn is true.
if(!text) return;
if(!text[0]) return;
TJS_D((TJS_W("Counting lines ...\n")))
Script = new tjs_char[TJS_strlen(text)+1];
TJS_strcpy(Script, text);
// calculation of line-count
tjs_char *ls = Script;
tjs_char *p = Script;
while(*p)
{
if(*p == TJS_W('\r') || *p == TJS_W('\n'))
{
LineVector.push_back(int(ls - Script));
LineLengthVector.push_back(int(p - ls));
if(*p == TJS_W('\r') && p[1] == TJS_W('\n')) p++;
p++;
ls = p;
}
else
{
p++;
}
}
if(p!=ls)
{
LineVector.push_back(int(ls - Script));
LineLengthVector.push_back(int(p - ls));
}
try
{
// parse and execute
#ifdef TJS_DEBUG_PROFILE_TIME
{
tTJSTimeProfiler p(parsetime);
#endif
Parse(text, isexpression, result != NULL);
#ifdef TJS_DEBUG_PROFILE_TIME
}
{
char buf[256];
sprintf(buf, "parsing : %d", parsetime);
OutputDebugString(buf);
if(parsetime)
{
sprintf(buf, "Commit : %d (%d%%)", time_Commit, time_Commit*100/parsetime);
OutputDebugString(buf);
sprintf(buf, "yylex : %d (%d%%)", time_yylex, time_yylex*100/parsetime);
OutputDebugString(buf);
sprintf(buf, "MakeNP : %d (%d%%)", time_make_np, time_make_np*100/parsetime);
OutputDebugString(buf);
sprintf(buf, "GenNodeCode : %d (%d%%)", time_GenNodeCode, time_GenNodeCode*100/parsetime);
OutputDebugString(buf);
sprintf(buf, " PutCode : %d (%d%%)", time_PutCode, time_PutCode*100/parsetime);
OutputDebugString(buf);
sprintf(buf, " PutData : %d (%d%%)", time_PutData, time_PutData*100/parsetime);
OutputDebugString(buf);
sprintf(buf, " this_proxy : %d (%d%%)", time_this_proxy, time_this_proxy*100/parsetime);
OutputDebugString(buf);
sprintf(buf, "ns::Push : %d (%d%%)", time_ns_Push, time_ns_Push*100/parsetime);
OutputDebugString(buf);
sprintf(buf, "ns::Pop : %d (%d%%)", time_ns_Pop, time_ns_Pop*100/parsetime);
OutputDebugString(buf);
sprintf(buf, "ns::Find : %d (%d%%)", time_ns_Find, time_ns_Find*100/parsetime);
OutputDebugString(buf);
sprintf(buf, "ns::Remove : %d (%d%%)", time_ns_Remove, time_ns_Remove*100/parsetime);
OutputDebugString(buf);
sprintf(buf, "ns::Commit : %d (%d%%)", time_ns_Commit, time_ns_Commit*100/parsetime);
OutputDebugString(buf);
}
}
#endif
#ifdef TJS_DEBUG_DISASM
std::list<tTJSInterCodeContext *>::iterator i =
InterCodeContextList.begin();
while(i != InterCodeContextList.end())
{
ConsoleOutput(TJS_W(""), (void*)this);
ConsoleOutput((*i)->GetName(), (void*)this);
(*i)->Disassemble(ConsoleOutput, (void*)this);
i++;
//.........这里部分代码省略.........
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:101,代码来源:tjsScriptBlock.cpp
示例13: Clear
////--------------------
/// FFConfigParser::Init
//------------------------
// Reads the force feedback configuration file. Call this once after the device
// is initialized.
//
// Parameters:
// * filename
//
// Returns:
// * qtrue - the effects set directory has been set according to the initialized
// device. (See base/fffx/fffx.cfg)
// * qfalse - no effects set could be determined for this device.
//
qboolean FFConfigParser::Init( const char *filename )
{
Clear(); // Always cleanup
return qboolean( filename && Parse( LoadFile( filename ) ) );
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:20,代码来源:ff_ConfigParser.cpp
示例14: Parse
/*
Parser
*/
Parser::Parser(const char *file_name)
{
Parse(file_name);
}
开发者ID:DeejStar,项目名称:Shadowgrounds-Redux,代码行数:7,代码来源:Parser.cpp
示例15: Parse
unsigned int JsonObjectNode::Parse(const tstring& content)
{
return Parse(content.c_str(), content.length());
}
开发者ID:BornHunter,项目名称:CGSF,代码行数:4,代码来源:JsonNode.cpp
示例16: Init
LTBOOL CAIGoalButeMgr::Init(const char* szAttributeFile)
{
if (g_pAIGoalButeMgr || !szAttributeFile) return LTFALSE;
if (!Parse(szAttributeFile))
{
AIASSERT1( 0, NULL, "CAIGoalButeMgr::Init: Failed to parse %s", szAttributeFile );
return LTFALSE;
}
// Set up global pointer
g_pAIGoalButeMgr = this;
// Read Goal Sets.
uint32 iGoalSet = 0;
sprintf(s_aTagName, "%s%d", "GoalSet", iGoalSet);
while (m_buteMgr.Exist(s_aTagName))
{
ReadGoalSet();
++iGoalSet;
sprintf(s_aTagName, "%s%d", "GoalSet", iGoalSet);
}
// Create an array as big as the goal type enum list.
m_aTemplates = debug_newa(AIGBM_GoalTemplate, kGoal_Count);
// See how many goal templates there are
uint32 cTemplates = 0;
sprintf(s_aTagName, "%s%d", "Goal", cTemplates);
while (m_buteMgr.Exist(s_aTagName))
{
++cTemplates;
sprintf(s_aTagName, "%s%d", "Goal", cTemplates);
}
// Read the goal templates.
for ( uint32 iTemplate = 0 ; iTemplate < cTemplates ; ++iTemplate )
{
ReadGoalTemplate(iTemplate);
}
// Read SmartObject templates.
uint32 iSmartObject = 0;
sprintf(s_aTagName, "%s%d", "SmartObject", iSmartObject);
while (m_buteMgr.Exist(s_aTagName))
{
ReadSmartObjectTemplate(iSmartObject);
++iSmartObject;
sprintf(s_aTagName, "%s%d", "SmartObject", iSmartObject);
}
m_buteMgr.Term();
return LTTRUE;
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:66,代码来源:AIGoalButeMgr.cpp
示例17: JSONValue
/**
* Parses a JSON encoded value to a JSONValue object
*
* @access protected
*
* @param wchar_t** data Pointer to a wchar_t* that contains the data
*
* @return JSONValue* Returns a pointer to a JSONValue object on success, NULL on error
*/
JSONValue *JSONValue::Parse(const wchar_t **data)
{
// Is it a string?
if (**data == '"')
{
std::wstring str;
if (!JSON::ExtractString(&(++(*data)), str))
return NULL;
else
return new JSONValue(str);
}
// Is it a boolean?
else if ((simplejson_wcsnlen(*data, 4) && wcsncasecmp(*data, L"true", 4) == 0) || (simplejson_wcsnlen(*data, 5) && wcsncasecmp(*data, L"false", 5) == 0))
{
bool value = wcsncasecmp(*data, L"true", 4) == 0;
(*data) += value ? 4 : 5;
return new JSONValue(value);
}
// Is it a null?
else if (simplejson_wcsnlen(*data, 4) && wcsncasecmp(*data, L"null", 4) == 0)
{
(*data) += 4;
return new JSONValue();
}
// Is it a number?
else if (**data == L'-' || (**data >= L'0' && **data <= L'9'))
{
// Negative?
bool neg = **data == L'-';
if (neg) (*data)++;
double number = 0.0;
// Parse the whole part of the number - only if it wasn't 0
if (**data == L'0')
(*data)++;
else if (**data >= L'1' && **data <= L'9')
number = JSON::ParseInt(data);
else
return NULL;
// Could be a decimal now...
if (**data == '.')
{
(*data)++;
// Not get any digits?
if (!(**data >= L'0' && **data <= L'9'))
return NULL;
// Find the decimal and sort the decimal place out
// Use ParseDecimal as ParseInt won't work with decimals less than 0.1
// thanks to Javier Abadia for the report & fix
double decimal = JSON::ParseDecimal(data);
// Save the number
number += decimal;
}
// Could be an exponent now...
if (**data == L'E' || **data == L'e')
{
(*data)++;
// Check signage of expo
bool neg_expo = false;
if (**data == L'-' || **data == L'+')
{
neg_expo = **data == L'-';
(*data)++;
}
// Not get any digits?
if (!(**data >= L'0' && **data <= L'9'))
return NULL;
// Sort the expo out
double expo = JSON::ParseInt(data);
for (double i = 0.0; i < expo; i++)
number = neg_expo ? (number / 10.0) : (number * 10.0);
}
// Was it neg?
if (neg) number *= -1;
return new JSONValue(number);
}
//.........这里部分代码省略.........
开发者ID:JordanLingHua,项目名称:swarch,代码行数:101,代码来源:JSONValue.cpp
示例18: Load
bool DllLoader::Load()
{
if (!Parse())
{
CLog::Log(LOGERROR, "Unable to open dll %s", GetFileName());
return false;
}
ResolveImports();
LoadSymbols();
// only execute DllMain if no EntryPoint is found
if (!EntryAddress)
ResolveExport("DllMain", (void**)&EntryAddress);
// patch some unwanted calls in memory
if (strstr(GetName(), "QuickTime.qts"))
{
int i;
uintptr_t dispatch_addr;
uintptr_t imagebase_addr;
uintptr_t dispatch_rva;
ResolveExport("theQuickTimeDispatcher", (void **)&dispatch_addr);
imagebase_addr = (uintptr_t)hModule;
CLog::Log(LOGDEBUG,
"Virtual Address of theQuickTimeDispatcher = %p",
(void *)dispatch_addr);
CLog::Log(LOGDEBUG, "ImageBase of %s = %p",
GetName(), (void *)imagebase_addr);
dispatch_rva = dispatch_addr - imagebase_addr;
CLog::Log(LOGDEBUG,
"Relative Virtual Address of theQuickTimeDispatcher = %p",
(void *)dispatch_rva);
uintptr_t base = imagebase_addr;
if (dispatch_rva == 0x124C30)
{
CLog::Log(LOGINFO, "QuickTime5 DLLs found\n");
for (i = 0;i < 5;i++) ((BYTE*)base + 0x19e842)[i] = 0x90; // make_new_region ?
for (i = 0;i < 28;i++) ((BYTE*)base + 0x19e86d)[i] = 0x90; // call__call_CreateCompatibleDC ?
for (i = 0;i < 5;i++) ((BYTE*)base + 0x19e898)[i] = 0x90; // jmp_to_call_loadbitmap ?
for (i = 0;i < 9;i++) ((BYTE*)base + 0x19e8ac)[i] = 0x90; // call__calls_OLE_shit ?
for (i = 0;i < 106;i++) ((BYTE*)base + 0x261B10)[i] = 0x90; // disable threads
}
else if (dispatch_rva == 0x13B330)
{
CLog::Log(LOGINFO, "QuickTime6 DLLs found\n");
for (i = 0;i < 5;i++) ((BYTE*)base + 0x2730CC)[i] = 0x90; // make_new_region
for (i = 0;i < 28;i++) ((BYTE*)base + 0x2730f7)[i] = 0x90; // call__call_CreateCompatibleDC
for (i = 0;i < 5;i++) ((BYTE*)base + 0x273122)[i] = 0x90; // jmp_to_call_loadbitmap
for (i = 0;i < 9;i++) ((BYTE*)base + 0x273131)[i] = 0x90; // call__calls_OLE_shit
for (i = 0;i < 96;i++) ((BYTE*)base + 0x2AC852)[i] = 0x90; // disable threads
}
else if (dispatch_rva == 0x13C3E0)
{
CLog::Log(LOGINFO, "QuickTime6.3 DLLs found\n");
for (i = 0;i < 5;i++) ((BYTE*)base + 0x268F6C)[i] = 0x90; // make_new_region
for (i = 0;i < 28;i++) ((BYTE*)base + 0x268F97)[i] = 0x90; // call__call_CreateCompatibleDC
for (i = 0;i < 5;i++) ((BYTE*)base + 0x268FC2)[i] = 0x90; // jmp_to_call_loadbitmap
for (i = 0;i < 9;i++) ((BYTE*)base + 0x268FD1)[i] = 0x90; // call__calls_OLE_shit
for (i = 0;i < 96;i++) ((BYTE*)base + 0x2B4722)[i] = 0x90; // disable threads
}
else
{
CLog::Log(LOGERROR, "Unsupported QuickTime version");
}
CLog::Log(LOGINFO, "QuickTime.qts patched!!!\n");
}
#ifdef LOGALL
CLog::Log(LOGDEBUG, "Executing EntryPoint with DLL_PROCESS_ATTACH at: 0x%x - Dll: %s", pLoader->EntryAddress, sName);
#endif
if(EntryAddress)
{
EntryFunc initdll = (EntryFunc)EntryAddress;
/* since we are handing execution over to unknown code, safeguard here */
try
{
#ifdef _LINUX
extend_stack_for_dll_alloca();
#endif
initdll((HINSTANCE)hModule, DLL_PROCESS_ATTACH , 0); //call "DllMain" with DLL_PROCESS_ATTACH
#ifdef LOGALL
CLog::Log(LOGDEBUG, "EntryPoint with DLL_PROCESS_ATTACH called - Dll: %s", sName);
#endif
}
XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception during DLL_PROCESS_ATTACH", __FUNCTION__);
// vp7vfw.dll throws a CUserException due to a missing export
// but the export isn't really needed for normal operation
//.........这里部分代码省略.........
开发者ID:ECMC,项目名称:xbmc,代码行数:101,代码来源:DllLoader.cpp
示例19: ParseAlloc
tst_t *Parse_config_string(bstring content)
{
Token *temp = NULL;
void *parser = ParseAlloc(malloc);
check_mem(parser);
ParserState state = {.settings = NULL, .error = 0, .line_number = 1};
char *p = bdata(content);
char *pe = bdataofs(content, blength(content) - 1);
char *eof = pe;
int cs = -1;
int act = -1;
char *ts = NULL;
char *te = NULL;
#line 80 "src/lexer.c"
{
cs = m2sh_lexer_start;
ts = 0;
te = 0;
act = 0;
}
#line 103 "src/lexer.rl"
#line 90 "src/lexer.c"
{
if ( p == pe )
goto _test_eof;
switch ( cs )
{
tr1:
#line 44 "src/lexer.rl"
{te = p+1;{ TKSTR(QSTRING) }}
goto st8;
tr4:
#line 59 "src/lexer.rl"
{te = p+1;}
goto st8;
tr9:
#line 45 "src/lexer.rl"
{te = p+1;{ TKSTR(PATTERN) }}
goto st8;
tr10:
#line 57 "src/lexer.rl"
{te = p+1;}
goto st8;
tr12:
#line 56 "src/lexer.rl"
{te = p+1;{ state.line_number++; }}
goto st8;
tr13:
#line 51 "src/lexer.rl"
{te = p+1;{ TK(LPAREN) }}
goto st8;
tr14:
#line 52 "src/lexer.rl"
{te = p+1;{ TK(RPAREN) }}
goto st8;
tr15:
#line 53 "src/lexer.rl"
{te = p+1;{ TK(COMMA) }}
goto st8;
tr17:
#line 54 "src/lexer.rl"
{te = p+1;{ TK(COLON) }}
goto st8;
tr18:
#line 46 "src/lexer.rl"
{te = p+1;{ TK(EQ) }}
goto st8;
tr20:
#line 49 "src/lexer.rl"
{te = p+1;{ TK(LBRACE) }}
goto st8;
tr21:
#line 50 "src/lexer.rl"
{te = p+1;{ TK(RBRACE) }}
goto st8;
tr23:
#
|
请发表评论