• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ csString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: while

int csPixelShaderParser::GetArguments (const csString &str, csString &dest,
  csString &src1, csString &src2, csString &src3, csString &src4)
{
  size_t start = str.FindFirst (' ');
  if (start == (size_t)-1) return 0;

  int argument = 0;
  size_t len = str.Length ();
  while(argument < 5 && start < len)
  {
    size_t end = str.FindFirst (',', start + 1);
    if(end == (size_t)-1) end = str.Length ();
    if(end - start < 1) break;;

    csString reg;
    str.SubString (reg, start, end - start);
    reg.Trim ();

    switch(argument)
    {
      default: break;
      case 0: dest = reg; break;
      case 1: src1 = reg; break;
      case 2: src2 = reg; break;
      case 3: src3 = reg; break;
      case 4: src4 = reg; break;
    }
    argument ++;
    start = end + 1;
  }

  return argument;
}
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:33,代码来源:ps1_parser.cpp


示例2: LoadPrerequisiteXML

bool LoadPrerequisiteXML(csRef<psQuestPrereqOp>& prerequisite, psQuest * self, csString script)
{
    csRef<iDocumentSystem> xml = csPtr<iDocumentSystem>(new csTinyDocumentSystem);
    csRef<iDocument> doc = xml->CreateDocument();
    const char* error = doc->Parse( script );
    if ( error )
    {
        Error3("%s\n%s",error, script.GetDataSafe() );
        return false;
    }

    csRef<iDocumentNode> root    = doc->GetRoot();
    if(!root)
    {
        Error1("No XML root in prerequisite script");
        return false;
    }
    csRef<iDocumentNode> topNode = root->GetNode("pre");
    if (topNode)
    {
        return LoadPrerequisiteXML(topNode,self,prerequisite);
    }
    else
    {
        Error3("Could not find <pre> tag in prerequisite script '%s' for quest '%s'!",
               script.GetData(),(self?self->GetName():"(null)"));
        return false;
    }

    return true;
}
开发者ID:garinh,项目名称:planeshift,代码行数:31,代码来源:psquest.cpp


示例3: SaveSpell

void SpellManager::SaveSpell(Client* client, csString spellName)
{
    psSpell* spell = client->GetCharacterData()->GetSpellByName(spellName);
    if(spell)
    {
        psserver->SendSystemInfo(client->GetClientNum(),
                                 "You know the %s spell already!",spellName.GetData());
        return;
    }

    spell = cacheManager->GetSpellByName(spellName);
    if(!spell)
    {
        psserver->SendSystemInfo(client->GetClientNum(),
                                 "%s isn't a defined spell!",spellName.GetData());
        return;
    }


    client->GetCharacterData()->AddSpell(spell);

    psServer::CharacterLoader.SaveCharacterData(client->GetCharacterData(),client->GetActor());

    SendSpellBook(NULL,client);
    psserver->SendSystemInfo(client->GetClientNum(),
                             "%s added to your spell book!",spellName.GetData());
}
开发者ID:huigou,项目名称:planeshift,代码行数:27,代码来源:spellmanager.cpp


示例4: StartExchange

void pawsExchangeWindow::StartExchange( csString& player, bool withPlayer )
{
    csString text;
    if(!player.IsEmpty())
    {
        text.Format("Trading with %s",player.GetData());
    }

    int width;

    Clear();            
    Show();
            
    pawsTextBox* textBox = dynamic_cast <pawsTextBox*> (FindWidget("other_player"));
    if (textBox != NULL)
        textBox->SetText( text );

    if (withPlayer)
        width = 350;
    else
        width = 175;
    SetRelativeFrameSize(GetActualWidth(width), defaultFrame.Height());

    // Autoshow the inventory
    pawsWidget* widget = PawsManager::GetSingleton().FindWidget("SmallInventoryWindow");
    
    if (widget)
    {
        wasSmallInventoryOpen = widget->IsVisible();
        widget->Show();
    }
}        
开发者ID:garinh,项目名称:planeshift,代码行数:32,代码来源:pawsexchangewindow.cpp


示例5: ForceLoadWindowWidget

