本文整理汇总了C++中JString::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::Clear方法的具体用法?C++ JString::Clear怎么用?C++ JString::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::Clear方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFitManager
void
GLFitDirector::AddHistoryText
(
const JBoolean refit
)
{
JString str;
if (refit)
{
str = "Refit\n";
}
else
{
str = "Fit\n";
}
itsHistory->AppendText(str, kJFalse);
JIndex index;
JBoolean ok = itsCurveList->GetCurrentCurveIndex(&index);
assert(ok);
str = "Curve: " + itsPlot->GetCurveName(index) + "\n";
itsHistory->AppendText(str, kJFalse);
ok = itsFitList->GetCurrentFitIndex(&index);
assert(ok);
const GLFitDescription& fd = GetFitManager()->GetFitDescription(index);
str = "Fit type: " + fd.GetFnName() + "\n";
itsHistory->AppendText(str, kJFalse);
str.Clear();
itsParameterTable->GetValueString(&str);
itsHistory->AppendText(str, kJFalse);
str = "Reduced Chi^2: " + itsChiSq->GetText() + "\n";
itsHistory->AppendText(str, kJFalse);
itsHistory->AppendText("\n\n", kJFalse);
}
示例2:
void
CBFileNameDisplay::HandleUnfocusEvent()
{
JXFileInput::HandleUnfocusEvent();
JBoolean saved = kJFalse;
JString fullName;
if (itsUnfocusAction != kCancel &&
JExpandHomeDirShortcut(GetText(), &fullName))
{
if (JIsRelativePath(fullName) &&
!(JGetChooseSaveFile())->SaveFile("Save file as:", "", fullName, &fullName))
{
fullName.Clear();
}
if (!fullName.IsEmpty() &&
!JSameDirEntry(fullName, itsOrigFile) &&
itsDoc->SaveInNewFile(fullName))
{
saved = kJTrue;
JBoolean onDisk;
fullName = itsDoc->GetFullName(&onDisk);
SetText(fullName);
if (itsUnfocusAction == kRename)
{
CBCleanUpAfterRename(itsOrigFile, fullName);
}
}
}
if (!saved)
{
SetText(itsOrigFile);
}
UpdateDisplay(kJFalse); // take control of text style
itsDragSource->ProvideDirectSave(NULL);
}
示例3: 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;
}
示例4: parser
void
GDBVarCommand::HandleSuccess
(
const JString& data
)
{
JString s = data;
s.TrimWhitespace();
JBoolean success = kJFalse;
JIndexRange r;
prefixPattern.SetSingleLine();
if (prefixPattern.Match(data, &r))
{
s.RemoveSubstring(r);
SetData(s);
GDBVarTreeParser parser(s);
if (parser.yyparse() == 0)
{
parser.ReportRecoverableError();
success = kJTrue;
Broadcast(ValueMessage(kValueUpdated, parser.GetRootNode()));
}
}
else
{
(CMGetLink())->Log("GDBVarCommand failed to match");
}
if (!success)
{
Broadcast(ValueMessage(kValueFailed, NULL));
}
s.Clear();
SetData(s);
}
示例5: if
XFontStruct*
#endif
JXFontManager::ApproximateFont
(
const JCharacter* origName,
const JCharacter* origCharSet,
const JSize origSize,
const JFontStyle& origStyle
)
const
{
JString name = origName;
JString charSet = origCharSet;
JSize size = origSize;
JFontStyle style = origStyle;
#ifdef _J_USE_XFT
XftFont* xfont = NULL;
#else
XFontStruct* xfont = NULL;
#endif
while (xfont == NULL)
{
if (size % 2 == 1)
{
size--; // even sizes are more common
}
else if (size < 12)
{
size += 2;
}
else if (size > 12)
{
size -= 2;
}
else if (style.bold)
{
style.bold = kJFalse;
size = origSize;
}
else if (style.italic)
{
style.italic = kJFalse;
size = origSize;
}
else if (name != JGetDefaultFontName())
{
name = JGetDefaultFontName();
size = origSize;
style = origStyle;
}
else if (!charSet.IsEmpty())
{
charSet.Clear();
name = origName;
size = origSize;
style = origStyle;
}
else
{
// this should never happen, but it does with some Win95 X servers
cerr << "The X server does not have any PostScript fonts at all, not even ";
cerr << JGetDefaultFontName() << endl;
JXApplication::Abort(JXDocumentManager::kServerDead, kJFalse);
}
xfont = GetNewFont(name, charSet, size, style);
}
return xfont;
}
示例6: if
void
JXPathInput::AdjustStylesBeforeRecalc
(
const JString& buffer,
JRunArray<Font>* styles,
JIndexRange* recalcRange,
JIndexRange* redrawRange,
const JBoolean deletion
)
{
const JColormap* colormap = GetColormap();
const JSize totalLength = buffer.GetLength();
JString fullPath = buffer;
if ((JIsRelativePath(buffer) && !HasBasePath()) ||
!JExpandHomeDirShortcut(buffer, &fullPath))
{
fullPath.Clear();
}
// Last clause because if JConvertToAbsolutePath() succeeds, we don't
// want to further modify fullName.
else if (JIsRelativePath(buffer) &&
!JConvertToAbsolutePath(buffer, itsBasePath, &fullPath))
{
if (HasBasePath())
{
fullPath = JCombinePathAndName(itsBasePath, buffer);
}
else
{
fullPath.Clear();
}
}
JSize errLength;
if (fullPath.IsEmpty())
{
errLength = totalLength;
}
else
{
const JString closestDir = JGetClosestDirectory(fullPath, itsRequireWriteFlag);
if (fullPath.BeginsWith(closestDir))
{
errLength = fullPath.GetLength() - closestDir.GetLength();
}
else
{
errLength = totalLength;
}
}
if (errLength > 0 && buffer.EndsWith(kThisDirSuffix))
{
errLength++; // trailing . is trimmed
}
Font f = styles->GetFirstElement();
styles->RemoveAll();
if (errLength >= totalLength)
{
f.style.color = colormap->GetRedColor();
styles->AppendElements(f, totalLength);
}
else
{
f.style.color = colormap->GetBlackColor();
styles->AppendElements(f, totalLength - errLength);
if (errLength > 0)
{
f.style.color = colormap->GetRedColor();
styles->AppendElements(f, errLength);
}
}
*redrawRange += JIndexRange(1, totalLength);
}
示例7: output
void
CBFunctionMenu::UpdateMenu()
{
CBFnMenuUpdater* updater = CBMGetFnMenuUpdater();
const JXKeyModifiers& modifiers = GetDisplay()->GetLatestKeyModifiers();
JBoolean sort = updater->WillSortFnNames();
if (modifiers.meta())
{
sort = !sort;
}
JBoolean includeNS = updater->WillIncludeNamespace();
if (modifiers.shift())
{
includeNS = !includeNS;
}
const JBoolean pack = updater->WillPackFnNames();
if (itsNeedsUpdate || sort != itsSortFlag ||
includeNS != itsIncludeNSFlag || pack != itsPackFlag)
{
#if defined CODE_CRUSADER
assert( itsDoc != NULL );
JString fileName;
JBoolean deleteFile = kJFalse;
if (itsDoc->NeedsSave())
{
itsDoc->SafetySave(JXDocumentManager::kTimer);
if (!itsDoc->GetSafetySaveFileName(&fileName) &&
(JCreateTempFile(&fileName)).OK())
{
// directory may not be writable
deleteFile = kJTrue;
// itsDoc can't be CBTextDocument, because Code Medic uses us
CBTextDocument* textDoc = dynamic_cast<CBTextDocument*>(itsDoc);
assert( textDoc != NULL );
std::ofstream output(fileName);
((textDoc->GetTextEditor())->GetText()).Print(output);
}
}
else
{
JBoolean onDisk;
fileName = itsDoc->GetFullName(&onDisk);
if (!onDisk)
{
fileName.Clear();
}
}
#elif defined CODE_MEDIC
const JString& fileName = itsFileName;
#endif
if (!fileName.IsEmpty())
{
itsLang = updater->UpdateMenu(fileName, itsFileType, sort, includeNS, pack,
this, itsLineIndexList);
}
else
{
itsLang = kCBOtherLang;
this->RemoveAllItems();
itsLineIndexList->RemoveAll();
}
if (IsEmpty())
{
SetEmptyMenuItems();
}
itsNeedsUpdate = kJFalse;
itsSortFlag = sort;
itsIncludeNSFlag = includeNS;
itsPackFlag = pack;
itsCaretItemIndex = 0; // nothing to remove
itsTE->DeactivateCurrentUndo(); // force another TextChanged
#if defined CODE_CRUSADER
if (deleteFile)
{
JRemoveFile(fileName);
}
#endif
}
// mark caret location
//.........这里部分代码省略.........
示例8: if
void
GMMIMEParser::ParseContentType
(
const JString& val,
GMIMEHeader* header
)
{
// we first need to determine the type. this will be found before the
// first '/' which will be followed by the subtype.
JString tVal = val;
tVal.TrimWhitespace();
JSize length = tVal.GetLength();
JString type;
JIndex findex;
if (tVal.LocateSubstring("/", &findex) && (findex > 1))
{
type = tVal.GetSubstring(1, findex - 1);
tVal.RemoveSubstring(1, findex);
tVal.TrimWhitespace();
type.ToLower();
header->SetType(type);
}
else
{
return;
}
// now we need to determine the subtype
JString subType;
length = tVal.GetLength();
JBoolean found = kJFalse;
JIndex index;
if (tVal.LocateSubstring(";", &index))
{
subType = tVal.GetSubstring(1, index - 1);
tVal.RemoveSubstring(1, index);
}
else
{
subType = tVal;
tVal.Clear();
}
tVal.TrimWhitespace();
subType.TrimWhitespace();
subType.ToLower();
header->SetSubType(subType);
if (tVal.IsEmpty())
{
return;
}
JPtrArray<JString> strings(JPtrArrayT::kDeleteAll);
ParseContentParameters(tVal, &strings);
JSize count = strings.GetElementCount();
for (JIndex i = 1; i <= count; i += 2)
{
JString* str = strings.NthElement(i);
if (type == kTextType)
{
if (*str == "charset")
{
if (strings.IndexValid(i+1))
{
str = strings.NthElement(i+1);
header->SetCharSet(*str);
}
}
}
else if (type == kMultipartType)
{
if (*str == "boundary")
{
if (strings.IndexValid(i+1))
{
str = strings.NthElement(i+1);
header->SetBoundary(*str);
}
}
}
if ((type == kAppType) ||
(type == kImageType) ||
(type == kTextType))
{
if (*str == "name")
{
if (strings.IndexValid(i+1))
{
str = strings.NthElement(i+1);
if (str->LocateLastSubstring("/", &findex))
{
str->RemoveSubstring(1, findex);
}
if (str->LocateLastSubstring("\\", &findex))
{
str->RemoveSubstring(1, findex);
}
header->SetFileName(*str);
//.........这里部分代码省略.........
示例9: JTellg
void
GMMIMEParser::ParseAlternate
(
std::istream& input,
const GMIMEHeader& header
)
{
JString boundary = "-" + header.GetBoundary();
JString data;
JString junk;
// slurp the initial empty part
JIndex bstart, bend;
ReadUntilBoundary(input, boundary, &bstart, &bend);
JIndex current = JTellg(input);
data.Read(input, bend - current + 1);
JString text;
JString charset;
JString subType;
GMIMEHeader shownHeader;
while (1)
{
GMIMEHeader child;
ParseMIMEHeader(input, &child);
if (child.GetSubType() != kPlainType && child.GetSubType() != kHTMLType)
{
text = data;
while (!ReadUntilBoundary(input, boundary, &bstart, &bend))
{
// slurp up the rest, because it is useless to us.
current = JTellg(input);
data.Read(input, bend - current + 1);
}
current = JTellg(input);
data.Read(input, bend - current + 1);
data.Clear();
break;
}
else
{
shownHeader = child;
}
// when the following function returns true, it has found the
// last boundary
data.Clear();
JBoolean end = ReadUntilBoundary(input, boundary, &bstart, &bend);
current = JTellg(input);
data.Read(input, bstart - current);
current = JTellg(input);
junk.Read(input, bend - current + 1);
if (end)
{
text = data;
data.Clear();
break;
}
}
WriteTextString(&text, shownHeader);
if (itsTextInfo != NULL)
{
itsTextInfo->ForceUpdate();
}
if (itsAttachInfo != NULL)
{
itsAttachInfo->ForceUpdate();
}
}
示例10: os
void
GMMIMEParser::ParseMixed
(
std::istream& input,
const GMIMEHeader& header
)
{
JString boundary = "-" + header.GetBoundary();
JString endBoundary = boundary + "--";
// slurp the initial empty part
JIndex bstart, bend;
ReadUntilBoundary(input, boundary, &bstart, &bend);
JIndex current = JTellg(input);
JString data;
data.Read(input, bend - current + 1);
while (1)
{
GMIMEHeader child;
ParseMIMEHeader(input, &child);
// when the following function returns true, it has found the
// last boundary
data.Clear();
JBoolean end;
if (child.GetEncoding() == kBase64Encoding)
{
JString filename = child.GetFileName();
if (filename.IsEmpty())
{
JCreateTempFile(itsAttachDir, NULL, &filename);
}
else
{
filename = JCombinePathAndName(itsAttachDir, filename);
}
if (!filename.IsEmpty())
{
AdjustAttachmentName(child, &filename);
std::ofstream os(filename);
JDecodeBase64(input, os);
end = ReadUntilBoundary(input, boundary, &bstart, &bend);
// JBoolean found;
// JString line;
// while (line.IsEmpty() && !input.fail())
// {
// line = JReadLine(input, &found);
// }
// JString endBoundary = boundary + "--";
// if (line.Contains(endBoundary))
// {
// end = kJTrue;
// }
}
}
else if ((child.GetType() != kMultipartType) &&
(!child.GetFileName().IsEmpty()))
{
JIndex startI = JTellg(input);
JIndex findex = startI;
if (itsData->LocateNextSubstring(boundary, &findex))
{
const JCharacter* c = itsData->GetCString() + startI;
JString filename = child.GetFileName();
if (filename.IsEmpty())
{
JCreateTempFile(itsAttachDir, NULL, &filename);
}
else
{
filename = JCombinePathAndName(itsAttachDir, filename);
}
if (!filename.IsEmpty())
{
AdjustAttachmentName(child, &filename);
std::ofstream os(filename);
JSeekg(input, findex - 1);
if (child.GetEncoding() == kQPEncoding)
{
JString data = itsData->GetSubstring(startI, findex - 3);
ParseQuotedPrintable(&data);
data.Print(os);
}
else
{
os.write(c, findex - startI - 3);
}
JBoolean found;
JString line = JReadLine(input, &found);
if (line.BeginsWith(endBoundary))
{
end = kJTrue;
}
}
}
}
else
{
end = ReadUntilBoundary(input, boundary, &bstart, &bend);
//.........这里部分代码省略.........