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


C++ gd::String类代码示例

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


在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetPropertyForDebugger

    void GetPropertyForDebugger(RuntimeScene & scene, std::size_t propertyNb, gd::String & name, gd::String & value) const
    {
        std::size_t i = 0;
        std::map < gd::String, ManualTimer >::const_iterator end = TimedEventsManager::managers[&scene].timedEvents.end();
        for (std::map < gd::String, ManualTimer >::iterator iter = TimedEventsManager::managers[&scene].timedEvents.begin();iter != end;++iter)
        {
            if ( propertyNb == i )
            {
                name = iter->first;
                //Unmangle name
                if ( name.find("GDNamedTimedEvent_") == 0 && name.length() > 18 )
                    name = name.substr(18, name.length());
                else
                    name = _("No name");

                value = gd::String::From(static_cast<double>(iter->second.GetTime())/1000000.0)+"s";

                return;
            }

            ++i;
        }
    }
开发者ID:alcemirfernandes,项目名称:GD,代码行数:23,代码来源:Extension.cpp

示例2: ShowYesNoMsgBox

/**
 * Show a message box with Yes/No buttons
 */
void GD_EXTENSION_API ShowYesNoMsgBox( RuntimeScene & scene, gd::Variable & variable, const gd::String & message, const gd::String & title )
{
    sf::Clock timeSpent;

    gd::String result;

    //Display the box
    #if defined(WINDOWS)
    if( MessageBoxW(NULL, message.ToWide().c_str(), title.ToWide().c_str(), MB_ICONQUESTION | MB_YESNO) == IDYES)
        result = "yes";
    else
        result = "no";
    #endif
    #if defined(LINUX) || defined(MACOS)
    nw::YesNoMsgBox dialog(title.ToLocale(), message.ToLocale(), result.Raw());
    dialog.wait_until_closed();
    #endif

    scene.NotifyPauseWasMade(timeSpent.getElapsedTime().asMicroseconds());//Don't take the time spent in this function in account.

    //Update the variable
    variable.SetString(result); //Can only be "yes" or "no", no need to encode in UTF8
}
开发者ID:sanyaade-teachings,项目名称:GD,代码行数:26,代码来源:CommonDialogs.cpp

示例3: if

std::set < gd::String > EventsVariablesFinder::FindArgumentsInInstructions(const gd::Platform & platform,
    const gd::Project & project, const gd::Layout & layout, const gd::InstructionsList & instructions,
    bool instructionsAreConditions, const gd::String & parameterType, const gd::String & objectName)
{
    std::set < gd::String > results;

    for (std::size_t aId = 0;aId < instructions.size();++aId)
    {
        gd::String lastObjectParameter = "";
        gd::InstructionMetadata instrInfos = instructionsAreConditions ? MetadataProvider::GetConditionMetadata(platform, instructions[aId].GetType()) :
                                                                         MetadataProvider::GetActionMetadata(platform, instructions[aId].GetType());
        for (std::size_t pNb = 0;pNb < instrInfos.parameters.size();++pNb)
        {
            //The parameter has the searched type...
            if ( instrInfos.parameters[pNb].type == parameterType )
            {
                //...remember the value of the parameter.
                if (objectName.empty() || lastObjectParameter == objectName)
                    results.insert(instructions[aId].GetParameter(pNb).GetPlainString());
            }
            //Search in expressions
            else if (instrInfos.parameters[pNb].type == "expression")
            {
                CallbacksForSearchingVariable callbacks(results, parameterType, objectName);

                gd::ExpressionParser parser(instructions[aId].GetParameter(pNb).GetPlainString());
                parser.ParseMathExpression(platform, project, layout, callbacks);
            }
            //Search in gd::String expressions
            else if (instrInfos.parameters[pNb].type == "string"||instrInfos.parameters[pNb].type == "file" ||instrInfos.parameters[pNb].type == "joyaxis" ||instrInfos.parameters[pNb].type == "color"||instrInfos.parameters[pNb].type == "layer")
            {
                CallbacksForSearchingVariable callbacks(results, parameterType, objectName);

                gd::ExpressionParser parser(instructions[aId].GetParameter(pNb).GetPlainString());
                parser.ParseStringExpression(platform, project, layout, callbacks);
            }
            //Remember the value of the last "object" parameter.
            else if (gd::ParameterMetadata::IsObject(instrInfos.parameters[pNb].type))
            {
                lastObjectParameter = instructions[aId].GetParameter(pNb).GetPlainString();
            }
        }

        if ( !instructions[aId].GetSubInstructions().empty() )
            FindArgumentsInInstructions(platform, project, layout, instructions[aId].GetSubInstructions(),
                instructionsAreConditions, parameterType);
    }

    return results;
}
开发者ID:HaoDrang,项目名称:GD,代码行数:50,代码来源:EventsVariablesFinder.cpp