bool ZoneHandler::ForceLoadWindowWidget(bool enable, csString loadWindowName)
{
    if(enable)
    {
        //check first if the window name is valid. shouldn't end up here
        if(loadWindowName.IsEmpty())
        {
            return false;
        }
        else //if it's valid we load it and set it as load window for now
        {
            PawsManager::GetSingleton().LoadWidget(loadWindowName.GetData());

            //request the load window to update the new window
            if(loadWindow)
                loadWindow->PublishMOTD();

            return FindLoadWindow(true, loadWindowName.GetData());
        }
    }
    else //restore the pointers to the normal window and removes the specified window from the memory
    {
        //restore the ties to the default load window
        bool result = FindLoadWindow(true);
        //as we have reloaded the load window we can remove the widget we don't need anymore
        if(loadWindowName.Length())
            PawsManager::GetSingleton().RemoveWidget(loadWindowName.GetData(), false);

        return result;
    }

    return true;
}
开发者ID:Mixone-FinallyHere,项目名称:planeshift,代码行数:33,代码来源:zonehandler.cpp


示例6: HandleAnswer

    void HandleAnswer(const csString & answer)
    {
        PendingQuestion::HandleAnswer(answer);

        if ( dynamic_cast<psItem*>(item) == NULL )
        {
            Error2("Item held in PendingLootPrompt with id %u has been lost",id);
            return;
        }

        gemActor* looter = gemSupervisor->FindPlayerEntity(looterID);
        gemActor* roller = gemSupervisor->FindPlayerEntity(rollerID);

        gemActor* getter = (answer == "yes") ? looter : roller ;

        // If the getter left the world, default to the other player
        if (!getter /*|| !getter->InGroup()*/ )
        {
            getter = (answer == "yes") ? roller : looter ;

            // If the other player also vanished, get rid of the item and be done with it...
            if (!getter /*|| !getter->InGroup()*/ )
            {
                cacheManager->RemoveInstance(item);
                return;
            }
        }

        // Create the loot message
        csString lootmsg;
        lootmsg.Format("%s was %s a %s by roll winner %s",
                       lootername.GetData(),
                       (getter == looter) ? "allowed to loot" : "stopped from looting",
                       item->GetName(),
                       rollername.GetData() );

        // Attempt to give to getter
        bool dropped = getter->GetCharacterData()->Inventory().AddOrDrop(item);

        if (!dropped)
            lootmsg.Append(", but can't hold anymore");

        // Send out the loot message
        psSystemMessage loot(getter->GetClientID(), MSG_LOOT, lootmsg.GetData() );
        getter->SendGroupMessage(loot.msg);

        psLootEvent evt(
                       looteeID,
                       looteename,
                       getter->GetCharacterData()->GetPID(),
                       lootername,
                       item->GetUID(),
                       item->GetName(),
                       item->GetStackCount(),
                       (int)item->GetCurrentStats()->GetQuality(),
                       0
                       );
        evt.FireEvent();
    }
开发者ID:randomcoding,项目名称:PlaneShift-PSAI,代码行数:59,代码来源:spawnmanager.cpp


示例7: TextIsValidForOutput

bool pawsNumbersPromptWindow::TextIsValidForOutput(const csString & text)
{
    if (text.Length() == 0)
        return false;

    int number = atoi(text.GetData());
    return TextIsValidForEditing(text) && (number >= 0) && (number >= minNumber);
}
开发者ID:Chettie,项目名称:Eulora-client,代码行数:8,代码来源:pawsnumberspromptwindow.cpp


示例8: GetAllRegionNames

void psWorld::GetAllRegionNames(csString &str)
{
    str.Clear();
    for(unsigned i=0; i < regions->GetSize(); i++)
    {
        str.Append(regions->Get(i));
        str.Append("|");
    }
}
开发者ID:Mixone-FinallyHere,项目名称:planeshift,代码行数:9,代码来源:psworld.cpp


示例9: CPrintf

