本文整理汇总了C++中JString::GetFirstCharacter方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::GetFirstCharacter方法的具体用法?C++ JString::GetFirstCharacter怎么用?C++ JString::GetFirstCharacter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::GetFirstCharacter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: input
void
CBSearchDocument::AppendText
(
const JString& text
)
{
if (text.GetFirstCharacter() == CBSearchTE::kIncrementProgress)
{
itsIndicator->IncrementValue();
return;
}
CBTextEditor* te = GetTextEditor();
itsFoundFlag = kJTrue;
const std::string s(text.GetCString(), text.GetLength());
std::istringstream input(s);
if (text.GetFirstCharacter() == CBSearchTE::kError)
{
input.ignore();
JString msg;
JReadAll(input, &msg);
const JIndex startIndex = te->GetTextLength() + 1;
te->SetCaretLocation(startIndex);
te->Paste(msg);
te->Paste("\n");
if (!itsOnlyListFilesFlag)
{
te->Paste("\n");
}
te->SetFontStyle(startIndex, startIndex + msg.GetLength()-1,
GetErrorStyle(), kJTrue);
}
else if (itsOnlyListFilesFlag)
{
JString fileName;
input >> fileName;
CBExecOutputDocument::AppendText(fileName);
if (itsIsReplaceFlag)
{
ReplaceAll(fileName);
}
}
else
{
示例2: AdjustStylesBeforeRecalc
void
CBCommandPathInput::AdjustStylesBeforeRecalc
(
const JString& buffer,
JRunArray<JFont>* styles,
JIndexRange* recalcRange,
JIndexRange* redrawRange,
const JBoolean deletion
)
{
if (!buffer.IsEmpty() && buffer.GetFirstCharacter() == '@')
{
const JColormap* colormap = GetColormap();
const JSize totalLength = buffer.GetLength();
JFont f = styles->GetFirstElement();
styles->RemoveAll();
f.SetColor(colormap->GetBlackColor());
styles->AppendElements(f, totalLength);
*redrawRange += JIndexRange(1, totalLength);
}
else
{
return JXPathInput::AdjustStylesBeforeRecalc(buffer, styles, recalcRange,
redrawRange, deletion);
}
}
示例3: indexStr
JString
CMLink::Build1DArrayExpressionForCFamilyLanguage
(
const JCharacter* origExpr,
const JInteger index
)
{
JString expr = origExpr;
const JString indexStr(index, 0); // must use floating point conversion
if (expr.Contains("$i"))
{
const JCharacter* map[] =
{
"i", indexStr.GetCString()
};
(JGetStringManager())->Replace(&expr, map, sizeof(map));
}
else
{
if (expr.GetFirstCharacter() != '(' ||
expr.GetLastCharacter() != ')')
{
expr.PrependCharacter('(');
expr.AppendCharacter(')');
}
expr.AppendCharacter('[');
expr += indexStr;
expr.AppendCharacter(']');
}
return expr;
}
示例4:
JBoolean
GAddressBookMgr::NameIsAlias
(
const JCharacter* name,
JString& alias,
JString& fcc
)
{
GAddressBookEntry* entry;
if (!itsAddresses->GetElement(name, &entry))
{
return kJFalse;
}
alias = entry->address;
if (alias.IsEmpty())
{
return kJFalse;
}
if (alias.GetFirstCharacter() == '(' &&
alias.GetLastCharacter() == ')')
{
if (entry->address.GetLength() > 2)
{
alias = entry->address.GetSubstring(2, entry->address.GetLength() - 1);
}
}
fcc = entry->fcc;
if (!fcc.IsEmpty() &&
fcc.GetFirstCharacter() == '(' &&
fcc.GetLastCharacter() == ')')
{
if (entry->fcc.GetLength() > 2)
{
fcc = entry->fcc.GetSubstring(2, entry->fcc.GetLength() - 1);
}
}
return kJTrue;
}
示例5: iStr
JString
CMLink::Build2DArrayExpressionForCFamilyLanguage
(
const JCharacter* origExpr,
const JInteger rowIndex,
const JInteger colIndex
)
{
JString expr = origExpr;
const JBoolean usesI = expr.Contains("$i"); // row
const JBoolean usesJ = expr.Contains("$j"); // col
const JString iStr(rowIndex, 0); // must use floating point conversion
const JString jStr(colIndex, 0); // must use floating point conversion
// We have to do both at the same time because otherwise we lose a $.
if (usesI || usesJ)
{
const JCharacter* map[] =
{
"i", iStr.GetCString(),
"j", jStr.GetCString()
};
(JGetStringManager())->Replace(&expr, map, sizeof(map));
}
if (!usesI || !usesJ)
{
if (expr.GetFirstCharacter() != '(' ||
expr.GetLastCharacter() != ')')
{
expr.PrependCharacter('(');
expr.AppendCharacter(')');
}
if (!usesI)
{
expr.AppendCharacter('[');
expr += iStr;
expr.AppendCharacter(']');
}
if (!usesJ)
{
expr.AppendCharacter('[');
expr += jStr;
expr.AppendCharacter(']');
}
}
return expr;
}
示例6: if
JBoolean
JXStringCompletionMenu::AddString
(
const JCharacter* str
)
{
const JIndex i = GetItemCount()+1;
if (i <= kMaxItemCount)
{
if (IsEmpty())
{
JFontID id;
JSize size;
JFontStyle style;
itsTE->GetDefaultFont(&id, &size, &style);
SetDefaultFont(id, size, style, kJFalse);
}
JString shortcut;
if (i <= 10)
{
shortcut = JString(i%10, JString::kBase10);
}
else if (i <= 36)
{
shortcut = " ";
shortcut.SetCharacter(1, 'a' + i - 11);
}
JString s = kItemPrefixStr;
s += str;
if (!shortcut.IsEmpty())
{
s.SetCharacter(1, shortcut.GetFirstCharacter());
s.SetCharacter(3, '-');
}
AppendItem(s, kPlainType, shortcut);
return kJTrue;
}
else if (i == kMaxItemCount+1)
{
AppendItem(kTruncationStr);
SetItemFont(i, JGetDefaultFontName(), kJDefaultFontSize,
JFontStyle(kJFalse, kJTrue, 0, kJFalse));
return kJFalse;
}
else
{
return kJFalse;
}
}
示例7: 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;
}
示例8:
JString
CMLineAddressTable::GetLineTextFromAddress
(
const JString& addr
)
const
{
JString s = addr;
if (s.BeginsWith("0x"))
{
s.RemoveSubstring(1,2);
}
while (s.GetFirstCharacter() == '0' &&
s.GetLength() > itsLineTextList->LastElement()->GetLength())
{
s.RemoveSubstring(1,1);
}
return s;
}
示例9: JExecute
void
CBApp::GetSystemIncludeDirectories()
{
int pid, fd, inFD;
const JError err = JExecute("gcc -Wp,-v -x c++ -fsyntax-only -", &pid,
kJCreatePipe, &inFD,
kJCreatePipe, &fd,
kJAttachToFromFD);
if (!err.OK())
{
for (const JCharacter* s : kSysIncludeDir)
{
itsSystemIncludeDirs->Append(s);
}
return;
}
close(inFD);
JString s;
while (1)
{
s = JReadUntil(fd, '\n');
if (s.IsEmpty())
{
break;
}
if (s.GetFirstCharacter() == ' ')
{
s.RemoveSubstring(1,1);
if (!s.Contains(" "))
{
itsSystemIncludeDirs->Append(s);
}
}
}
}
示例10: if
void
CBCommandTable::TableDrawCell
(
JPainter& p,
const JPoint& cell,
const JRect& rect
)
{
JPoint editCell;
if (GetEditedCell(&editCell) && cell == editCell)
{
return;
}
HilightIfSelected(p, cell, rect);
const CBCommandManager::CmdInfo info = itsCmdList->GetElement(cell.y);
if (info.separator)
{
JPoint pt1 = rect.bottomLeft(), pt2 = rect.bottomRight();
pt1.y--;
pt2.y--;
p.Line(pt1, pt2);
}
if (cell.x == kOptionsColumn)
{
JString s;
if (info.isMake)
{
s += ",M";
}
if (info.isVCS)
{
s += ",V";
}
if (info.saveAll)
{
s += ",S";
}
if (info.oneAtATime)
{
s += ",O";
}
if (info.useWindow)
{
s += ",W";
}
if (info.raiseWindowWhenStart)
{
s += ",R";
}
if (info.beepWhenFinished)
{
s += ",B";
}
if (!s.IsEmpty())
{
if (s.GetFirstCharacter() == ',')
{
s.RemoveSubstring(1,1);
}
p.String(rect, s, JPainter::kHAlignCenter, JPainter::kVAlignCenter);
}
}
else
{
const JString* s = NULL;
JFontStyle style;
if (cell.x == kMenuTextColumn)
{
s = info.menuText;
}
else if (cell.x == kMenuShortcutColumn)
{
s = info.menuShortcut;
}
else if (cell.x == kScriptNameColumn)
{
s = info.name;
}
else if (cell.x == kCommandColumn)
{
s = info.cmd;
}
else if (cell.x == kPathColumn)
{
s = info.path;
style.color =
CBCommandPathInput::GetTextColor(*s, itsBasePath, kJFalse, p.GetColormap());
}
assert( s != NULL );
p.SetFont(itsFontName, itsFontSize, style);
JRect r = rect;
r.left += kHMarginWidth;
p.String(r, *s, JPainter::kHAlignLeft, JPainter::kVAlignCenter);
}
//.........这里部分代码省略.........
示例11: if
JBoolean
CBCtagsUser::HasExuberantCtags()
{
if (itsHasExuberantCtagsFlag == kUntested)
{
itsHasExuberantCtagsFlag = kFailure;
// this hack is required on Linux kernel 2.3.x (4/19/2000)
j_sig_func* origHandler = signal(SIGCHLD, emptyHandler);
pid_t pid;
#if defined _J_SUNOS
pid_t* ppid = NULL;
#else
pid_t* ppid = &pid;
#endif
int fromFD;
JError err = JExecute(kCheckVersionCmd, ppid,
kJIgnoreConnection, NULL,
kJCreatePipe, &fromFD,
kJTossOutput, NULL);
if (err.OK())
{
JString vers;
JReadAll(fromFD, &vers);
JArray<JIndexRange> matchList;
if (versionPattern.Match(vers, &matchList))
{
matchList.RemoveElement(1);
const JSize count = matchList.GetElementCount();
JString s;
for (JIndex i=1; i<=count; i++)
{
JUInt v = 0;
const JIndexRange r = matchList.GetElement(i);
if (!r.IsEmpty())
{
s = vers.GetSubstring(r);
while (!isdigit(s.GetFirstCharacter()))
{
s.RemoveSubstring(1, 1);
}
const JBoolean ok = s.ConvertToUInt(&v);
assert( ok );
}
if (v > kMinVersion[i-1] ||
(i == count && v == kMinVersion[i-1]))
{
itsHasExuberantCtagsFlag = kSuccess;
break;
}
else if (v < kMinVersion[i-1])
{
break;
}
}
}
}
if (origHandler != SIG_ERR)
{
signal(SIGCHLD, origHandler);
}
}
return JI2B( itsHasExuberantCtagsFlag == kSuccess );
}
示例12: JString
void
CMVarNode::ConvertToBase()
{
itsCanConvertBaseFlag = kJFalse;
if (itsOrigValue != NULL && !itsOrigValue->IsEmpty())
{
JTree* tree;
if (itsValue != *itsOrigValue && GetTree(&tree))
{
tree->BroadcastChange(this);
}
itsValue = *itsOrigValue;
}
if (itsBase == 0 || itsIsPointerFlag)
{
return; // avoid constructing matchList
}
JArray<JIndexRange> matchList;
if (valuePattern.Match(itsValue, &matchList))
{
JString vStr = itsValue.GetSubstring(matchList.GetElement(2));
JUInt v;
itsCanConvertBaseFlag = JI2B(
vStr.ConvertToUInt(&v, vStr.GetFirstCharacter() == '0' ? 8 : 10) &&
(itsBase != 1 || (0 <= v && v <= 255)));
if (itsCanConvertBaseFlag)
{
// save value for when base reset to "default"
itsOrigValue = new JString(itsValue);
assert( itsOrigValue != NULL );
// replace only the value, preserving whatever else is there
if (itsBase == 1)
{
assert( 0 <= v && v <= 255 );
vStr = JString(v, JString::kBase16, kJTrue);
vStr += " '";
JBoolean found = kJFalse;
for (JIndex i=0; i<kSpecialCharCount; i++)
{
if (JCharacter(v) == kSpecialCharInfo[i].c)
{
vStr += kSpecialCharInfo[i].s;
found = kJTrue;
}
}
if (!found)
{
vStr.AppendCharacter(v);
}
vStr.AppendCharacter('\'');
}
else
{
vStr = JString(v, (JString::Base) itsBase, kJTrue);
if (itsBase == 8)
{
vStr.PrependCharacter('0');
}
}
JIndexRange r;
itsValue.ReplaceSubstring(matchList.GetElement(2), vStr, &r);
JTree* tree;
if (GetTree(&tree))
{
tree->BroadcastChange(this);
}
}
}
}
示例13: info
void
CBSymbolList::ReadSymbolList
(
istream& input,
const CBLanguage lang,
const JCharacter* fullName,
const JFAID_t fileID
)
{
JString path, fileName;
JSplitPathAndName(fullName, &path, &fileName);
input >> ws;
while (input.peek() == '!')
{
JIgnoreLine(input);
input >> ws;
}
JStringPtrMap<JString> flags(JPtrArrayT::kDeleteAll);
while (1)
{
JString* name = new JString;
assert( name != NULL );
input >> ws;
*name = JReadUntil(input, '\t'); // symbol name
if (input.eof() || input.fail())
{
delete name;
break;
}
JIgnoreUntil(input, '\t'); // file name
JIndex lineIndex;
input >> lineIndex; // line index
ReadExtensionFlags(input, &flags);
JCharacter typeChar = ' ';
JString* value;
if (flags.GetElement("kind", &value) && !value->IsEmpty())
{
typeChar = value->GetFirstCharacter();
}
JString* signature = NULL;
if (flags.GetElement("signature", &value) && !value->IsEmpty())
{
signature = new JString(*value);
assert( signature != NULL );
signature->PrependCharacter(' ');
}
if (IgnoreSymbol(*name))
{
delete name;
}
else
{
const Type type = DecodeSymbolType(lang, typeChar);
if (signature == NULL &&
(IsFunction(type) || IsPrototype(type)))
{
signature = new JString(" ( )");
assert( signature != NULL );
}
const SymbolInfo info(name, signature, lang, type,
kJFalse, fileID, lineIndex);
itsSymbolList->InsertSorted(info);
// add file:name
if (IsFileScope(type))
{
JString* name1 = new JString(fileName);
assert( name1 != NULL );
*name1 += ":";
*name1 += *name;
JString* sig1 = NULL;
if (signature != NULL)
{
sig1 = new JString(*signature);
assert( sig1 != NULL );
}
const SymbolInfo info1(name1, sig1, lang, type,
kJTrue, fileID, lineIndex);
itsSymbolList->InsertSorted(info1);
}
}
}
}
示例14: iStr
JString
XDLink::Build2DArrayExpression
(
const JCharacter* origExpr,
const JInteger rowIndex,
const JInteger colIndex
)
{
JString expr = origExpr;
const JBoolean usesI = expr.Contains("$i"); // row
const JBoolean usesJ = expr.Contains("$j"); // col
const JString iStr(rowIndex, 0); // must use floating point conversion
const JString jStr(colIndex, 0); // must use floating point conversion
// We have to do both at the same time because otherwise we lose a $.
if (usesI || usesJ)
{
// double literal $'s
for (JIndex i=expr.GetLength()-1; i>=1; i--)
{
if (expr.GetCharacter(i) == '$' &&
expr.GetCharacter(i+1) != 'i' &&
expr.GetCharacter(i+1) != 'j')
{
expr.InsertCharacter('$', i);
}
}
const JCharacter* map[] =
{
"i", iStr.GetCString(),
"j", jStr.GetCString()
};
(JGetStringManager())->Replace(&expr, map, sizeof(map));
}
if (!usesI || !usesJ)
{
if (expr.GetFirstCharacter() != '(' ||
expr.GetLastCharacter() != ')')
{
expr.PrependCharacter('(');
expr.AppendCharacter(')');
}
if (!usesI)
{
expr.AppendCharacter('[');
expr += iStr;
expr.AppendCharacter(']');
}
if (!usesJ)
{
expr.AppendCharacter('[');
expr += jStr;
expr.AppendCharacter(']');
}
}
return expr;
}
示例15: frame
//.........这里部分代码省略.........
JString label = JReadLine(input);
RemoveIdentifier(kObjLabelMarker, &label);
// shortcuts
JString shortcuts = JReadLine(input);
RemoveIdentifier(kObjShortcutMarker, &shortcuts);
optionValues.SetElement(kShortcutsIndex, &shortcuts, JPtrArrayT::kForget);
// resizing (ignored)
JIgnoreLine(input);
// gravity
input >> ws;
line = JReadUntilws(input);
assert( line == kObjGravityMarker );
const JString nwGravity = JReadUntilws(input);
const JString seGravity = JReadUntilws(input);
// variable name
JBoolean isLocal = kJFalse;
JString* varName = new JString(JReadLine(input));
assert( varName != NULL );
RemoveIdentifier(kObjNameMarker, varName);
if (varName->IsEmpty())
{
isInstanceVar.AppendElement(kJFalse);
GetTempVarName(tagName, varName, *objNames);
isLocal = kJTrue;
}
else if (varName->GetFirstCharacter() == '(' &&
varName->GetLastCharacter() == ')')
{
isInstanceVar.AppendElement(kJFalse);
isLocal = kJTrue;
*varName = varName->GetSubstring(2, varName->GetLength()-1);
}
else if (varName->GetFirstCharacter() == '<' &&
varName->GetLastCharacter() == '>')
{
isInstanceVar.AppendElement(kJFalse);
*varName = varName->GetSubstring(2, varName->GetLength()-1);
}
else
{
isInstanceVar.AppendElement(kJTrue);
}
objNames->Append(varName);
// callback (ignored)
JIgnoreLine(input);
// callback argument
JString cbArg = JReadLine(input);
RemoveIdentifier(kObjCBArgMarker, &cbArg);
JString cbArgExtra;
do
{
cbArgExtra = JReadLine(input);
cbArgExtra.TrimWhitespace();