本文整理汇总了C++中JString::GetSubstring方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::GetSubstring方法的具体用法?C++ JString::GetSubstring怎么用?C++ JString::GetSubstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::GetSubstring方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetX
void
GDBPlot2DCommand::HandleSuccess
(
const JString& data
)
{
JArray<JFloat>* x = GetX();
JArray<JFloat>* y = GetY();
if ((GetLastResult()).BeginsWith("error,msg=\"No symbol"))
{
x->RemoveAll();
y->RemoveAll();
return;
}
const JIndex count = x->GetElementCount();
JIndex i;
JIndexRange r;
JArray<JIndexRange> matchRange1, matchRange2;
JString v1, v2;
for (i=1; i<=count; i++)
{
if (!prefixPattern.MatchAfter(data, r, &matchRange1))
{
break;
}
r = matchRange1.GetElement(1);
if (!prefixPattern.MatchAfter(data, r, &matchRange2))
{
break;
}
r = matchRange2.GetElement(1);
v1 = data.GetSubstring(matchRange1.GetElement(2));
v1.TrimWhitespace();
v2 = data.GetSubstring(matchRange2.GetElement(2));
v2.TrimWhitespace();
JFloat x1, y1;
if (!v1.ConvertToFloat(&x1) ||
!v2.ConvertToFloat(&y1))
{
break;
}
x->SetElement(i, x1);
y->SetElement(i, y1);
}
if (i <= count)
{
const JSize delta = count - (i-1);
x->RemoveNextElements(count - delta + 1, delta);
y->RemoveNextElements(count - delta + 1, delta);
}
}
示例2:
JBoolean
JSplitPathAndName
(
const JCharacter* fullName,
JString* path,
JString* name
)
{
assert( !JStringEmpty(fullName) );
JString pathAndName = fullName;
assert( pathAndName.GetLastCharacter() != ACE_DIRECTORY_SEPARATOR_CHAR );
JIndex i;
if (pathAndName.LocateLastSubstring(ACE_DIRECTORY_SEPARATOR_STR, &i))
{
*path = pathAndName.GetSubstring(1,i);
*name = pathAndName.GetSubstring(i+1, pathAndName.GetLength());
JCleanPath(path);
return kJTrue;
}
else
{
*path = JGetCurrentDirectory();
*name = pathAndName;
return kJFalse;
}
}
示例3: BeginsWith
inline JBoolean
jTranslateRemoteToLocal1
(
const JCharacter* host,
const JString& remotePath,
const JCharacter* mountDev,
const JCharacter* mountDir,
JString* localPath
)
{
const JString dev = mountDev;
JIndex hostEndIndex;
if (dev.LocateSubstring(":/", &hostEndIndex) && hostEndIndex > 1)
{
JString h = dev.GetSubstring(1, hostEndIndex-1);
jGetFullHostName(&h);
JString p = dev.GetSubstring(hostEndIndex+1, dev.GetLength());
JAppendDirSeparator(&p); // force complete name when check BeginsWith()
if (host == h && remotePath.BeginsWith(p))
{
*localPath = remotePath;
localPath->ReplaceSubstring(1, p.GetLength()-1, mountDir);
JCleanPath(localPath);
return kJTrue;
}
}
return kJFalse;
}
示例4: if
void
GMMIMEParser::ParseContentParameters
(
const JString& text,
JPtrArray<JString>* strings
)
{
JString tmp = text;
JString* str;
JIndex findex;
while (tmp.LocateSubstring("=", &findex) && findex > 1)
{
str = new JString(tmp.GetSubstring(1, findex - 1));
assert(str != NULL);
str->TrimWhitespace();
str->ToLower();
strings->Append(str);
tmp.RemoveSubstring(1, findex);
tmp.TrimWhitespace();
// now we need to get the corresponding value.
// we need to check for quotes first.
JIndex index = 1;
if (tmp.GetLength() > 1 && tmp.GetCharacter(1) == '\"')
{
FindStringEnd(tmp, &index);
str = new JString(tmp.GetSubstring(2, index-1));
assert(str != NULL);
if (tmp.LocateSubstring(";", &findex))
{
tmp.RemoveSubstring(1, findex);
}
}
else if (tmp.LocateSubstring(";", &index))
{
str = new JString();
assert(str != NULL);
if (index > 1)
{
*str = tmp.GetSubstring(1, index-1);
}
tmp.RemoveSubstring(1, index);
}
else
{
str = new JString(tmp);
assert(str != NULL);
}
str->TrimWhitespace();
strings->Append(str);
tmp.TrimWhitespace();
}
}
示例5: r
inline JBoolean
jTranslateLocalToRemote1
(
const JString& localPath,
const JCharacter* mountDev,
const JCharacter* mountDir,
JBoolean* found,
JString* host,
JString* remotePath
)
{
if (!JIsSamePartition(localPath, mountDir))
{
return kJFalse;
}
const JString dev = mountDev;
JIndex hostEndIndex;
if (dev.LocateSubstring(":/", &hostEndIndex) && hostEndIndex > 1)
{
*host = dev.GetSubstring(1, hostEndIndex-1);
#ifdef _J_CYGWIN
if (host->GetLength() == 1 &&
'A' <= host->GetFirstCharacter() && host->GetFirstCharacter() <= 'Z')
{
*host = JGetHostName();
*remotePath = localPath;
JCleanPath(remotePath);
*found = kJTrue;
return kJTrue;
}
#endif
jGetFullHostName(host);
*remotePath = dev.GetSubstring(hostEndIndex+1, dev.GetLength());
JAppendDirSeparator(remotePath);
// use JIndexRange to allow empty
JIndexRange r(strlen(mountDir)+1, localPath.GetLength());
*remotePath += localPath.GetSubstring(r);
JCleanPath(remotePath);
*found = kJTrue;
}
return kJTrue;
}
示例6:
JXPSPrintSetupDialog*
CBPSPrinter::CreatePrintSetupDialog
(
const Destination destination,
const JCharacter* printCmd,
const JCharacter* fileName,
const JBoolean collate,
const JBoolean bw
)
{
assert( itsCBPrintSetupDialog == NULL );
if (itsFontSize == kUnsetFontSize)
{
JString fontName;
CBGetPrefsManager()->GetDefaultFont(&fontName, &itsFontSize);
JArray<JIndexRange> matchList;
if (nxmRegex.Match(fontName, &matchList))
{
const JString hStr = fontName.GetSubstring(matchList.GetElement(2));
const JBoolean ok = hStr.ConvertToUInt(&itsFontSize);
assert( ok );
itsFontSize--;
}
}
itsCBPrintSetupDialog =
CBPSPrintSetupDialog::Create(destination, printCmd, fileName,
collate, bw, itsFontSize,
(CBGetPTTextPrinter())->WillPrintHeader());
return itsCBPrintSetupDialog;
}
示例7: JSetPermissions
JError
JCreateDirectory
(
const JCharacter* dirName,
const mode_t mode
)
{
if (JDirectoryExists(dirName))
{
return JSetPermissions(dirName, mode);
}
JString path = dirName;
JCleanPath(&path);
JAppendDirSeparator(&path);
JString dir;
JIndex slashIndex = 2;
while (path.LocateNextSubstring("/", &slashIndex))
{
dir = path.GetSubstring(1, slashIndex);
if (!JDirectoryExists(dir))
{
const JError err = JMkDir(dir, mode);
if (!err.OK())
{
return err;
}
}
slashIndex++; // move past the slash we found
}
return JNoError();
}
示例8:
JBoolean
JDirInfo::BuildRegexFromWildcardFilter
(
const JCharacter* origFilterStr,
JString* regexStr
)
{
regexStr->Clear();
JString filterStr = origFilterStr;
filterStr.TrimWhitespace();
if (filterStr.IsEmpty())
{
return kJFalse;
}
JIndex index;
while (filterStr.LocateSubstring(" ", &index))
{
assert( index > 1 );
const JString str = filterStr.GetSubstring(1, index-1);
AppendRegex(str, regexStr);
filterStr.RemoveSubstring(1, index);
filterStr.TrimWhitespace();
}
assert( !filterStr.IsEmpty() );
AppendRegex(filterStr, regexStr);
return kJTrue;
}
示例9:
JBoolean
CBHTMLStyler::GetXMLStyle
(
const JString& tagName,
JFontStyle* style
)
{
JIndex i;
if (!tagName.LocateLastSubstring(":", &i))
{
return kJFalse;
}
// tag name takes priority over XML namespaces
JString s;
if (i < tagName.GetLength())
{
s = tagName.GetSubstring(i+1, tagName.GetLength());
if (GetWordStyle(s, style))
{
itsLatestTagName = s;
return kJTrue;
}
}
do
{
s = tagName.GetSubstring(1, i);
if (GetWordStyle(s, style))
{
itsLatestTagName = s;
return kJTrue;
}
i--; // skip past the one we found
}
while (itsLatestTagName.LocatePrevSubstring(":", &i));
return kJFalse;
}
示例10: if
JBoolean
SplitClassNameAndArgs
(
const JString& str,
JString* name,
JString* args
)
{
JIndex i;
const JBoolean hasArgs = str.LocateSubstring("(", &i);
if (hasArgs && 1 < i && i < str.GetLength())
{
*name = str.GetSubstring(1, i-1);
*args = str.GetSubstring(i+1, str.GetLength());
name->TrimWhitespace();
args->TrimWhitespace();
return kJTrue;
}
else if (hasArgs && i == 1)
{
cerr << "No class name in " << str << endl;
name->Clear();
args->Clear();
return kJFalse;
}
else
{
if (hasArgs)
{
*name = str.GetSubstring(1, i-1);
}
else
{
*name = str;
}
name->TrimWhitespace();
args->Clear();
return kJTrue;
}
}
示例11: JGetHostName
inline void
jGetFullHostName
(
JString* host
)
{
if (!host->Contains("."))
{
const JString localhost = JGetHostName();
JIndex dotIndex;
if (localhost.LocateSubstring(".", &dotIndex))
{
*host += localhost.GetSubstring(dotIndex, localhost.GetLength());
}
}
}
示例12: StartCTags
void
GFGLink::ParseClass
(
GFGClass* list,
const JCharacter* filename,
const JCharacter* classname
)
{
JBoolean ok = kJTrue;
if (itsCTagsProcess == NULL)
{
ok = StartCTags();
}
if (ok)
{
itsClassList = list;
itsCurrentClass = classname;
itsCurrentFile = filename;
JConvertToAbsolutePath(filename, "", &itsCurrentFile);
itsCurrentFile.Print(*itsOutputLink);
*itsOutputLink << std::endl;
itsOutputLink->flush();
JBoolean found = kJFalse;
JString result = JReadUntil(itsInputFD, kDelimiter, &found);
if (found)
{
JIndex findex;
while ( result.LocateSubstring("\n", &findex) &&
findex > 1)
{
JString line = result.GetSubstring(1, findex - 1);
result.RemoveSubstring(1, findex);
ParseLine(line);
}
Broadcast(FileParsed());
}
}
}
示例13:
JBoolean
SVNInfoLog::GetBaseRevision
(
JString* rev
)
{
JString s;
JArray<JIndexRange> matchList;
if (GetSelection(&s) && revisionPattern.Match(s, &matchList))
{
*rev = s.GetSubstring(matchList.GetElement(2));
return kJTrue;
}
else
{
rev->Clear();
return kJFalse;
}
}
示例14: is
JBoolean
GMMIMEParser::GetTextSegment
(
const JIndex index,
JString* text,
TextFormat* format,
JString* charset
)
{
assert(itsTextInfo != NULL);
assert(index <= itsTextInfo->GetEntryCount());
JString name = itsTextInfo->GetEntry(index).GetFullName();
std::ifstream is(name);
if (is.good())
{
JReadAll(is, text);
if (name.EndsWith(kPlainType))
{
*format = kPlain;
}
else if (name.EndsWith(kHTMLType))
{
*format = kHTML;
}
JIndex findex;
JBoolean ok = name.LocateLastSubstring(".", &findex);
assert(ok);
name.RemoveSubstring(findex, name.GetLength());
ok = name.LocateLastSubstring(".", &findex);
if (findex < name.GetLength())
{
*charset = name.GetSubstring(findex + 1, name.GetLength());
}
}
else
{
itsIsSuccessful = kJFalse;
}
return itsIsSuccessful;
}
示例15: JReadUntil
JBoolean
GAddressBookMgr::GetNextRecord
(
JString& line,
JString& record,
std::istream& is
)
{
if (line.IsEmpty())
{
return kJFalse;
}
JIndex index;
if (line.LocateSubstring("\t", &index))
{
if (index > 1)
{
record = line.GetSubstring(1, index - 1);
line.RemoveSubstring(1, index);
return kJTrue;
}
line.RemoveSubstring(1, 1);
return kJFalse;
}
record = line;
if (record.Contains("(") && !record.Contains(")"))
{
JString temp = JReadUntil(is, ')');
record += temp + ")";
line = JReadLine(is);
if (!line.IsEmpty() && (line.GetFirstCharacter() == '\t'))
{
line.RemoveSubstring(1, 1);
}
}
else
{
line.Clear();
}
return kJTrue;
}