//-----------------------------------------------------------------------------
bool psNPCLoader::SaveToFile(int id, csString &filename)
{
    filename.Insert(0,"/this/");

    psCharacterLoader loader;
    npc = loader.LoadCharacterData(id,false);

    if(!npc)
    {
        CPrintf(CON_ERROR, "Error: Couldn't load NPC with id: %i\n",id);
        return false;
    }

    //*npc = *character;  // removed



    npcID = id;
    area  = npc->GetCharName();

    csRef<iDocumentSystem> xml;
    xml.AttachNew(new csTinyDocumentSystem);
    csRef<iDocument> doc = xml->CreateDocument();
    csRef<iDocumentNode> root = doc->CreateRoot();
    npcRoot = root->CreateNodeBefore(CS_NODE_ELEMENT);
    npcRoot->SetValue("npc");


    WriteBasicInfo();
    WriteDescription();
    WriteLocation();
    WriteStats();
    WriteMoney();
    WriteEquipment();
    WriteFactions();
    WriteSkills();
    WriteMerchantInfo();
    WriteTrainerInfo();
    WriteKnowledgeAreas();
    WriteSpecificKnowledge();

    csRef<iVFS> vfs =  csQueryRegistry<iVFS> (psserver->GetObjectReg());

    if(!vfs)
        return false;

    csString error = doc->Write(vfs, filename);
    if(!error.IsEmpty())
    {
        CPrintf(CON_ERROR, "Error writing to file %s: %s\n",filename.GetData(), error.GetData());
        return false;
    }

    return true;
}
开发者ID:Mixone-FinallyHere,项目名称:planeshift,代码行数:56,代码来源:psnpcloader.cpp


示例10: csString

csString psOperProfile::Dump(double totalConsumption, const csString & unitName)
{
    double perc = consumption/totalConsumption*100;
    if (perc > 0)
        return csString().Format(
                "count=%-5u perc=%.1lf %s=%-2i avg-%s=%.3f max=%.3f Name=%s\n",
                unsigned(count), perc, unitName.GetData(), int(consumption),
                unitName.GetData(), consumption/count, maxCons, desc.GetData());
    else
        return "";
}
开发者ID:Mixone-FinallyHere,项目名称:planeshift,代码行数:11,代码来源:psprofile.cpp


示例11: TestTarget

static inline void TestTarget(csString& targetDesc, int32_t targetType,
                              enum TARGET_TYPES type, const char* desc)
{
    if (targetType & type)
    {
        if (targetDesc.Length() > 0)
        {
            targetDesc.Append((targetType > (type * 2)) ? ", " : ", or ");
        }
        targetDesc.Append(desc);
    }
}
开发者ID:garinh,项目名称:planeshift,代码行数:12,代码来源:client.cpp


示例12: ParseColor

// converts hexadecimal string to color in current pixel format
int ParseColor(const csString &str, iGraphics2D* g2d)
{
    int r, g, b;

    if(str.Length() != 6)
        return false;

    r = HexToDec8(str.GetAt(0), str.GetAt(1));
    g = HexToDec8(str.GetAt(2), str.GetAt(3));
    b = HexToDec8(str.GetAt(4), str.GetAt(5));

    return g2d->FindRGB(r, g, b);
}
开发者ID:Mixone-FinallyHere,项目名称:planeshift,代码行数:14,代码来源:pawstree.cpp


示例13: Dequip

bool psCharAppearance::Dequip(csString& slotname,
                              csString& mesh,
                              csString& part,
                              csString& subMesh,
                              csString& texture)
{
    
    //look Equip() for more informations on this: bracers must be managed separately
    
    if (slotname == "bracers")
    {
        for(unsigned int position = 0; position < bracersSlotCount; position++)
            Dequip(BracersSlots[position], mesh, part, subMesh, texture);
        return true;
    }

    if ( slotname == "helm" )
    {
         ShowHair(true);
    }

    if ( mesh.Length() )
    {
        ClearEquipment(slotname);
        Detach(slotname);
    }

    // This is a part mesh (ie Mesh) set default mesh for that part.

    if ( subMesh.Length() )
    {
        DefaultMesh(part);
    }

    if ( part.Length() )
    {
        if ( texture.Length() )
        {
            ChangeMaterial(part, texture);
        }
        else
        {
            DefaultMaterial(part);
        }
        DefaultMaterial(part);
    }

    ClearEquipment(slotname);

    return true;
}
开发者ID:garinh,项目名称:planeshift,代码行数:51,代码来源:charapp.cpp


