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


C++ csString类代码示例

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


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


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