当前位置: 首页>>代码示例>>C++>>正文


C++ Parse函数代码示例

本文整理汇总了C++中Parse函数的典型用法代码示例。如果您正苦于以下问题:C++ Parse函数的具体用法?C++ Parse怎么用?C++ Parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Parse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"
		"dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1\n"
		"MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx\n"
		"dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B\n"
		"AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f\n"
		"BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A\n"
		"cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC\n"
		"AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ\n"
		"MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm\n"
		"aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw\n"
		"ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj\n"
		"IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF\n"
		"MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA\n"
		"A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y\n"
		"7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh\n"
		"1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4\n"
		"-----END CERTIFICATE-----\n\n"

		// Starfield G2 cert
		// This is the data of the root certs for Starfield 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"
		"BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G\n"
		"CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU\n"
		"sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3\n"
		"4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg\n"
		"8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K\n"
		"pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1\n"
		"mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0\n"
		"-----END CERTIFICATE-----\n\n"

		// Starfield original (G1) cert:
		"-----BEGIN CERTIFICATE-----\n"
		"MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n"
		"MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n"
		"U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n"
		"NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n"
		"ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n"
		"ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n"
		"DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n"
		"8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n"
		"+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+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


注:本文中的Parse函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。