本文整理汇总了C++中WString::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ WString::Left方法的具体用法?C++ WString::Left怎么用?C++ WString::Left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WString
的用法示例。
在下文中一共展示了WString::Left方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDirectory
WString GetDirectory(const WString& fileName)
{
int index=0;
for(int i=0;i<fileName.Length();i++)
{
if(fileName[i]==PATH_DELIMITER)
{
index=i;
}
}
return fileName.Left(index+1);
}
示例2: ReplaceAll
bool WString::ReplaceAll(const WString &findWhat,const WString &replaceWith)
{
WString process = *this;
WString result;
int pos;
bool processed = false;
while ((pos = process.Find(findWhat)) != -1)
{
result = result+process.Left(pos)+replaceWith;
process = process.Right(pos+findWhat.GetLength());
processed = true;
}
*this = result+process;
return processed;
}
示例3: ComposeTab
void FileTabs::ComposeTab(Tab& tab, const Font &font, Color ink, int style)
{
if(PaintIcons() && tab.HasIcon())
{
tab.AddImage(tab.img);
tab.AddSpace(TB_SPACEICON);
}
WString txt = IsString(tab.value) ? tab.value : StdConvert().Format(tab.value);
int extpos = txt.ReverseFind('.');
tab.AddText(extpos >= 0 ? txt.Left(extpos) : txt, font, filecolor);
if (extpos >= 0) {
tab.AddText(txt.Right(txt.GetLength() - extpos), font, extcolor);
}
}
示例4:
bool GuiSinglelineTextBox::TextElementOperatorCallback::BeforeModify(TextPos start, TextPos end, const WString& originalText, WString& inputText)
{
vint length=inputText.Length();
const wchar_t* input=inputText.Buffer();
for(vint i=0;i<length;i++)
{
if(*input==0 || *input==L'\r' || *input==L'\n')
{
length=i;
break;
}
}
if(length!=inputText.Length())
{
inputText=inputText.Left(length);
}
return true;
}
示例5: GetPathComponents
void FilePath::GetPathComponents(WString path, collections::List<WString>& components)
{
WString pathRemaining = path;
WString delimiter = Delimiter;
components.Clear();
while(true)
{
auto index = INVLOC.FindFirst(pathRemaining, delimiter, Locale::None);
if (index.key == -1)
break;
if(index.key != 0)
components.Add(pathRemaining.Left(index.key));
else
{
#if defined VCZH_GCC
// Unix absolute path starting with "/"
// components[0] will be L"/"
components.Add(delimiter);
#elif defined VCZH_MSVC
if(pathRemaining.Length() >= 2 && pathRemaining[1] == Delimiter)
{
// Windows UNC Path starting with "\\"
// components[0] will be L"\\"
components.Add(L"\\");
index.value++;
}
#endif
}
pathRemaining = pathRemaining.Right(pathRemaining.Length() - (index.key + index.value));
}
if(pathRemaining.Length() != 0)
{
components.Add(pathRemaining);
}
}
示例6: main
int main(int argc, char* argv[])
#endif
{
WString baseDirectory;
{
#if defined VCZH_MSVC
wchar_t currentDirectory[MAX_PATH]={0};
GetCurrentDirectory(MAX_PATH, currentDirectory);
baseDirectory=currentDirectory;
#elif defined VCZHGCC
char currentDirectory[1024]={0};
getcwd(currentDirectory, 1024);
baseDirectory=atow(currentDirectory);
#endif
if(baseDirectory[baseDirectory.Length()-1]!=PATH_DELIMITER)
{
baseDirectory+=PATH_DELIMITER;
}
}
Regex regexPathSplitter(L"[///\\]");
Ptr<ParsingGeneralParser> parser=CreateBootstrapStrictParser();
Console::SetTitle(L"Vczh Parser Generator for C++");
Console::SetColor(false, true, false, true);
Console::WriteLine(L"parsing>Files : "+itow(argc-1));
for(int i=1;i<argc;i++)
{
Console::WriteLine(L"------------------------------------------------------------");
#if defined VCZH_MSVC
WString inputPath=argv[i];
#elif defined VCZH_GCC
WString inputPath=atow(argv[i]);
#endif
if(inputPath.Length()<2 || inputPath[1]!=L':')
{
inputPath=baseDirectory+inputPath;
}
Console::WriteLine(L"parsing>Making : "+inputPath);
if(inputPath.Length()<11 || inputPath.Right(11)!=L".parser.txt")
{
Console::SetColor(true, false, false, true);
Console::WriteLine(L"error> The extenion name of the input file path must be \".parser.txt\".");
Console::SetColor(false, true, false, true);
}
else
{
WString name;
{
List<Ptr<RegexMatch>> matches;
regexPathSplitter.Split(inputPath, true, matches);
name=matches[matches.Count()-1]->Result().Value();
name=name.Left(name.Length()-11);
}
WString outputMetaPath=inputPath.Left(inputPath.Length()-11);
WString outputHeaderPath=outputMetaPath+L".h";
WString outputCppPath=outputMetaPath+L".cpp";
WString logPath=outputMetaPath+L".log";
Console::WriteLine(L"parsing>Output header path : "+outputHeaderPath);
Console::WriteLine(L"parsing>Output cpp path : "+outputCppPath);
Console::WriteLine(L"parsing>Log path : "+logPath);
CodegenConfig config;
WString codeGrammar;
{
FileStream fileStream(inputPath, FileStream::ReadOnly);
if(!fileStream.IsAvailable())
{
Console::SetColor(true, false, false, true);
Console::WriteLine(L"error> Cannot open \""+inputPath+L" for read.");
Console::SetColor(false, true, false, true);
goto STOP_PARSING;
}
BomDecoder decoder;
DecoderStream decoderStream(fileStream, decoder);
StreamReader reader(decoderStream);
if(!config.ReadConfig(reader))
{
goto STOP_PARSING;
}
codeGrammar=reader.ReadToEnd();
}
Ptr<ParsingDefinition> definition;
Ptr<ParsingTable> table;
{
FileStream fileStream(logPath, FileStream::WriteOnly);
if(!fileStream.IsAvailable())
{
Console::SetColor(true, false, false, true);
Console::WriteLine(L"error> Cannot open \""+logPath+L" for write.");
Console::SetColor(false, true, false, true);
goto STOP_PARSING;
}
BomEncoder encoder(BomEncoder::Utf16);
EncoderStream encoderStream(fileStream, encoder);
StreamWriter writer(encoderStream);
//.........这里部分代码省略.........