本文整理汇总了C++中SPString类的典型用法代码示例。如果您正苦于以下问题:C++ SPString类的具体用法?C++ SPString怎么用?C++ SPString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SPString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
bool SUIManager::LoadFromString( SPString stringStream )
{
SPString screensString = SPStringHelper::XMLExcludeFrom(stringStream, L"ScreenList");
stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"ScreenList");
while(screensString.size() > 0)
{
SPString screenString = SPStringHelper::XMLExcludeFrom(screensString, L"SUIScreen");
screensString = SPStringHelper::XMLRemoveFirst(screensString, L"SUIScreen");
SPString screenNameString = SPStringHelper::XMLExcludeFrom(screenString, L"Name");
SUIScreenPtr screen = new SUIScreen();
screen->SetName(screenNameString);
AddScreen(screen);
dispalyStack.push_back(screen);
screen->LoadFromString(screenString);
}
dispalyStack.clear();
SPString displayStackString = SPStringHelper::XMLExcludeFrom(stringStream, L"DisplayStack");
stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"DisplayStack");
while(displayStackString.size() > 0)
{
SPString screenNameString = SPStringHelper::XMLExcludeFrom(displayStackString, L"ScreenName");
displayStackString = SPStringHelper::XMLRemoveFirst(displayStackString, L"ScreenName");
dispalyStack.push_front(GetScreen(screenNameString));
}
return true;
}
示例2: SplitPath
void SPPathHelper::MakeSurePathExist( SPString path )
{
SPPointer<SPStringList> parts = SplitPath(path);
SPString currentDir = (*parts)[0];
for (int i = 0; i < parts->size() - 1; i++)
{
CreateDirectory(currentDir.c_str(), NULL);
currentDir = currentDir + L"\\" + (*parts)[i + 1];
}
}
示例3: length
int
SPString::rindex(const SPString & s, int offset)
{
if (offset == -1)
offset = length() - s.length();
else
offset = offset - s.length() + 1;
if (offset > length() - s.length())
offset = length() - s.length();
for (int i = offset; i >= 0; i--) {
if (strncmp(&pstr[i], s, s.length()) == 0)
return i;
}
return -1;
}
示例4: SetTitle
void SPWindow::SetTitle( SPString title )
{
modificationLock.Lock();
SetWindowText(GetHWnd(), title.c_str());
this->title = title;
modificationLock.Unlock();
}
示例5: while
bool SScriptManager::LoadFromString( SPString stringStream )
{
SPString commandsString = SPStringHelper::XMLExcludeFrom(stringStream, L"Commands");
stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"Commands");
commands.clear();
while(commandsString.size() > 0)
{
SPString commandString = SPStringHelper::XMLExcludeFrom(commandsString, L"SSC");
commandsString = SPStringHelper::XMLRemoveFirst(commandsString, L"SSC");
SPString commandName = SPStringHelper::XMLExcludeFrom(commandString, L"CN");
SPString commandArgs = SPStringHelper::XMLExcludeFrom(commandString, L"Properties");
SPString commandFile = SPStringHelper::XMLExcludeFrom(commandString, L"FN");
int commandOrder = SPStringHelper::StringToInt(SPStringHelper::XMLExcludeFrom(commandString, L"OD"));
SScriptCommand command(commandName, SScriptHelper::StringToVariables(commandArgs), commandFile, commandOrder);
commands.push_back(command);
}
SPString innerVariablesString = SPStringHelper::XMLExcludeFrom(stringStream, L"InnerVariables");
stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"InnerVariables");
innerScript->SetVariableMap(SScriptHelper::StringToVariables(innerVariablesString));
SPString outerVariablesString = SPStringHelper::XMLExcludeFrom(stringStream, L"OuterVariables");
stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"OuterVariables");
script->SetVariableMap(SScriptHelper::StringToVariables(innerVariablesString));
SPString functionsString = SPStringHelper::XMLExcludeFrom(stringStream, L"Functions");
stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"Functions");
while(functionsString.size() > 0)
{
SPString functionString = SPStringHelper::XMLExcludeFrom(functionsString, L"F");
functionsString = SPStringHelper::XMLRemoveFirst(functionsString, L"F");
SPString functionName = SPStringHelper::XMLExcludeFrom(functionString, L"N");
SPString functionScript = SPStringHelper::XMLExcludeFrom(functionString, L"S");
AddUserDefinedFunction(functionName, new ScriptStringFunction(this, functionScript));
}
return true;
}
示例6: sp_string_read_content
static void
sp_string_read_content(SPObject *object)
{
SPString *string = SP_STRING(object);
string->string.clear();
//XML Tree being used directly here while it shouldn't be.
gchar const *xml_string = string->getRepr()->content();
// see algorithms described in svg 1.1 section 10.15
if (object->xml_space.value == SP_XML_SPACE_PRESERVE) {
for ( ; *xml_string ; xml_string = g_utf8_next_char(xml_string) ) {
gunichar c = g_utf8_get_char(xml_string);
if ((c == 0xa) || (c == 0xd) || (c == '\t')) {
c = ' ';
}
string->string += c;
}
}
else {
bool whitespace = false;
for ( ; *xml_string ; xml_string = g_utf8_next_char(xml_string) ) {
gunichar c = g_utf8_get_char(xml_string);
if ((c == 0xa) || (c == 0xd)) {
continue;
}
if ((c == ' ') || (c == '\t')) {
whitespace = true;
} else {
if (whitespace && (!string->string.empty() || (object->getPrev() != NULL))) {
string->string += ' ';
}
string->string += c;
whitespace = false;
}
}
if (whitespace && object->getRepr()->next() != NULL) { // can't use SPObject::getNext() when the SPObject tree is still being built
string->string += ' ';
}
}
object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
示例7:
int
SPString::index(const SPString & s, int offset)
{
if (offset < 0)
offset = 0;
for (int i = offset; i < length(); i++) {
if (strncmp(&pstr[i], s, s.length()) == 0)
return i;
}
return -1;
}
示例8: while
bool SUIPictureManager::LoadFromString( SPString stringStream )
{
SPString picturesString = SPStringHelper::XMLExcludeFrom(stringStream, L"Pictures");
stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"Pictures");
while(picturesString.size() > 0)
{
SPString pictureString = SPStringHelper::XMLExcludeFrom(picturesString, L"SUIPL");
picturesString = SPStringHelper::XMLRemoveFirst(picturesString, L"SUIPL");
SPString propertiesString = SPStringHelper::XMLExcludeFrom(pictureString, L"Properties");
pictureString = SPStringHelper::XMLRemoveFirst(pictureString, L"Properties");
VariableMap properties = SScriptHelper::StringToVariables(propertiesString);
SScriptFunctionPtr buildPicture = new SSFPicture();
buildPicture->Function(properties, false);
SPString mixImagesString = SPStringHelper::XMLExcludeFrom(pictureString, L"MPS");
pictureString = SPStringHelper::XMLRemoveFirst(pictureString, L"MPS");
SScriptFunctionPtr mixPicture = new SSFMixPicture();
while(mixImagesString.size() > 0)
{
SPString mixImageString = SPStringHelper::XMLExcludeFrom(mixImagesString, L"SUIMI");
mixImagesString = SPStringHelper::XMLRemoveFirst(mixImagesString, L"SUIMI");
VariableMap miProperties = SScriptHelper::StringToVariables(mixImageString);
mixPicture->Function(miProperties, false);
}
}
SPString currentPictureString = SPStringHelper::XMLExcludeFrom(stringStream, L"CurrentPictureName");
stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"CurrentPictureName");
currentPicture = GetPicture(currentPictureString);
return true;
}
示例9: _wtmpnam_s
bool SPInputManager::SetCursor( SPString path )
{
SPFilePtr file = SPFileManager::GetSingleton().OpenFile(path);
if (!file)
{
return false;
}
LONGLONG length = file->GetFileLength();
char* pData = new char[length];
file->Read(pData, length);
wchar_t tname[10];
_wtmpnam_s(tname, 10);
SPString name = SPString(tname);// + path.substr(path.find_last_of(L".") + 1);
HANDLE newFile = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (newFile == INVALID_HANDLE_VALUE)
{
return false;
}
DWORD numOfByte;
if(FALSE == WriteFile(newFile, pData, length, &numOfByte, NULL))
{
delete [] pData;
SPFileManager::GetSingleton().CloseFile(path);
CloseHandle(newFile);
DeleteFile(name.c_str());
return false;
}
CloseHandle(newFile);
HCURSOR cursor = LoadCursorFromFile(name.c_str());
if (!cursor)
{
DWORD err = GetLastError();
delete [] pData;
SPFileManager::GetSingleton().CloseFile(path);
CloseHandle(newFile);
DeleteFile(name.c_str());
return false;
}
SPWindow::GetSingleton().SetCursor(cursor);
DeleteFile(name.c_str());
delete [] pData;
SPFileManager::GetSingleton().CloseFile(path);
//CloseHandle(newFile);
return true;
}
示例10: CreatePath
bool SPFileHelper::CreatePath( SPString path )
{
if (path.size() == 0 || path == L"/" || path == L"\\")
{
return true;
}
if(IsPathExists(path.c_str()))
{
return true;
}
if(!CreatePath(GetUpperPath(path)))
{
return false;
}
if( FALSE == CreateDirectory(path.c_str(), NULL))
{
return false;
}
return true;
}
示例11: GetUpperPath
SPString SPFileHelper::GetUpperPath( SPString path )
{
SPString result1 = L"";
SPString result2 = L"";
if (path.find_last_of(L"\\") != wstring::npos)
{
result2 = path.substr(0, path.find_last_of(L"\\"));
}
if (path.find_last_of(L"/") != wstring::npos)
{
result1 = path.substr(0, path.find_last_of(L"/"));
}
return result1.size() > result2.size() ? result1 : result2;
}
示例12: Load
bool SPFont::Load(
INT Height,
UINT Width,
UINT Weight,
UINT MipLevels,
BOOL Italic,
DWORD CharSet,
DWORD OutputPrecision,
DWORD Quality,
DWORD PitchAndFamily,
SPString FontName )
{
float rate = SPFontManager::GetSingleton().GetSizeRate();
if (FAILED(D3DXCreateFont(
SPDevice::GetSingleton().GetD3DDevice(),
Height * rate , Width * rate, Weight, MipLevels, Italic,
CharSet, OutputPrecision, Quality,
PitchAndFamily, FontName.c_str(), &font)))
{
return false;
}
//D3DXFONT_DESCA des;
//Font->GetDescA(&des);
width = Width;
height = Height;
weight = Weight;
italic = Italic == TRUE;
miplevel = MipLevels;
name = FontName;
return true;
}
示例13: IsPathExists
bool SPFileHelper::IsPathExists( SPString path )
{
return TRUE == PathFileExists(path.c_str());
}
示例14: main
int main(int argc, char **argv)
{
char c, *infn;
ifstream ini("\\win3\\win.ini");
ofstream fout("t.sty");
int ln= 0;
SPString w;
SPStringList l;
SPStringList ttfonts;
Assoc<SPString> repfnts("", ""); // saves font replacement names
if(argc < 2) infn= "test.sty";
else infn= argv[1];
ifstream fin(infn);
if(!ini){
cerr << "Can't open \\win3\\win.ini" << endl;
exit(1);
}
if(!fin){
cerr << "Can't open " << infn << endl;
exit(1);
}
if(!fout){
cerr << "Can't open t.sty for write" << endl;
exit(1);
}
cout << "Reading in truetype fonts" << endl;
while(ini >> w){ // find the [fonts] section
if(w.m("\\[fonts\\]")) break;
}
// cout << buf << endl;
if(!ini.good()){ // checks all file state
cerr << "Couldn't find [fonts] section in win.ini" << endl;
exit(1);
}
// make a list of truetype fonts
Regexp r1("^([a-zA-Z ]+) \\(([a-zA-Z ]+)\\)=");
Regexp r2("^TrueType$");
Regexp r3("\\[.*\\]");
while(ini >> w){
if(w.m(r3)) break; // found the start of another section
if(w.m(r1, l) != 3) continue; // ignore this line
// cout << "Font match:" << l[1] << ", " << l[2] << endl;
if(l[2].m(r2)){
ttfonts.push(l[1]);
}
}
cout << "ttfonts: " << endl << ttfonts << endl;
ini.close();
cout << "Looking for non-truetype fonts" << endl;
SPString s, fnt, newfnt;
SPStringList sl;
while(fin >> s){
ln++;
// cout << "line " << ln << ": <" << s << ">" << endl;
if(s.m("\\[fnt\\]")){
fout << s << endl; // write out [fnt] line
// read next line which should have font in it
if(!(fin >> s)){
cerr << "Error reading font line " << ln << endl;
exit(1);
}
ln++;
fnt= s.split("' '").join(" "); // This trims whitespace
// cout << "font name: <" << fnt << ">" << endl;
if(!ttfonts.grep("^" + fnt + "$", "i")){ // not a truetype font
int pos= s.index(fnt); // get position in string of font
if(pos < 0){
cerr << "Couldn't find <" << fnt << "> in string <" << s << "> line " << ln << endl;
exit(1);
}
// See if we already know what to exchange it with
if(repfnts.isin(fnt)) // just replace it
s.substr(pos, strlen(fnt)) = repfnts(fnt);
else{ // need to ask what the new font name will be
do{
cout << "Replace font <" << fnt << "> with:"; cout.flush();
cin >> newfnt;
if(!(sl=ttfonts.grep("^" + newfnt + "$", "i"))){
cerr << "<" << newfnt << "> is not a valid font" << endl;
continue;
}
break;
}while(1);
s.substr(pos, strlen(fnt)) = sl[0]; // replace it
repfnts(fnt) = sl[0]; // remember for next time
//.........这里部分代码省略.........
示例15: getline
#include <iostream.h>
#include <fstream.h>
#include "splash.h"
#include "tracer.h"
#ifdef _Windows
#include "../win/debugwin/debugstr.h"
#define OUTSTREAM dout
#else
#define OUTSTREAM cout
#endif
ifstream fin;
// Globals
SPString curln, curclass;
int bcnt; // current brace count
/*
* Reads in a line, and eliminates anything in between comments
* or quotes. Also keeps count of the brace level
*/
int getline()
{
LTRACER("getline", 4)
if(!(fin >> curln)) return 0;
cout << curln << endl;
LTRACE(2, curln)
while(curln.m("\".*\"")){ // remove anything in quoted strings
int o, c;