本文整理汇总了C++中JString::ReplaceSubstring方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::ReplaceSubstring方法的具体用法?C++ JString::ReplaceSubstring怎么用?C++ JString::ReplaceSubstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::ReplaceSubstring方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
XDLink::SendRaw
(
const JCharacter* text
)
{
if (itsLink != NULL)
{
JString s = text;
s.TrimWhitespace();
JIndex i;
while (s.LocateSubstring(" ", &i))
{
s.ReplaceSubstring(i, i+1, " ");
}
itsLink->SendMessage(s);
itsLink->StartTimer();
if (!itsDebuggerBusyFlag)
{
itsDebuggerBusyFlag = kJTrue;
Broadcast(DebuggerBusy());
}
Broadcast(DebugOutput(s, kCommandType));
}
}
示例2: JGetString
void
CMEditPrefsDialog::ChooseDebugger
(
const JCharacter* name,
JXInputField* input
)
{
const JCharacter* map[] =
{
"name", name
};
const JString prompt = JGetString("ChooseDebuggerPrompt::CMEditPrefsDialog", map, sizeof(map));
JString fullName;
if ((JGetChooseSaveFile())->ChooseFile(prompt, "", &fullName))
{
JString text = input->GetText();
JIndex i;
if (text.LocateSubstring(" ", &i))
{
text.ReplaceSubstring(1, i-1, fullName);
}
else
{
text = fullName;
}
input->SetText(text);
}
}
示例3: input
void
GDBGetSourceFileList::HandleSuccess
(
const JString& origData
)
{
if (origData.BeginsWith("Source files for which symbols have been read in:"))
{
(JXGetApplication())->DisplayBusyCursor();
JXFileListTable* table = (GetFileList())->GetTable();
table->RemoveAllFiles();
JString data = origData;
JIndex i,j;
while (data.LocateSubstring("Source files for which symbols", &i))
{
j = i;
if (!data.LocateNextSubstring(":", &j))
{
j = data.GetLength();
}
data.ReplaceSubstring(i, j, ",");
}
data.TrimWhitespace(); // no comma after last file
std::istrstream input(data.GetCString(), data.GetLength());
JString fullName, path, name, s;
JBoolean foundDelimiter;
do
{
input >> ws;
fullName = JReadUntil(input, ',', &foundDelimiter);
fullName.TrimWhitespace();
if (!fullName.IsEmpty())
{
JSplitPathAndName(fullName, &path, &name);
table->AddFile(name);
}
}
while (foundDelimiter);
}
示例4: JString
void
XDLink::SendMedicCommand
(
CMCommand* command
)
{
command->Starting();
JString arg = " -i ";
arg += JString(command->GetTransactionID(), JString::kBase10);
JString s = command->GetCommand();
JIndex i;
if (s.LocateSubstring("@i", &i))
{
s.ReplaceSubstring(i, i+1, arg);
}
else
{
s += arg;
}
SendRaw(s);
}
示例5: if
void
CBCompileDocument::AppendText
(
const JString& origText
)
{
const JString* text = &origText;
JBoolean deleteText = kJFalse;
if (strchr(*text, kMultibyteMarker) != NULL)
{
JString* s = jnew JString(origText);
assert( s != NULL );
text = s;
deleteText = kJTrue;
JSize length = s->GetLength();
for (JIndex i=1; i<=length; i++)
{
if (s->GetCharacter(i) == kMultibyteMarker && i <= length-2)
{
const unsigned char c1 = s->GetCharacter(i+1);
const unsigned char c2 = s->GetCharacter(i+2);
const JIndex u = (((unsigned int) (unsigned char) c1) << 8) |
((unsigned int) (unsigned char) c2);
if (u == 32920 || u == 32921)
{
s->ReplaceSubstring(i, i+2, "'");
}
else
{
std::cout << "jcc: AppendText: unicode: " << u << std::endl;
s->ReplaceSubstring(i, i+2, "\x80");
}
length -= 2;
}
}
}
const JBoolean isJavacError = javacOutputRegex.Match(*text);
JIndexRange gccPrevLineRange, gccRange;
const JBoolean isGCCError = JI2B(!isJavacError && gccErrorRegex.Match(*text, &gccRange));
JIndexRange flexRange;
const JBoolean isFlexError = flexErrorRegex.Match(*text, &flexRange);
JIndexRange bisonRange;
const JBoolean isBisonError = bisonErrorRegex.Match(*text, &bisonRange);
JIndexRange makeRange;
const JBoolean isMakeError = JI2B(
makeErrorRegex.Match(*text, &makeRange) && !text->EndsWith(makeIgnoreErrorStr) );
JArray<JIndexRange> absoftRangeList;
const JBoolean isAbsoftError = absoftErrorRegex.Match(*text, &absoftRangeList);
JArray<JIndexRange> maven2RangeList;
const JBoolean isMaven2Error = maven2ErrorRegex.Match(*text, &maven2RangeList);
JArray<JIndexRange> maven3RangeList;
const JBoolean isMaven3Error = maven3ErrorRegex.Match(*text, &maven3RangeList);
if (isGCCError &&
gccErrorRegex.Match(itsPrevLine, &gccPrevLineRange) &&
gccPrevLineRange == gccRange &&
JCompareMaxN(itsPrevLine, *text, gccRange.last, kJTrue))
{
JString s = *text;
s.RemoveSubstring(1, gccRange.last - 1);
s.Prepend(" /");
// in front of 1 or 2 trailing newlines
CBTextEditor* te = GetTextEditor();
te->SetCaretLocation(te->GetTextLength() - (theDoubleSpaceFlag ? 1 : 0));
te->Paste(s);
}
else if (!isJavacError && !isGCCError &&
gccErrorRegex.Match(itsPrevLine, &gccPrevLineRange) &&
text->BeginsWith(gccMultilinePrefix) &&
text->GetLength() > kGCCMultilinePrefixLength &&
!isspace(text->GetCharacter(kGCCMultilinePrefixLength+1)))
{
JString s = *text;
s.RemoveSubstring(1, strlen(gccMultilinePrefix));
CBTextEditor* te = GetTextEditor();
te->SetCaretLocation(te->GetTextLength() - (theDoubleSpaceFlag ? 1 : 0));
te->Paste(s);
}
else
{
CBTextEditor* te = GetTextEditor();
const JIndex startIndex = te->GetTextLength() + 1;
CBExecOutputDocument::AppendText(*text);
if (theDoubleSpaceFlag)
{
//.........这里部分代码省略.........
示例6: if
void
CBShellEditor::HandleKeyPress
(
const int key,
const JXKeyModifiers& modifiers
)
{
const JBoolean controlOn = modifiers.control();
const JBoolean metaOn = modifiers.meta();
const JBoolean shiftOn = modifiers.shift();
if ((key == kJLeftArrow && metaOn && !controlOn && !shiftOn) ||
(key == JXCtrl('A') && controlOn && !metaOn && !shiftOn))
{
const JIndex index = GetInsertionIndex();
const JRunArray<Font>& styles = GetStyles();
if (index > 1 && styles.GetElement(index-1) == GetDefaultFont())
{
JIndex runIndex, firstIndexInRun;
const JBoolean ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun);
SetCaretLocation(firstIndexInRun);
return;
}
}
if (key == kJReturnKey)
{
SetCurrentFont(itsInsertFont);
}
else
{
SetCurrentFont(GetDefaultFont());
}
JBoolean sentCmd = kJFalse;
if (key == kJReturnKey && !modifiers.shift() && !HasSelection())
{
JIndex index;
JBoolean ok = GetCaretLocation(&index);
assert( ok );
JString cmd;
const JRunArray<Font>& styles = GetStyles();
if (index > 1 && styles.GetElement(index-1) == GetDefaultFont())
{
JIndex runIndex, firstIndexInRun;
ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun);
const JIndex endIndex = firstIndexInRun + styles.GetRunLength(runIndex);
cmd = (GetText()).GetSubstring(firstIndexInRun, endIndex - 1);
SetCaretLocation(endIndex);
if (cmd.BeginsWith("man "))
{
cmd.ReplaceSubstring(1, 4, "jcc --man ");
}
else if (cmd.BeginsWith("apropos "))
{
cmd.ReplaceSubstring(1, 8, "jcc --apropos ");
}
else if (cmd.BeginsWith("vi "))
{
cmd.ReplaceSubstring(1, 3, "jcc ");
}
else if (cmd.BeginsWith("less ") || cmd.BeginsWith("more "))
{
cmd.ReplaceSubstring(1, 5, "jcc ");
}
else if (cmd == "more" || cmd == "less" || cmd == "vi")
{
cmd = "jcc";
}
}
cmd += "\n";
itsShellDoc->SendCommand(cmd);
sentCmd = kJTrue;
}
CBTextEditor::HandleKeyPress(key, modifiers);
if (sentCmd)
{
itsInsertIndex = GetInsertionIndex();
}
}
示例7: if
JBoolean
CBCClass::ViewDefinition
(
const JCharacter* fnName,
const JBoolean caseSensitive,
const JBoolean reportNotFound
)
const
{
JBoolean found = kJFalse;
JString headerName;
if (IsEnum())
{
found = ViewDeclaration(fnName, caseSensitive, reportNotFound);
}
else if (!Implements(fnName, caseSensitive))
{
found = ViewInheritedDefinition(fnName, caseSensitive, reportNotFound);
if (!found && reportNotFound)
{
JString msg = "Unable to find any definition for \"";
msg += fnName;
msg += "\".";
(JGetUserNotification())->ReportError(msg);
}
}
else if (GetFileName(&headerName))
{
// search for class::fn
const JCharacter* nsOp = "[[:space:]]*::[[:space:]]*";
JString searchStr = GetFullName();
JIndex i=1;
while (searchStr.LocateNextSubstring("::", &i))
{
searchStr.ReplaceSubstring(i,i+1, nsOp);
i += strlen(nsOp);
}
searchStr += nsOp;
searchStr += fnName;
found = FindDefinition(headerName, searchStr, caseSensitive);
if (!found)
{
// "::" insures that we find the source instead of a call to the function.
// We can't use "class::" because this doesn't work for templates.
searchStr = "::[[:space:]]*";
searchStr += fnName;
found = FindDefinition(headerName, searchStr, caseSensitive);
}
if (!found)
{
CBDocumentManager* docMgr = CBGetDocumentManager();
// look for it in the header file (pure virtual or inline in class defn)
JIndex lineIndex;
if (docMgr->SearchFile(headerName, fnName, caseSensitive, &lineIndex))
{
docMgr->OpenTextDocument(headerName, lineIndex);
found = kJTrue;
}
// we couldn't find it anywhere
else if (reportNotFound)
{
JString msg = "Unable to find the definition for \"";
msg += fnName;
msg += "\".";
(JGetUserNotification())->ReportError(msg);
}
}
}
else if (reportNotFound)
{
JString msg = GetFullName();
msg.PrependCharacter('"');
msg += "\" is a ghost class, so no information is available for it.";
(JGetUserNotification())->ReportError(msg);
}
return found;
}
示例8: JGetRootDirectory
JString
JGetClosestDirectory
(
const JCharacter* origDirName,
const JBoolean requireWrite,
const JCharacter* basePath
)
{
assert( !JStringEmpty(origDirName) );
JString workingDir;
if (!JStringEmpty(basePath))
{
workingDir = basePath;
JAppendDirSeparator(&workingDir);
}
else
{
workingDir = JGetCurrentDirectory();
}
JString dirName = origDirName;
JString homeDir;
JSize homeLength;
if (origDirName[0] == '~' &&
!JExpandHomeDirShortcut(origDirName, &dirName, &homeDir, &homeLength))
{
return JGetRootDirectory();
}
else if (JIsRelativePath(origDirName))
{
dirName.Prepend(workingDir);
}
assert( !JIsRelativePath(dirName) );
JString newDir, junkName;
while (!JDirectoryExists(dirName) ||
!JCanEnterDirectory(dirName) ||
!JDirectoryReadable(dirName) ||
(requireWrite && !JDirectoryWritable(dirName)))
{
JStripTrailingDirSeparator(&dirName);
if (JIsRootDirectory(dirName))
{
break;
}
JSplitPathAndName(dirName, &newDir, &junkName);
dirName = newDir;
}
// convert back to partial path, if possible
if (origDirName[0] == '~' &&
dirName.BeginsWith(homeDir))
{
dirName.ReplaceSubstring(1, homeDir.GetLength(), origDirName, homeLength);
}
else if (JIsRelativePath(origDirName) &&
dirName.GetLength() > workingDir.GetLength() &&
dirName.BeginsWith(workingDir))
{
dirName.RemoveSubstring(1, workingDir.GetLength());
}
return dirName;
}