示例14: ConstructPath

bool AssetManager::LoadAsset (const csString& normpath, const csString& file, const csString& mount,
    iCollection* collection)
{
  csRef<iString> path;
  if (!normpath.IsEmpty ())
  {
    csRef<scfStringArray> fullPath = ConstructPath ();
    path = FindAsset (fullPath, normpath, file);
    if (!path)
      return Error ("Cannot find asset '%s' in the asset path!\n", normpath.GetData ());
  }

  csString rmount;
  if (mount.IsEmpty ())
  {
    rmount.Format ("/assets/__mnt_%d__/", mntCounter);
    mntCounter++;
  }
  else
  {
    rmount = mount;
  }

  if (path)
  {
    vfs->Mount (rmount, path->GetData ());
    printf ("Mounting '%s' to '%s'\n", path->GetData (), rmount.GetData ());
    fflush (stdout);
  }

  vfs->PushDir (rmount);
  // If the file doesn't exist we don't try to load it. That's not an error
  // as it might be saved later.
  bool exists = vfs->Exists (file);
  vfs->PopDir ();
  if (exists)
  {
    if (!LoadLibrary (rmount, file, collection))
      return false;
  }
  else
  {
    Warn ("Warning! File '%s/%s' does not exist!\n",
	(!path) ? rmount.GetData () : path->GetData (), file.GetData ());
  }

  //if (!path.IsEmpty ())
    //vfs->Unmount (rmount, path);
  return true;
}
开发者ID:Dracophoenix1,项目名称:ares,代码行数:50,代码来源:assetmanager.cpp


示例15: cmd

void psCommandManager::BuildXML(int securityLevel, csString &dest, bool subscribe)
{
    CommandGroup* grp = commandGroups.Get(securityLevel, NULL);
    if(!grp)
        return;

    dest.AppendFmt("<subscribe value='%s' />", subscribe ? "true":"false");

    for(size_t z = 0; z < grp->commands.GetSize(); z++)
    {
        csString cmd(grp->commands[z].GetData());
        if(cmd.GetAt(0) == '/')   // Make a list of the commands, but leave out the specials
            dest.AppendFmt("<command name='%s' />", cmd.GetData());
    }
}
开发者ID:Mixone-FinallyHere,项目名称:planeshift,代码行数:15,代码来源:commandmanager.cpp


示例16: AddToPathEnv

static inline bool AddToPathEnv (csString dir, csString& pathEnv)
{
  // check if installdir is in the path.
  bool gotpath = false;

  size_t dlen = dir.Length();
  // csGetInstallDir() might return "" (current dir)
  if (dlen != 0)
  {
    ToLower (dir);
  
    if (!pathEnv.IsEmpty())
    {
      csString mypath (pathEnv);
      ToLower (mypath);

      const char* ppos = strstr (mypath.GetData(), dir);
      while (!gotpath && ppos)
      {
        const char* npos = strchr (ppos, ';');
        size_t len = npos ? npos - ppos : strlen (ppos);

        if ((len == dlen) || (len == dlen+1))
        {
          if (ppos[len] == '\\') len--;
	  if (!strncmp (ppos, dir, len))
	  {
	    // found it
	    gotpath = true;
	  }
        }
        ppos = npos ? strstr (npos+1, dir) : 0;
      }
    }

    if (!gotpath)
    {
      // put CRYSTAL path into PATH environment.
      csString newpath;
      newpath.Append (dir);
      newpath.Append (";");
      newpath.Append (pathEnv);
      pathEnv = newpath;
      return true;
    }
  }
  return false;
}
开发者ID:garinh,项目名称:cs,代码行数:48,代码来源:win32.cpp


示例17: DebugDumpContents

