本文整理汇总了C++中JString::PrependCharacter方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::PrependCharacter方法的具体用法?C++ JString::PrependCharacter怎么用?C++ JString::PrependCharacter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::PrependCharacter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
JString
JVMVarNode::GetFullName
(
JBoolean* isPointer
)
const
{
JString str;
if (IsRoot())
{
return str;
}
const JVMVarNode* parent = dynamic_cast<const JVMVarNode*>(GetVarParent());
const JString& name = GetName();
if (parent->IsRoot())
{
str = "(" + name + ")";
}
else if (name.IsEmpty())
{
JIndex i;
const JBoolean found = parent->FindChild(this, &i);
assert( found );
str = parent->GetFullName(isPointer);
if (!str.BeginsWith("(") || !str.EndsWith(")"))
{
str.PrependCharacter('(');
str.AppendCharacter(')');
}
str += "[" + JString(i-1, JString::kBase10) + "]";
}
else if (name.BeginsWith("<"))
{
if (isPointer != NULL)
{
*isPointer = parent->IsPointer();
}
str = parent->GetFullName(isPointer);
}
else if (name.BeginsWith("["))
{
str = parent->GetFullName(isPointer) + name;
}
else if (name.BeginsWith("*"))
{
str = parent->GetPath() + "(" + name + ")";
}
else
{
str = name;
if (str.BeginsWith("static "))
{
str.RemoveSubstring(1,7);
}
str.Prepend(parent->GetPath());
}
return str;
}
示例2: 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;
}
示例3: if
JString
JPrepArgForExec
(
const JCharacter* arg
)
{
JString str = arg;
JBoolean quote = kJFalse;
const JSize length = str.GetLength();
for (JIndex i=length; i>=1; i--)
{
const JCharacter c = str.GetCharacter(i);
if (c == '"' || c == '\'' || c == '\\' || c == ';')
{
str.InsertSubstring("\\", i);
}
else if (isspace(c))
{
quote = kJTrue;
}
}
if (quote)
{
str.PrependCharacter('"');
str.AppendCharacter('"');
}
return str;
}
示例4: if
void
THXBaseConvDirector::Convert()
{
const JInteger fromBase = itsFromBase->GetBase();
const JString& fromStr = itsFromValue->GetText();
if (fromBase != 16 && hexRegex.Match(fromStr))
{
itsFromBase->SetBase(16); // calls us again
return;
}
JUInt value;
if (!fromStr.ConvertToUInt(&value, fromBase))
{
itsToValue->SetText("");
return;
}
JString toValue;
const JInteger toBase = itsToBase->GetBase();
if (value == 0)
{
toValue = "0";
}
else if (toBase == 2)
{
do
{
if (value & 0x01)
{
toValue.PrependCharacter('1');
}
else
{
toValue.PrependCharacter('0');
}
value = value >> 1;
}
while (value != 0);
}
else
{
示例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
CBCClass::ViewDeclaration
(
const JCharacter* fnName,
const JBoolean caseSensitive,
const JBoolean reportNotFound
)
const
{
JBoolean found = kJFalse;
JString headerName;
if (!Implements(fnName, caseSensitive))
{
found = ViewInheritedDeclaration(fnName, caseSensitive, reportNotFound);
if (!found && reportNotFound)
{
JString msg = "Unable to find any declaration for \"";
msg += fnName;
msg += "\".";
(JGetUserNotification())->ReportError(msg);
}
}
else if (GetFileName(&headerName))
{
CBDocumentManager* docMgr = CBGetDocumentManager();
JIndex lineIndex;
if (docMgr->SearchFile(headerName, fnName, caseSensitive, &lineIndex))
{
docMgr->OpenTextDocument(headerName, lineIndex);
found = kJTrue;
}
else if (reportNotFound)
{
JString msg = "Unable to find the declaration of \"";
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;
}
示例7:
void
JXFileHistoryMenu::AddFile
(
const JCharacter* origPath,
const JCharacter* name
)
{
if (JStringEmpty(origPath) || JStringEmpty(name))
{
return;
}
JString path = origPath;
path.PrependCharacter(' ');
path.AppendCharacter(' ');
AddItem(name, path);
}
示例8: if
void
JDirInfo::AppendRegex
(
const JCharacter* origStr,
JString* regexStr
)
{
JIndex i;
JString str = origStr;
// Convert wildcard multiples (*) to regex multiples (.*)
// and wildcard singles (?) to regex singles (.)
for (i = str.GetLength(); i>=1; i--)
{
const JCharacter c = str.GetCharacter(i);
if (c == '*')
{
str.InsertSubstring(".", i);
}
else if (c == '?')
{
str.SetCharacter(i, '.');
}
else if (JRegex::NeedsBackslashToBeLiteral(c))
{
str.InsertSubstring("\\", i);
}
}
// Add instructions that it must match the entire file name.
str.PrependCharacter('^');
str.AppendCharacter('$');
// append to regexStr
if (!regexStr->IsEmpty())
{
regexStr->AppendCharacter('|');
}
*regexStr += str;
}
示例9:
void
GetTempVarName
(
const JCharacter* tagName,
JString* varName,
const JPtrArray<JString>& objNames
)
{
JString suffix = tagName;
JIndexRange r;
while (illegalCChar.Match(suffix, &r))
{
suffix.RemoveSubstring(r);
}
suffix.PrependCharacter('_');
const JString prefix = "obj";
const JSize count = objNames.GetElementCount();
for (JIndex i=1; i<=INT_MAX; i++)
{
*varName = prefix + JString(i) + suffix;
JBoolean unique = kJTrue;
for (JIndex j=1; j<=count; j++)
{
const JString* usedName = objNames.NthElement(j);
if (*varName == *usedName)
{
unique = kJFalse;
break;
}
}
if (unique)
{
break;
}
}
}
示例10: 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;
}
示例11: 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);
}
}
}
}
示例12: 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);
}
}
}
}
示例13: output
void
CBFileNode::CreateFilesForTemplate
(
istream& input,
const JFileVersion vers
)
const
{
CBFileNodeBase::CreateFilesForTemplate(input, vers);
JBoolean exists;
input >> exists;
if (exists)
{
JString relName, data;
input >> relName >> data;
JString path, name;
JSplitPathAndName(relName, &path, &name);
const CBProjectTree* projTree = dynamic_cast<const CBProjectTree*>(GetTree());
assert( projTree != NULL );
const JString& basePath = (projTree->GetProjectDoc())->GetFilePath();
path = JCombinePathAndName(basePath, path);
JUserNotification* un = JGetUserNotification();
if (!JDirectoryExists(path))
{
const JError err = JCreateDirectory(path);
if (!err.OK())
{
JString msg = "Unable to create the file ";
msg += relName;
msg += " from the template because:\n\n";
msg += err.GetMessage();
un->ReportError(msg);
return;
}
}
const JString fullName = JCombinePathAndName(path, name);
if (JFileExists(fullName))
{
JString msg = fullName;
msg.PrependCharacter('"');
msg += "\" already exists. Do you want to overwrite it?";
if (!un->AskUserNo(msg))
{
return;
}
}
ofstream output(fullName);
if (output.good())
{
data.Print(output);
}
else
{
JString msg = "Unable to create the file ";
msg += relName;
msg += " from the template.";
un->ReportError(msg);
}
}
}