示例4: OpenLibrary

std::shared_ptr<gd::Platform> PlatformLoader::LoadPlatformInManager(gd::String fullpath)
{
    std::cout << "Loading platform " << fullpath << "..." << std::endl;
    Handle platformHdl = OpenLibrary(fullpath.ToLocale().c_str()); //Use the system locale for filepath
    if (platformHdl == NULL)
    {
        gd::String error = DynamicLibraryLastError();

        cout << "Loading of "<< fullpath <<" failed." << endl;
        cout << "Error returned : \"" << error << "\"" << endl;
        #if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
        wxString userMsg = _("Platform ") + fullpath +
            _(" could not be loaded.\nContact the developer for more information.\n\nDetailed log:\n") + error;
        wxMessageBox(userMsg, _("Platform not compatible"), wxOK | wxICON_EXCLAMATION);
        #endif
    }
    else
    {
        CreatePlatformFunPtr createFunPtr = (CreatePlatformFunPtr)GetSymbol(platformHdl, "CreateGDPlatform");
        DestroyPlatformFunPtr destroyFunPtr = (DestroyPlatformFunPtr)GetSymbol(platformHdl, "DestroyGDPlatform");

        if ( createFunPtr == NULL || destroyFunPtr == NULL )
        {
            cout << "Loading of "<< fullpath <<" failed (no valid create/destroy functions)." << endl;

            CloseLibrary(platformHdl);

            #if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
            wxString userMsg = _("Platform ")+ fullpath +
                _(" could not be loaded.\nContact the developer for more information.\n\nDetailed log:\nNo valid create/destroy functions." );
            wxMessageBox(userMsg, _("Platform not compatible"), wxOK | wxICON_EXCLAMATION);
            #endif
        }
        else
        {
            #if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
            gd::LocaleManager::Get()->AddCatalog(wxFileName(fullpath).GetName()); //In editor, load catalog associated with extension, if any.
            #endif

            std::shared_ptr<gd::Platform> platform(createFunPtr(), destroyFunPtr);
            std::cout << "Loading of " << fullpath << " done." << std::endl;

            gd::PlatformManager::Get()->AddPlatform(platform);
            std::cout << "Registration in platform manager of " << fullpath << " done." << std::endl;
            return platform;
        }
    }

    return std::shared_ptr<gd::Platform>();
}
开发者ID:HaoDrang,项目名称:GD,代码行数:50,代码来源:PlatformLoader.cpp

示例5: defined

