本文整理汇总了C++中JString::BeginsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::BeginsWith方法的具体用法?C++ JString::BeginsWith怎么用?C++ JString::BeginsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::BeginsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
inline JBoolean
JXFontManager::IsPostscript
(
const JString& name
)
const
{
#if ONLY_STD_PS_FONTS
return JI2B(name == "Arial" || // Helvetica sucks on OS X
name.BeginsWith("Courier") ||
name.BeginsWith("Helvetica") ||
name == "Symbol" ||
name == "Times" ||
name.Contains("Bookman") ||
name.Contains("Century Schoolbook") ||
name.Contains("Chancery") ||
name.Contains("Palatino"));
#else
return kJTrue;
#endif
}
示例2: 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;
}
示例3: if
JBoolean
JFSBinding::Match
(
const JString& fileName,
const JString& content
)
const
{
if (itsCmd.IsEmpty())
{
return kJFalse;
}
else if (itsContentRegex != NULL)
{
return JI2B(content.BeginsWith(itsLiteralPrefix) &&
itsContentRegex->Match(content));
}
else if (itsNameRegex != NULL)
{
return itsNameRegex->Match(fileName);
}
else
{
return JI2B(!itsPattern.IsEmpty() &&
fileName.EndsWith(itsPattern, kJFalse));
}
}
示例4: GetTextEditor
void
CBExecOutputDocument::ReceiveRecord()
{
assert( itsRecordLink != NULL );
JString text;
const JBoolean ok = itsRecordLink->GetNextMessage(&text);
assert( ok );
// remove text that has already been printed
if (!itsLastPrompt.IsEmpty() && text.BeginsWith(itsLastPrompt))
{
text.RemoveSubstring(1, itsLastPrompt.GetLength());
}
itsLastPrompt.Clear();
const JXTEBase::DisplayState state = GetTextEditor()->SaveDisplayState();
AppendText(text);
GetTextEditor()->ClearUndo();
if (!itsReceivedDataFlag)
{
itsReceivedDataFlag = kJTrue;
if (!IsActive())
{
Activate();
}
}
GetTextEditor()->RestoreDisplayState(state);
}
示例5:
void
XDLink::SwitchToFrame
(
const JUInt64 id
)
{
if (id != itsStackFrameIndex)
{
itsStackFrameIndex = id;
Broadcast(FrameChanged());
}
const CMStackFrameNode* frame;
JString fileName;
JIndex lineIndex;
if (CMGetCommandDirector()->GetStackDir()->GetStackWidget()->GetStackFrame(id, &frame) &&
frame->GetFile(&fileName, &lineIndex))
{
if (fileName.BeginsWith("file://"))
{
fileName.RemoveSubstring(1, 7);
}
Broadcast(ProgramStopped(CMLocation(fileName, lineIndex)));
}
}
示例6: BeginsWith
inline JBoolean
jTranslateRemoteToLocal1
(
const JCharacter* host,
const JString& remotePath,
const JCharacter* mountDev,
const JCharacter* mountDir,
JString* localPath
)
{
const JString dev = mountDev;
JIndex hostEndIndex;
if (dev.LocateSubstring(":/", &hostEndIndex) && hostEndIndex > 1)
{
JString h = dev.GetSubstring(1, hostEndIndex-1);
jGetFullHostName(&h);
JString p = dev.GetSubstring(hostEndIndex+1, dev.GetLength());
JAppendDirSeparator(&p); // force complete name when check BeginsWith()
if (host == h && remotePath.BeginsWith(p))
{
*localPath = remotePath;
localPath->ReplaceSubstring(1, p.GetLength()-1, mountDir);
JCleanPath(localPath);
return kJTrue;
}
}
return kJFalse;
}
示例7:
JBoolean
CBCtagsUser::IgnoreSymbol
(
const JString& s
)
{
return s.BeginsWith("::");
}
示例8: if
void
JWebBrowser::ShowURL
(
const JCharacter* url
)
{
JString s = url;
if (s.BeginsWith(kMailURLPrefix, kJFalse))
{
s.RemoveSubstring(1, kMailURLPrefixLength);
ComposeMail(s);
}
else if (s.BeginsWith(kFileURLPrefix, kJFalse))
{
s.RemoveSubstring(1, kFileURLPrefixLength);
ShowFileContent(s);
}
else
{
Exec(itsShowURLCmd, kURLVarName, url);
}
}
示例9: input
void
GDBGetSourceFileList::HandleSuccess
(
const JString& origData
)
{
if (origData.BeginsWith("Source files for which symbols have been read in:"))
{
(JXGetApplication())->DisplayBusyCursor();
JXFileListTable* table = (GetFileList())->GetTable();
table->RemoveAllFiles();
JString data = origData;
JIndex i,j;
while (data.LocateSubstring("Source files for which symbols", &i))
{
j = i;
if (!data.LocateNextSubstring(":", &j))
{
j = data.GetLength();
}
data.ReplaceSubstring(i, j, ",");
}
data.TrimWhitespace(); // no comma after last file
std::istrstream input(data.GetCString(), data.GetLength());
JString fullName, path, name, s;
JBoolean foundDelimiter;
do
{
input >> ws;
fullName = JReadUntil(input, ',', &foundDelimiter);
fullName.TrimWhitespace();
if (!fullName.IsEmpty())
{
JSplitPathAndName(fullName, &path, &name);
table->AddFile(name);
}
}
while (foundDelimiter);
}
示例10:
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;
}
示例11:
JBoolean
CBSymbolList::InContext
(
const JString& fullName,
const JPtrArray<JString>& contextNamespace,
const JBoolean caseSensitive
)
const
{
const JSize count = contextNamespace.GetElementCount();
for (JIndex i=1; i<=count; i+=2)
{
const JString* cns1 = contextNamespace.NthElement(i);
const JString* cns2 = contextNamespace.NthElement(i+1);
if (fullName.BeginsWith(*cns1, caseSensitive) ||
fullName.Contains(*cns2, caseSensitive))
{
return kJTrue;
}
}
return kJFalse;
}
示例12: if
void
GFGLink::ParseLine
(
const JString& data
)
{
// we only care about virtual functions
JBoolean required = kJFalse;
if (data.Contains("implementation:pure virtual"))
{
required = kJTrue;
}
else if (!data.Contains("implementation:virtual"))
{
return;
}
JArray<JIndexRange> subList;
if (memberLine.Match(data, &subList))
{
JIndexRange sRange = subList.GetElement(2);
JString name = data.GetSubstring(sRange);
if (name.BeginsWith("~"))
{
return;
}
GFGMemberFunction* fn = jnew GFGMemberFunction();
assert(fn != NULL);
fn->SetFnName(name);
fn->ShouldBeRequired(required);
sRange = subList.GetElement(3);
JIndex line;
JString lineStr = data.GetSubstring(sRange);
lineStr.ConvertToUInt(&line);
sRange = subList.GetElement(4);
JString base = data.GetSubstring(sRange);
if (base != itsCurrentClass)
{
jdelete fn;
return;
}
sRange = subList.GetElement(5);
JString access = data.GetSubstring(sRange);
if (access == "protected")
{
fn->ShouldBeProtected(kJTrue);
}
ParseInterface(fn, line);
// Override entry from base class so function will only be
// marked as pure virtual if nobody implemented it.
JBoolean found;
const JIndex i =
itsClassList->SearchSorted1(fn, JOrderedSetT::kAnyMatch, &found);
if (found)
{
itsClassList->DeleteElement(i);
}
itsClassList->InsertAtIndex(i, fn);
}
}
示例13: is
void
GAddressBookMgr::AddAddressBook
(
const JCharacter* name,
JTree* tree
)
{
if (!JFileExists(name))
{
return;
}
JDirEntry* dirEntry = new JDirEntry(name);
assert(dirEntry != NULL);
JTreeNode* jbase = tree->GetRoot();
JNamedTreeNode* base = dynamic_cast<JNamedTreeNode*>(jbase);
assert(base != NULL);
GAddressBookTreeNode* book = new
GAddressBookTreeNode(dirEntry, base, dirEntry->GetName());
assert(book != NULL);
std::ifstream is(name);
while (is.good())
{
JString line = JReadLine(is);
GAddressBookEntry* entry = new GAddressBookEntry();
assert( entry != NULL );
JString name;
if (GetNextRecord(line, name, is))
{
GetNextRecord(line, entry->fullname, is);
if (GetNextRecord(line, entry->address, is))
{
GetNextRecord(line, entry->fcc, is);
GetNextRecord(line, entry->comment, is);
itsAddresses->SetElement(name, entry, JPtrArrayT::kDelete);
GAddressEntryTreeNode* aEntry =
new GAddressEntryTreeNode(book, entry->fullname);
assert(aEntry != NULL);
GAddressItemTreeNode* item =
new GAddressItemTreeNode(GAddressItemTreeNode::kName,
aEntry, name, kJFalse);
assert(item != NULL);
JString address = entry->address;
if (address.BeginsWith("(") && address.GetLength() > 2)
{
address = address.GetSubstring(2, address.GetLength() - 1);
JPtrArray<JString> list(JPtrArrayT::kForgetAll);
GParseNameList(address, list);
const JSize count = list.GetElementCount();
for (JSize i = count; i >= 1; i--)
{
item =
new GAddressItemTreeNode(GAddressItemTreeNode::kEMail,
aEntry, *(list.NthElement(i)), kJFalse);
assert(item != NULL);
}
list.DeleteAll();
}
else
{
item =
new GAddressItemTreeNode(GAddressItemTreeNode::kEMail,
aEntry, address, kJFalse);
}
if (!entry->comment.IsEmpty())
{
item =
new GAddressItemTreeNode(GAddressItemTreeNode::kComment,
aEntry, entry->comment, kJFalse);
assert(item != NULL);
}
if (!entry->fcc.IsEmpty())
{
item =
new GAddressItemTreeNode(GAddressItemTreeNode::kFcc,
aEntry, entry->fcc, kJFalse);
assert(item != NULL);
}
book->InsertSorted(aEntry);
continue;
}
}
delete entry;
}
}
示例14: input
void
JXFontManager::GetMonospaceFontNames
(
JPtrArray<JString>* fontNames
)
const
{
if (itsMonoFontNames != NULL)
{
fontNames->CopyObjects(*itsMonoFontNames, fontNames->GetCleanUpAction(), kJFalse);
}
else
{
(JXGetApplication())->DisplayBusyCursor();
fontNames->CleanOut();
fontNames->SetCompareFunction(JCompareStringsCaseInsensitive);
fontNames->SetSortOrder(JOrderedSetT::kSortAscending);
JPtrArray<JString> allFontNames(JPtrArrayT::kDeleteAll);
allFontNames.SetCompareFunction(JCompareStringsCaseInsensitive);
allFontNames.SetSortOrder(JOrderedSetT::kSortAscending);
JString name;
#if ENABLE_TRUE_TYPE
FcFontSet* set =
XftListFonts(*itsDisplay, itsDisplay->GetScreen(),
FC_SPACING, FcTypeInteger, FC_MONO, NULL,
FC_FAMILY, NULL);
for (int i=0; i < set->nfont; i++)
{
FcChar8* s = FcNameUnparse(set->fonts[i]);
name.Set((JCharacter*) s);
// cout << "tt mono: " << name << endl;
#if ONLY_STD_MONOSPACE
if (!name.BeginsWith("Courier") &&
!name.BeginsWith("Consolas") &&
!name.Contains(" Mono") &&
name != "LucidaTypewriter")
{
FcStrFree(s);
continue;
}
#endif
if (IsUseless(name))
{
FcStrFree(s);
continue;
}
JBoolean isDuplicate;
const JIndex index =
allFontNames.GetInsertionSortIndex(&name, &isDuplicate);
if (!isDuplicate)
{
allFontNames.InsertAtIndex(index, name);
JString* n = new JString(name);
assert( n != NULL );
const JBoolean ok = fontNames->InsertSorted(n, kJFalse);
assert( ok );
}
FcStrFree(s);
}
FcFontSetDestroy(set);
#else
for (int j=0; j<kMonospaceFontPatternCount; j++)
{
int nameCount;
char** nameList = XListFonts(*itsDisplay, kMonospaceFontPattern[j],
INT_MAX, &nameCount);
if (nameList == NULL)
{
return;
}
for (int i=0; i<nameCount; i++)
{
const std::string s(nameList[i], strlen(nameList[i]));
std::istringstream input(s);
input.ignore(); // initial dash
JIgnoreUntil(input, '-'); // foundry name
name = JReadUntil(input, '-'); // font name
if (name.IsEmpty() || name == "nil")
{
continue;
}
ConvertToPSFontName(&name);
// cout << "std mono: " << name << endl;
//.........这里部分代码省略.........
示例15: if
void
CBShellEditor::HandleKeyPress
(
const int key,
const JXKeyModifiers& modifiers
)
{
const JBoolean controlOn = modifiers.control();
const JBoolean metaOn = modifiers.meta();
const JBoolean shiftOn = modifiers.shift();
if ((key == kJLeftArrow && metaOn && !controlOn && !shiftOn) ||
(key == JXCtrl('A') && controlOn && !metaOn && !shiftOn))
{
const JIndex index = GetInsertionIndex();
const JRunArray<Font>& styles = GetStyles();
if (index > 1 && styles.GetElement(index-1) == GetDefaultFont())
{
JIndex runIndex, firstIndexInRun;
const JBoolean ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun);
SetCaretLocation(firstIndexInRun);
return;
}
}
if (key == kJReturnKey)
{
SetCurrentFont(itsInsertFont);
}
else
{
SetCurrentFont(GetDefaultFont());
}
JBoolean sentCmd = kJFalse;
if (key == kJReturnKey && !modifiers.shift() && !HasSelection())
{
JIndex index;
JBoolean ok = GetCaretLocation(&index);
assert( ok );
JString cmd;
const JRunArray<Font>& styles = GetStyles();
if (index > 1 && styles.GetElement(index-1) == GetDefaultFont())
{
JIndex runIndex, firstIndexInRun;
ok = styles.FindRun(index-1, &runIndex, &firstIndexInRun);
const JIndex endIndex = firstIndexInRun + styles.GetRunLength(runIndex);
cmd = (GetText()).GetSubstring(firstIndexInRun, endIndex - 1);
SetCaretLocation(endIndex);
if (cmd.BeginsWith("man "))
{
cmd.ReplaceSubstring(1, 4, "jcc --man ");
}
else if (cmd.BeginsWith("apropos "))
{
cmd.ReplaceSubstring(1, 8, "jcc --apropos ");
}
else if (cmd.BeginsWith("vi "))
{
cmd.ReplaceSubstring(1, 3, "jcc ");
}
else if (cmd.BeginsWith("less ") || cmd.BeginsWith("more "))
{
cmd.ReplaceSubstring(1, 5, "jcc ");
}
else if (cmd == "more" || cmd == "less" || cmd == "vi")
{
cmd = "jcc";
}
}
cmd += "\n";
itsShellDoc->SendCommand(cmd);
sentCmd = kJTrue;
}
CBTextEditor::HandleKeyPress(key, modifiers);
if (sentCmd)
{
itsInsertIndex = GetInsertionIndex();
}
}