當前位置: 首頁>>代碼示例>>C++>>正文


C++ XString::find方法代碼示例

本文整理匯總了C++中XString::find方法的典型用法代碼示例。如果您正苦於以下問題:C++ XString::find方法的具體用法?C++ XString::find怎麽用?C++ XString::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XString的用法示例。


在下文中一共展示了XString::find方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: _GetTMPName

XString TranscodeExport::_GetTMPName( const XString& fileName ) const
{
    if( !fileName.Contains(".") )
        X_THROW(("No extension in file name!"));

    if( !fileName.Contains(PATH_SLASH) )
        X_THROW(("Need full path to file for export."));

    vector<XString> parts;
    fileName.Split( PATH_SLASH, parts );

    if( parts.size() < 2 )
        X_THROW(("Invalid export path: %s",fileName.c_str()));;

    XString path;

    for( int i = 0; i < ((int)parts.size() - 1); i++ )
        path += XString::Format( "%s%s", PATH_SLASH, parts[i].c_str() );

    XString mediaFileName = parts[parts.size()-1];

    XString fileBaseName = mediaFileName.substr(0, mediaFileName.find("."));
    XString extension = mediaFileName.substr(mediaFileName.find(".")+1);

    XMD5 hash;
    hash.Update( (uint8_t*)fileBaseName.c_str(), fileBaseName.length() );
    hash.Finalize();

    XString fileBaseNameHash = hash.GetAsString();

    return XString::Format( "%s%sexport-tmp-%s.%s",
                            path.c_str(),
                            PATH_SLASH,
                            fileBaseNameHash.c_str(),
                            extension.c_str() );
}
開發者ID:MultiSight,項目名稱:exporty,代碼行數:36,代碼來源:TranscodeExport.cpp

示例2: XSimpleTimeZone

XIRef<XTimeZone> XSimpleTimeZone::FromISOString(const XString& isoString)
{
    if(isoString[0] != '-' && isoString[0] != '+')
        X_THROW(("Invalid ISO Extended String: %s", isoString.c_str()));

    const int sign = isoString[0] == '-' ? -1 : 1;
    const XString str = isoString.substr(1);

    if(str.empty())
        X_THROW(("Invalid ISO Extended String: %s", isoString.c_str()));

    const size_t colonDex = str.find(':');
    XString hoursStr;
    XString minutesStr;

    if(colonDex != string::npos)
    {
        hoursStr = str.substr(0, colonDex);
        minutesStr = str.substr(colonDex + 1);

        if(minutesStr.size() != 2)
            X_THROW(("Invalid ISO Extended String: %s", isoString.c_str()));
    }
    else
        hoursStr = str;

    if(count_if(hoursStr.begin(), hoursStr.end(), verifyDigit) != (int)hoursStr.size() ||
       count_if(minutesStr.begin(), minutesStr.end(), verifyDigit) != (int)minutesStr.size())
    {
        X_THROW(("Invalid ISO Extended String: %s", isoString.c_str()));
    }

    const int hours = hoursStr.ToInt();
    const int minutes = minutesStr.empty() ? 0 : minutesStr.ToInt();

    return new XSimpleTimeZone(sign * (int)(convert(HOURS, MINUTES, hours) + minutes));
}
開發者ID:MultiSight,項目名稱:xsdk,代碼行數:37,代碼來源:XTimeZone.cpp

示例3: _GetNode

XIRef<XDomParserNode> SoapArgs::_GetNode( const XString& path, XIRef<XDomParserNode> parent )
{
    const size_t dot = path.find('.');
    XString front = path.substr(0, dot);
    XString rest = dot == string::npos ? "" : path.substr(dot + 1);

    const list<XIRef<XDomParserNode> >::const_iterator end = parent->GetChildren().end();
    list<XIRef<XDomParserNode> >::const_iterator found = end;

    for(list<XIRef<XDomParserNode> >::const_iterator iter = parent->GetChildren().begin();
        iter != end;
        ++iter)
    {
        if((*iter)->GetTagName() == front)
        {
            found = iter;
            break;
        }
    }

    if(found != end)
        return rest.empty() ? *found : _GetNode(rest, *found);

    XIRef<XDomParserNode> node(new XDomParserNode(XString::Format("<%s>", front.c_str())));
    parent->AppendChild(node);

    if(!rest.empty())
        return _GetNode(rest, node);

    return node;


    /*
    // Key - "foo.bar.alpha"
    // In this case, foo and bar are CONTAINER_TYPE and alpha is a VALUE_TYPE

    SoapArgs* existingNode = current->Find( path);

    if(existingNode)
    {
    }

    vector<XString> parts;
    key.Split( ".", parts );

    XHash<SoapArgsNode>* current = &_complex;


    if( !parts.empty() )
    {
        XString currPath = parts[0];
        size_t limit = parts.size() - 1;

        // Loop over all the CONTAINER_TYPE parts of the path...
        for( size_t i = 0; i < limit; ++i )
        {
            SoapArgsNode* found = current->Find( currPath );

            if( found )
            {
                current = &found->_children;
            }
            else
            {
                SoapArgsNode node;
                node._nodeType = CONTAINER_TYPE;
                node._name = parts[i];
                current->Add( currPath, node );
                SoapArgsNode* foundNode = current->Find( currPath );
                current = &foundNode->_children;
            }

            currPath += "." + parts[i];
        }

        SoapArgsNode* found == current->Find( path );

        if(found)
        {
            SoapArgs node = *found;
            current->Remove( parts[i] );

            return found;
        }
    }

    SoapArgsNode node;
    node._nodeType = VALUE_TYPE;
    node._name = !parts.empty() ? parts[i] : key;
    */
}
開發者ID:KennyDark,項目名稱:opencvr,代碼行數:91,代碼來源:SoapArgs.cpp

示例4: kbc


//.........這裏部分代碼省略.........
  sProjectName = "KBasic Default Project";
  sProjectType = "With Forms MainWindow (you must have myMenuBar created)";
  sTranslation = "&Window;Help;C&ontents;A&bout;Cl&ose;Close &All;&Tile;&Cascade;Arrange &icons;Ne&xt;Pre&vious;";
  sSQL = "QPSQL;localhost;test;postgres;test";

*/

 // if (bUseCache) printf("!!!!!");


 // sprintf(ac, "");
  //if (MAIN_argc > 1 && i <= MAIN_argc) sprintf(ac, "%s", MAIN_argv[i]);
  
  //sprintf(ac, "C:/kbasic16/kbide/examples/kbasic/builtin/__class__.kbasic");

  //if (utility::my_stricmp(ac, "") == 0) return 0;

  //bUseCache = false;
  {
    sKBasicPath = MAIN_argv[0];  
    bool bDebug = false;
#ifdef WINDOWS // HIDE
    bDebug = sKBasicPath.contains("Debug"); // HIDE
#endif // HIDE

    sKBasicPath = sKBasicPath.replace("\\", "/");
#ifdef WINDOWS // HIDE
    sKBasicPath = sKBasicPath.replace("/Debug", "", false); // HIDE
    sKBasicPath = sKBasicPath.replace("/Release", "", false); // HIDE
    sKBasicPath = sKBasicPath.replace(".exe", "", false); // HIDE
#endif // HIDE

    if (bDebug){
      int n = sKBasicPath.findRev("/");
      if (n >= 0) sKBasicPath = sKBasicPath.left(n);

      sKBasicPath = sKBasicPath.replace("kbc", "kbide/ide/cache");
    } else {
      sKBasicPath = sKBasicPath.replace("kbc", "ide/cache");
    }
    
    if (sKBasicPath.isEmpty()) return 0;
  }

  // if (checkLicense(acLicense) == false) return 0;


//  checkSerialNo();

	textbuffer *myTextbuffer = new textbuffer(); // needed to truncate big input strings or zero terminate them
 
  cache *my_cache = new cache();
  token *myToken = new token();
	scanner *myScanner = new scanner(myToken, my_cache);

	char *acText;
  bool b = true;

  if (utility::readSourceFile(&acText, cachePath("project.name").ascii(), myTextbuffer)){
    acText = utility::eatUTF16DOM(acText);
    sProjectName = acText;
  }

//  if (b && (b = utility::readSourceFile(&acText, "c:/kbasic16/kbide/ide/cache/C__kbasic16_kbide_examples_kbasic_builtin___class__.kbasic.scanner", myTextbuffer))){}

開發者ID:DamianSuess,項目名稱:kbasic,代碼行數:65,代碼來源:main.cpp

示例5: if