void ExtensionsLoader::ExtensionsLoadingDone(const gd::String & directory)
{
    gd::String suffix = "";

    #if defined(WINDOWS)
        suffix += "w";
    #endif

    #if defined(GD_IDE_ONLY)
        suffix += "e";
    #endif

    #if defined(LINUX) || defined (MACOS)

    //List all extensions loaded
    struct dirent *lecture;
    DIR *rep;
    rep = opendir( directory.c_str() );
    int l = 0;

    if ( rep == NULL )
    {
        cout << "Unable to open Extensions ("<< directory <<") directory." << endl;
        return;
    }

    std::vector<gd::String> librariesLoaded;
    while ( (lecture = readdir( rep )) )
    {
        gd::String lec = lecture->d_name;
        if ( lec != "." && lec != ".." && lec.find(".xgd"+suffix, lec.length()-4-suffix.length()) != string::npos)
        {
            librariesLoaded.push_back(directory+"/"+lec);
            l++;
        }
    }

    closedir( rep );

    //Libraries are loaded using dlopen(.., RTLD_LAZY|RTLD_LOCAL) meaning that their symbols are not available for other libraries
    //nor for LLVM/Clang. We then reload set them as global to make their symbols available for LLVM/Clang. We couldn't mark them
    //as global when loading them as every extension use the same "CreateGDExtension" symbol.
    //SetLibraryGlobal is also setting RTLD_NOW to ensure that all symbols are resolved: Otherwise, we can get weird
    //"symbol lookup error" even if the symbols exist in the extensions!
    for (std::size_t i = 0;i<librariesLoaded.size();++i)
        SetLibraryGlobal(librariesLoaded[i].c_str());
    #else
    //Nothing to do on Windows.
    #endif
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:50,代码来源:ExtensionsLoader.cpp

示例6: ChangeProperty

bool RuntimeObject::ChangeProperty(std::size_t propertyNb,
                                   gd::String newValue) {
  if (propertyNb == 0) {
    size_t separationPos = newValue.find(";");

    if (separationPos > newValue.length()) return false;

    gd::String xValue = newValue.substr(0, separationPos);
    gd::String yValue = newValue.substr(separationPos + 1, newValue.length());

    SetX(xValue.To<float>());
    SetY(yValue.To<float>());
  } else if (propertyNb == 1) {
    return SetAngle(newValue.To<float>());
  } else if (propertyNb == 2) {
    return false;
  } else if (propertyNb == 3) {
    if (newValue == _("Hidden")) {
      SetHidden();
    } else
      SetHidden(false);
  } else if (propertyNb == 4) {
    layer = newValue;
  } else if (propertyNb == 5) {
    SetZOrder(newValue.To<int>());
  } else if (propertyNb == 6) {
    return false;
  } else if (propertyNb == 7) {
    return false;
  } else if (propertyNb == 8) {
    return false;
  } else if (propertyNb == 9) {
    return false;
  }

  return true;
}
开发者ID:Lizard-13,项目名称:GD,代码行数:37,代码来源:RuntimeObject.cpp

示例7: Run

void HttpServer::Run(gd::String indexDirectory) {
  // Some options ( Last option must be NULL )
  std::string indexDirectoryLocale = indexDirectory.ToLocale();
  const char *options[] = {"listening_ports",
                           "2828",
                           "document_root",
                           indexDirectoryLocale.c_str(),
                           NULL};

  // Setup callbacks, i.e. nothing to do :)
  struct mg_callbacks callbacks;
  memset(&callbacks, 0, sizeof(callbacks));

  ctx = mg_start(&callbacks, NULL, options);
}
开发者ID:Lizard-13,项目名称:GD,代码行数:15,代码来源:HttpServer.cpp

示例8: GetBinaryFileSize

long int ResourcesLoader::GetBinaryFileSize( const gd::String & filename)
{
    if (resFile.ContainsFile(filename))
        return resFile.GetFileSize(filename);
    else
    {
        ifstream file (filename.ToLocale().c_str(), ios::in|ios::binary|ios::ate);
        if (file.is_open()) {
            return file.tellg();
        }
    }

    std::cout << "Binary file " << filename << " cannot be read. " << std::endl;
    return 0;
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:15,代码来源:ResourcesLoader.cpp

示例9: MakeColorTransparent

void RuntimeSpriteObject::MakeColorTransparent( const gd::String & colorStr )
{
    if ( needUpdateCurrentSprite ) UpdateCurrentSprite();

    ptrToCurrentSprite->MakeSpriteOwnsItsImage(); //We want to modify only the image of the object, not all objects which have the same image.
    std::shared_ptr<SFMLTextureWrapper> dest = ptrToCurrentSprite->GetSFMLTexture();

    std::vector < gd::String > colors = colorStr.Split(U';');

    if ( colors.size() < 3 ) return; //La couleur est incorrecte

    //Update texture and pixel perfect collision mask
    dest->image.createMaskFromColor(  sf::Color( colors[0].To<int>(), colors[1].To<int>(), colors[2].To<int>()));
    dest->texture.loadFromImage(dest->image);
}
开发者ID:wilarch30,项目名称:GD,代码行数:15,代码来源:RuntimeSpriteObject.cpp

示例10: OpenSFMLTextureFromFile

void GD_EXTENSION_API OpenSFMLTextureFromFile( RuntimeScene & scene, const gd::String & fileName, const gd::String & imageName )
{
    //Get or create the texture in memory
    std::shared_ptr<SFMLTextureWrapper> newTexture;
    if ( !scene.GetImageManager()->HasLoadedSFMLTexture(imageName) )
        newTexture = std::shared_ptr<SFMLTextureWrapper>(new SFMLTextureWrapper);
    else
        newTexture = scene.GetImageManager()->GetSFMLTexture(imageName);

    //Open the SFML image and the SFML texture
    newTexture->image.loadFromFile(fileName.ToLocale());
    newTexture->texture.loadFromImage(newTexture->image); //Do not forget to update the associated texture

    scene.GetImageManager()->SetSFMLTextureAsPermanentlyLoaded(imageName, newTexture);
}
开发者ID:mateerladnam,项目名称:GD,代码行数:15,代码来源:PrimitiveDrawingTools.cpp

示例11: GetIntAttribute

int SerializerElement::GetIntAttribute(const gd::String& name,
                                       int defaultValue,
                                       gd::String deprecatedName) const {
  if (attributes.find(name) != attributes.end())
    return attributes.find(name)->second.GetInt();
  else if (!deprecatedName.empty() &&
           attributes.find(deprecatedName) != attributes.end())
    return attributes.find(deprecatedName)->second.GetInt();
  else {
    if (HasChild(name, deprecatedName)) {
      SerializerElement& child = GetChild(name, 0, deprecatedName);
      if (!child.IsValueUndefined()) return child.GetValue().GetInt();
    }
  }

  return defaultValue;
}
开发者ID:4ian,项目名称:GD,代码行数:17,代码来源:SerializerElement.cpp

示例12: LoadSFMLTexture

sf::Texture ResourcesLoader::LoadSFMLTexture(const gd::String & filename)
{
    sf::Texture texture;

    if (resFile.ContainsFile(filename))
    {
        char* buffer = resFile.GetFile(filename);
        if (buffer==NULL)
            cout << "Failed to get the file of a SFML texture from resource file: " << filename << endl;

        if (!texture.loadFromMemory(buffer, resFile.GetFileSize(filename)))
            cout << "Failed to load a SFML texture from resource file: " << filename << endl;
    }
    else if (!texture.loadFromFile(filename.ToLocale()))
        cout << "Failed to load a SFML texture: " << filename << endl;

    return texture;
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:18,代码来源:ResourcesLoader.cpp

示例13: LoadSoundBuffer

sf::SoundBuffer ResourcesLoader::LoadSoundBuffer( const gd::String & filename )
{
    sf::SoundBuffer sbuffer;

    if (resFile.ContainsFile(filename))
    {
        char* buffer = resFile.GetFile(filename);
        if (buffer==NULL)
            cout << "Failed to get the file of a sound buffer from resource file: " << filename << endl;

        if (!sbuffer.loadFromMemory(buffer, resFile.GetFileSize(filename)))
            cout << "Failed to load a sound buffer from resource file: " << filename << endl;
    }
    else if (!sbuffer.loadFromFile(filename.ToLocale()))
        cout << "Failed to load a sound buffer: " << filename << endl;

    return sbuffer;
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:18,代码来源:ResourcesLoader.cpp

示例14: SaveToJSONFile

bool ProjectFileWriter::SaveToJSONFile(const gd::Project & project, const gd::String & filename)
{
    //Serialize the whole project
    gd::SerializerElement rootElement;
    project.SerializeTo(rootElement);

    //Write JSON to file
    gd::String str = gd::Serializer::ToJSON(rootElement);
    std::ofstream ofs(filename.ToLocale().c_str());
    if (!ofs.is_open())
    {
        gd::LogError( _( "Unable to save file ")+ filename + _("!\nCheck that the drive has enough free space, is not write-protected and that you have read/write permissions." ) );
        return false;
    }

    ofs << str;
    ofs.close();
    return true;
}
开发者ID:HaoDrang,项目名称:GD,代码行数:19,代码来源:ProjectFileWriter.cpp

示例15: ifs

bool ProjectFileWriter::LoadFromJSONFile(gd::Project & project, const gd::String & filename)
{
    std::ifstream ifs(filename.ToLocale().c_str());
    if (!ifs.is_open())
    {
        gd::String error = _( "Unable to open the file.") + _("Make sure the file exists and that you have the right to open the file.");
        gd::LogError(error);
        return false;
    }

    project.SetProjectFile(filename);
    project.SetDirty(false);

    std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
    gd::SerializerElement rootElement = gd::Serializer::FromJSON(str);
    project.UnserializeFrom(rootElement);

    return true;
}
开发者ID:HaoDrang,项目名称:GD,代码行数:19,代码来源:ProjectFileWriter.cpp


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