本文整理汇总了C++中JString::SetCharacter方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::SetCharacter方法的具体用法?C++ JString::SetCharacter怎么用?C++ JString::SetCharacter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::SetCharacter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: JGetString
void
JCheckSiteName
(
const JCharacter* encSiteSuffix,
const JCharacter siteCode,
const JCharacter* map[],
const JSize size
)
{
JString siteSuffix = encSiteSuffix;
const JSize len = siteSuffix.GetLength();
for (JIndex i=1; i<=len; i++)
{
siteSuffix.SetCharacter(i, siteSuffix.GetCharacter(i) ^ siteCode);
}
map[1] = siteSuffix.GetCString();
if (!(JGetHostName()).EndsWith(siteSuffix, kJFalse))
{
const JString msg = JGetString(kWrongSiteID, map, size);
(JGetUserNotification())->DisplayMessage(msg);
exit(0);
}
}
示例3:
JString
JGetPermissionsString
(
const mode_t mode
)
{
JString modeString = "---------";
if (mode & S_IRUSR)
{
modeString.SetCharacter(1, 'r');
}
if (mode & S_IWUSR)
{
modeString.SetCharacter(2, 'w');
}
if (mode & S_IXUSR)
{
modeString.SetCharacter(3, 'x');
}
if (mode & S_IRGRP)
{
modeString.SetCharacter(4, 'r');
}
if (mode & S_IWGRP)
{
modeString.SetCharacter(5, 'w');
}
if (mode & S_IXGRP)
{
modeString.SetCharacter(6, 'x');
}
if (mode & S_IROTH)
{
modeString.SetCharacter(7, 'r');
}
if (mode & S_IWOTH)
{
modeString.SetCharacter(8, 'w');
}
if (mode & S_IXOTH)
{
modeString.SetCharacter(9, 'x');
}
return modeString;
}
示例4:
const JCharacter*
SyGApplication::GetNMShortcut
(
JIndex* i
)
const
{
if (*i <= kShortcutKeyCount)
{
kShortcutStr.SetCharacter(6, kShortcutKey[*i-1]);
(*i)++;
return kShortcutStr.GetCString();
}
else
{
return NULL;
}
}
示例5: 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;
}
示例6: if
JBoolean
JNameValid
(
const JCharacter* str
)
{
JIndex i;
const JSize length = strlen(str);
if (length == 0)
{
(JGetUserNotification())->ReportError("Names cannot be empty.");
return kJFalse;
}
const JCharacter greekPrefix = JPGetGreekCharPrefixChar();
for (i=1; i<=length; i++)
{
const JCharacter c = str[i-1];
JBoolean valid = JConvertToBoolean( (i>1 && JIsAlnum(c)) || (i==1 && JIsAlpha(c)) );
if (i == 1)
{
valid = JConvertToBoolean( valid || c == greekPrefix );
}
else if (i > 1)
{
JSize j = 0;
while (!valid && j < validCharCount)
{
valid = JConvertToBoolean( c == validChar[j] );
j++;
}
}
if (!valid)
{
JString errorStr = "Illegal character 'x";
errorStr.SetCharacter(errorStr.GetLength(), c);
errorStr += "' in \"";
errorStr += str;
errorStr += "\".";
(JGetUserNotification())->ReportError(errorStr);
return kJFalse;
}
}
const JSize nameCount = JPGetNamedConstCount();
const JNamedConstInfo* nameInfo = JPGetNamedConstInfo();
for (i=1; i<=nameCount; i++)
{
if (strcmp(str, nameInfo[i-1].name) == 0)
{
JString errorStr = "\"";
errorStr += nameInfo[i-1].name;
errorStr += "\" is already used to represent a constant.";
(JGetUserNotification())->ReportError(errorStr);
return kJFalse;
}
}
return kJTrue;
}
示例7: if
//.........这里部分代码省略.........
// 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)
{
te->Paste("\n");
}
itsPrevLine = *text;
// display file name in bold and activate Errors menu
JIndexRange boldRange;
if (isJavacError)
{
JArray<JIndexRange> javacMatchList;
if (javacErrorRegex.Match(*text, &javacMatchList))
{
const JIndexRange r = javacMatchList.GetElement(2);
boldRange.Set(startIndex + r.first-1, startIndex + r.last-1);
}
}
else if (isGCCError)
{
boldRange.Set(startIndex, startIndex + gccRange.first - 1);
}
else if (isFlexError)
{
boldRange.Set(startIndex+1, startIndex + flexRange.first);
}
else if (isBisonError)
{
boldRange.Set(startIndex+2, startIndex + bisonRange.first + 1);
}
else if (isMakeError)
{
boldRange.SetFirstAndLength(startIndex, text->GetLength());
}
else if (isAbsoftError)
{
boldRange = absoftRangeList.GetElement(2);
boldRange += startIndex-1;
}
else if (isMaven2Error)
{
boldRange = maven2RangeList.GetElement(2);
boldRange += startIndex-1;
}
else if (isMaven3Error)
{
boldRange = maven3RangeList.GetElement(2);
boldRange += startIndex-1;
}
if (!boldRange.IsEmpty())
{
te->JTextEditor::SetFont(boldRange.first, boldRange.last, GetErrorFont(), kJTrue);
if (!itsHasErrorsFlag)
{
itsHasErrorsFlag = kJTrue;
itsErrorMenu->Activate();
JXWindow* window = GetWindow();
JString windowTitle = window->GetTitle();
windowTitle.SetCharacter(1, '!');
windowTitle.SetCharacter(2, '!');
windowTitle.SetCharacter(3, '!');
window->SetTitle(windowTitle);
}
}
}
if (deleteText)
{
jdelete text;
}
}
示例8:
void
JXDocumentManager::UpdateDocumentMenu
(
JXDocumentMenu* menu
)
{
if (menu->IsOpen())
{
DocumentMenusNeedUpdate();
return;
}
menu->RemoveAllItems();
// It almost always is sorted, so we only pay O(N) instead of O(N^2).
// (but we can't sort when document is created!)
if (!itsDocList->IsSorted())
{
itsDocList->Sort();
}
const JSize count = itsDocList->GetElementCount();
for (JIndex i=1; i<=count; i++)
{
DocInfo info = itsDocList->GetElement(i);
const JString& name = (info.doc)->GetName();
menu->AppendItem(name);
if ((info.doc)->NeedsSave())
{
menu->SetItemFontStyle(i, (menu->GetColormap())->GetDarkRedColor());
}
const JXImage* icon;
if ((info.doc)->GetMenuIcon(&icon) &&
icon->GetDisplay() == menu->GetDisplay() &&
icon->GetColormap() == menu->GetColormap())
{
menu->SetItemImage(i, const_cast<JXImage*>(icon), kJFalse);
}
if (itsWantShortcutFlag &&
kFirstShortcut <= info.shortcut && info.shortcut <= kLastShortcut)
{
const JXMenu::Style style = JXMenu::GetDefaultStyle();
JString nmShortcut;
if (style == JXMenu::kWindowsStyle)
{
nmShortcut = "Ctrl-0";
}
else
{
assert( style == JXMenu::kMacintoshStyle );
nmShortcut = "Meta-0";
}
nmShortcut.SetCharacter(nmShortcut.GetLength(),
kShortcutChar [ info.shortcut ]);
menu->SetItemNMShortcut(i, nmShortcut);
}
}
}