void ProximityList::DebugDumpContents(csString& out)
{
    size_t x;
    csString temp;

    temp.AppendFmt("I represent client %d\n",clientnum);
    temp.AppendFmt("I am publishing updates to:\n");
    
    for (x = 0; x < objectsThatWatchMe.GetSize(); x++ )
    {
        temp.AppendFmt( "\tClient %d (%s), range %1.2f min_range %.2f\n",
                objectsThatWatchMe[x].client,
                ((gemObject*)(objectsThatWatchMe[x].object))->GetName(),
                        objectsThatWatchMe[x].dist,
                        objectsThatWatchMe[x].min_dist);
    }

    if (clientnum)
    {
        temp.Append( "I am listening to:\n");
        for (x = 0; x < objectsThatIWatch.GetSize(); x++ )
        {
            gemObject * obj = objectsThatIWatch[x];
            
            temp.AppendFmt("\t%-3d %s\n", obj->GetEID().Unbox(), obj->GetName());
        }
    }
    else
    {
        temp.Append("I am not a human player, so I don't subscribe to other entities.\n");
    }
    out.Append(temp);
}
开发者ID:randomcoding,项目名称:PlaneShift-PSAI,代码行数:33,代码来源:psproxlist.cpp


示例18: ReportClient

void psServerStatusRunEvent::ReportClient(Client * curr, ClientStatusLogger & clientLogger, csString & reportString)
{
    if (curr->IsSuperClient() || !curr->GetActor()) 
        return;

    const psCharacter *chr = curr->GetCharacterData();
    // log this client's info with the clientLogger
    clientLogger.LogClientInfo(curr);

    psGuildInfo *guild = curr->GetActor()->GetGuild();
    csString guildTitle;
    csString guildName;
    if (guild && guild->id && !guild->IsSecret())
    {
        psGuildLevel *level = curr->GetActor()->GetGuildLevel();
        if (level)
        {
            guildTitle = EscpXML(level->title);
        }
        guildName = EscpXML(guild->name);
    }
    
    reportString.AppendFmt("<player name=\"%s\" characterID=\"%u\" guild=\"%s\" title=\"%s\" security=\"%d\" kills=\"%u\" deaths=\"%u\" suicides=\"%u\" pos_x=\"%.2f\" pos_y=\"%.2f\" pos_z=\"%.2f\" sector=\"%s\" />\n",
                           EscpXML(curr->GetName()).GetData(), chr->GetPID().Unbox(), guildName.GetDataSafe(), guildTitle.GetDataSafe(), curr->GetSecurityLevel(), chr->GetKills(), chr->GetDeaths(), chr->GetSuicides(), chr->location.loc.x, chr->location.loc.y, chr->location.loc.z, EscpXML(chr->location.loc_sector->name).GetData());
}
开发者ID:garinh,项目名称:planeshift,代码行数:25,代码来源:serverstatus.cpp


示例19: ParseFile

csRef<iDocument> ParseFile(iObjectRegistry* object_reg, const csString & name)
{
    csRef<iVFS> vfs;
    csRef<iDocumentSystem>  xml;
    csRef<iDocument> doc;
    const char* error;
    
    vfs =  csQueryRegistry<iVFS > ( object_reg);
    assert(vfs);
    csRef<iDataBuffer> buff = vfs->ReadFile(name);
    if (buff == NULL)
    {
        //Error2("Could not find file: %s", name.GetData());
        return NULL;
    }
    xml =  csQueryRegistry<iDocumentSystem> (object_reg);
    if (!xml.IsValid())
        xml.AttachNew(new csTinyDocumentSystem);
    assert(xml);
    doc = xml->CreateDocument();
    assert(doc);
    error = doc->Parse( buff );
    if ( error )
    {
        Error3("Parse error in %s: %s", name.GetData(), error);
        return NULL;
    }
    return doc;    
}
开发者ID:Chettie,项目名称:Eulora-client,代码行数:29,代码来源:psxmlparser.cpp


示例20: AddWindow

void pawsControlWindow::AddWindow(csString wndName, csString btnName)
{
    WBName newName;
    pawsButton* btn = (pawsButton*)FindWidget(btnName.GetData());

    if (!btn)
    {
        printf("Couldn't find button %s!\n",btnName.GetData());
        return;
    }

    newName.buttonName = btnName;
    newName.windowName = wndName;
    newName.id = btn->GetID();
    wbs.Push(newName);
}
开发者ID:garinh,项目名称:planeshift,代码行数:16,代码来源:pawscontrolwindow.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cstring类代码示例发布时间:2022-05-31
下一篇:
C++ csRef类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap