本文整理汇总了C++中JString::InsertCharacter方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::InsertCharacter方法的具体用法?C++ JString::InsertCharacter怎么用?C++ JString::InsertCharacter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::InsertCharacter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: indexStr
JString
XDLink::Build1DArrayExpression
(
const JCharacter* origExpr,
const JInteger index
)
{
JString expr = origExpr;
const JString indexStr(index, 0); // must use floating point conversion
if (expr.Contains("$i"))
{
// double literal $'s
for (JIndex i=expr.GetLength()-1; i>=1; i--)
{
if (expr.GetCharacter(i) == '$' &&
expr.GetCharacter(i+1) != 'i')
{
expr.InsertCharacter('$', i);
}
}
const JCharacter* map[] =
{
"i", indexStr.GetCString()
};
(JGetStringManager())->Replace(&expr, map, sizeof(map));
}
else
{
expr.AppendCharacter('[');
expr += indexStr;
expr.AppendCharacter(']');
}
return expr;
}
示例2: 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;
}
示例3: input
void
LLDBGetAssembly::HandleSuccess
(
const JString& cmdData
)
{
LLDBLink* link = dynamic_cast<LLDBLink*>(CMGetLink());
if (link == NULL)
{
return;
}
lldb::SBCommandInterpreter interp = link->GetDebugger()->GetCommandInterpreter();
if (!interp.IsValid())
{
return;
}
const CMLocation& loc = (GetDirector())->GetDisassemblyLocation();
const JString cmd = "disassemble -n " + JPrepArgForExec(loc.GetFunctionName());
lldb::SBCommandReturnObject result;
interp.HandleCommand(cmd, result);
JPtrArray<JString> addrList(JPtrArrayT::kDeleteAll);
JString instText;
if (result.IsValid() && result.Succeeded() && result.HasResult())
{
std::istringstream input(result.GetOutput());
JString line, s;
JSize maxOffsetLength = 0;
while (!input.eof() && !input.fail())
{
line = JReadLine(input);
JIndex i;
if (line.LocateSubstring(":", &i) && i < line.GetLength())
{
s = line.GetSubstring(1, i-1);
if (s.BeginsWith("->") && s.GetLength() > 2)
{
s = s.GetSubstring(3, s.GetLength());
}
s.TrimWhitespace();
addrList.Append(s);
JIndexRange r;
if (offsetPattern.Match(s, &r))
{
maxOffsetLength = JMax(maxOffsetLength, r.GetLength());
}
if (!instText.IsEmpty())
{
instText.AppendCharacter('\n');
}
s = line.GetSubstring(i+1, line.GetLength());
s.TrimWhitespace();
instText.Append(s);
}
}
const JSize count = addrList.GetElementCount();
for (JIndex i=1; i<count; i++)
{
JString* s = addrList.NthElement(i);
JIndexRange r;
if (offsetPattern.Match(*s, &r))
{
const JSize pad = maxOffsetLength - r.GetLength();
for (JIndex j=0; j<pad; j++)
{
s->InsertCharacter('0', r.first+2);
}
}
}
}
(GetDirector())->DisplayDisassembly(&addrList, instText);
}