本文整理汇总了C++中TStrV::GetVal方法的典型用法代码示例。如果您正苦于以下问题:C++ TStrV::GetVal方法的具体用法?C++ TStrV::GetVal怎么用?C++ TStrV::GetVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStrV
的用法示例。
在下文中一共展示了TStrV::GetVal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCanonicalPath
TStr TNodeJsFPath::GetCanonicalPath(const TStr& FPath) {
// Get absolute path
TStr AbsFPath = TStr::GetNrAbsFPath(FPath);
// Remove any redundancies
TStrV CanonV; AbsFPath.SplitOnAllCh('/', CanonV);
TSStack<TStr> CanonS; TStr CurrStr;
for (int ElN = 0; ElN < CanonV.Len(); ++ElN) {
CurrStr = CanonV.GetVal(ElN);
if (CurrStr == "..") {
EAssertR(!CanonS.Empty(), "Stack empty");
CanonS.Pop();
} else if (CurrStr != ".") {
CanonS.Push(CurrStr+"/");
}
}
// Assemble the canonical path (from left to right
EAssertR(!CanonS.Empty(), "Stack empty");
// We start with drive letter (Windows) or slash (Unix)
TChA CanonFPath = AbsFPath.LeftOf('/'); CanonFPath += '/';
// Get the rest of the path
for (int CanonN = CanonS.Len() - 1; CanonN >= 0; CanonN--) {
CanonFPath += CanonS[CanonN];
}
// Done
return CanonFPath;
}
示例2: listFile
void TNodeJsFs::listFile(const v8::FunctionCallbackInfo<v8::Value>& Args) {
v8::Isolate* Isolate = v8::Isolate::GetCurrent();
v8::HandleScope HandleScope(Isolate);
EAssertR(Args.Length() >= 1 && Args[0]->IsString(),
"Expected directory path as the first argument.");
// Read parameters
TStr FPath(*v8::String::Utf8Value(Args[0]->ToString()));
TStrV FExtV;
if (Args.Length() >= 2 && Args[1]->IsString()) {
FExtV.Add(TStr(*v8::String::Utf8Value(Args[1]->ToString())));
}
const bool RecurseP = Args.Length() >= 3 && Args[2]->IsBoolean() && Args[2]->BooleanValue();
// Get file list
TStrV FNmV;
TFFile::GetFNmV(FPath, FExtV, RecurseP, FNmV);
FNmV.Sort();
v8::Handle<v8::Array> FNmArr = v8::Array::New(Isolate, FNmV.Len());
for(int FldN = 0; FldN < FNmV.Len(); ++FldN) {
FNmArr->Set(v8::Integer::New(Isolate, FldN), v8::String::NewFromUtf8(Isolate, FNmV.GetVal(FldN).CStr()));
}
Args.GetReturnValue().Set(FNmArr);
}