char *prepareSourceCode(const char *acFile, const char *acText, const XString & sFile)
{
  static XString sText;
  XString sClass = "";
  bool bReport = false;
  bool bModule = false;
  bool bClass = false;

  if (sFile.endsWith(".kbasic_form")){
    sClass = "Form";
  } else if (sFile.endsWith(".kbasic_menubar")){
    sClass = "MenuBar";
  } else if (sFile.endsWith(".kbasic_toolbar")){
    sClass = "ToolBar";
  } else if (sFile.endsWith(".kbasic_module")){
    bModule = true;
  } else if (sFile.endsWith(".kbasic_class")){
    bClass = true;
  } else if (sFile.endsWith(".kbasic_report")){
    sClass = "Report";
    bReport = true;
  }

  XString sHeader = "";

  if (bModule){
    sText = acText; sText = sText.replace("\r", "");
    if (sText.contains("\nEnd Module ", false)) return (char *) sText.ascii();
    if (sText.contains("\nEnd Module\n", false)) return (char *) sText.ascii();
    if (sText.contains("\nEnd Module'", false)) return (char *) sText.ascii();
    if (sText.contains("\nEnd Module/*", false)) return (char *) sText.ascii();
    if (sText.endsWith("End Module", false)) return (char *) sText.ascii();
    if (sText.startsWith("Module ", false)) return (char *) sText.ascii();
    if (sText.startsWith("\nModule ", false)) return (char *) sText.ascii();

    sHeader = sHeader.append("Module ");
    sHeader = sHeader.append(getFilenameWithoutPathAndExtension(acFile));
    sHeader = sHeader.append(" : ");
    
    sText = sText.prepend(sHeader);

    sText = sText.append("\nEnd Module\n");
  } else if (bClass){
    sText = acText; sText = sText.replace("\r", "");
    if (sText.contains("\nEnd Class ", false)) return (char *) sText.ascii();
    if (sText.contains("\nEnd Class\n", false)) return (char *) sText.ascii();
    if (sText.contains("\nEnd Class'", false)) return (char *) sText.ascii();
    if (sText.contains("\nEnd Class/*", false)) return (char *) sText.ascii();
    if (sText.endsWith("End Class", false)) return (char *) sText.ascii();
    if (sText.startsWith("Class ", false)) return (char *) sText.ascii();
    if (sText.startsWith("\nClass ", false)) return (char *) sText.ascii();

    sHeader = sHeader.append("Class ");
    sHeader = sHeader.append(getFilenameWithoutPathAndExtension(acFile));
    if (sFile.endsWith("myEvent.kbasic_class", false)){
      sHeader = sHeader.append(" Inherits Event ");
    }
    sHeader = sHeader.append(" : ");

    
    sText = sText.prepend(sHeader);

    sText = sText.append("\nEnd Class\n");
  } else {

    XString sFind = "\nEnd " + sClass + "\n";
    sText = acText; sText = sText.replace("\r", "");
    sText = sText.mid(sText.find(sFind) + sFind.length());
    
    sHeader = sHeader.append("Class ");
    sHeader = sHeader.append(getFilenameWithoutPathAndExtension(acFile));
    sHeader = sHeader.append(" Inherits ");
    sHeader = sHeader.append(bReport ? "Form" : sClass); // actually Report is a form
    sHeader = sHeader.append("\n");

    sText = sText.prepend(sHeader);

    XString sDefinition = "";
    

    if (sFile.endsWith(".kbasic_form")){
      sDefinition = prepareSourceCodeDefinition(acFile, acText, true);  
    } else if (sFile.endsWith(".kbasic_report")){
      sDefinition = prepareSourceCodeDefinition(acFile, acText, false);  
    }

    sText = sText.append(sDefinition);
    sText = sText.append("\nEnd Class\n");
  }

  return (char *) sText.ascii();

}
開發者ID:DamianSuess,項目名稱:kbasic,代碼行數:93,代碼來源:main.cpp

示例6: atoi

char *prepareSourceCodeDefinition(const char *acFile, const char *acText, bool bForm)
{
  XString sText;

  sText = acText; sText = sText.replace("\r", "");
  int n = 0;

  XString sSQLName = "";
  XString sSQLControls = "";
  XString sAdditonalCode = "";
  XString sAdditional = "";

  int nBorderLeft = 0;
  int nBorderRight = 0;
  int nBorderTop = 0;
  int nBorderBottom = 0;

  int nHeight = 0;
  
  n = sText.find("Height = ");
  if (n >= 0){
    n += 9;
    int n2 = sText.find("\n", n);
    nHeight = atoi(sText.mid(n, n2 - n).ascii());
  }

  n = sText.find("BorderLeft = ");
  if (n >= 0){
    n += 13;
    int n2 = sText.find("\n", n);
    nBorderLeft = atoi(sText.mid(n, n2 - n).ascii());
  }

  n = sText.find("BorderRight = ");
  if (n >= 0){
    n += 14;
    int n2 = sText.find("\n", n);
    nBorderRight = atoi(sText.mid(n, n2 - n).ascii());
  }

  n = sText.find("BorderTop = ");
  if (n >= 0){
    n += 12;
    int n2 = sText.find("\n", n);
    nBorderTop = atoi(sText.mid(n, n2 - n).ascii());
  }

  n = sText.find("BorderBottom = ");
  if (n >= 0){
    n += 15;
    int n2 = sText.find("\n", n);
    nBorderBottom = atoi(sText.mid(n, n2 - n).ascii());
  }

  n = sText.find("SQLControls = \"");
  if (n >= 0){
    n += 15;
    int n2 = sText.find("\"", n);
    sSQLControls = sText.mid(n, n2 - n);
  }

  n = sText.find("SQLName = \"");
  if (n >= 0){
    n += 11;
    int n2 = sText.find("\"", n);
    sSQLName = sText.mid(n, n2 - n);
  }

  n = 0;

  
  n++;

  static XString sDefinition;
  sDefinition = "";
  XString sConstructor = "";

  sDefinition += "\n";



  do {
    n = sText.find("Begin ", n);
    if (n == -1) break;

    int n2 = sText.find("\n", n);
    n += 6;
    XString sLine = sText.mid(n, n2 - n);
    int n3 = sLine.find(" ");
    XString sType = sLine.mid(0, n3);
    XString sName = sLine.mid(n3 + 1);
    sName = sName.stripWhiteSpace();

    sDefinition += "Public ";
    sDefinition += sName;
    sDefinition += " As ";
    sDefinition += sType;
    sDefinition += "\n";

    sConstructor += sName;
//.........這裏部分代碼省略.........
開發者ID:DamianSuess,項目名稱:kbasic,代碼行數:101,代碼來源:main.cpp


注:本文中的XString::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。