本文整理汇总了C++中string::CharPointerType类的典型用法代码示例。如果您正苦于以下问题:C++ CharPointerType类的具体用法?C++ CharPointerType怎么用?C++ CharPointerType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CharPointerType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addLines
int StringArray::addLines (const String& sourceText)
{
int numLines = 0;
String::CharPointerType text (sourceText.getCharPointer());
bool finished = text.isEmpty();
while (! finished)
{
for (String::CharPointerType startOfLine (text);;)
{
const String::CharPointerType endOfLine (text);
switch (text.getAndAdvance())
{
case 0: finished = true; break;
case '\n': break;
case '\r': if (*text == '\n') ++text; break;
default: continue;
}
strings.add (String (startOfLine, endOfLine));
++numLines;
break;
}
}
return numLines;
}
示例2: parseIdentifier
int parseIdentifier (CodeDocument::Iterator& source) noexcept
{
int tokenLength = 0;
String::CharPointerType::CharType possibleIdentifier [100];
String::CharPointerType possible (possibleIdentifier);
while (isIdentifierBody (source.peekNextChar()))
{
const juce_wchar c = source.nextChar();
if (tokenLength < 20)
possible.write (c);
++tokenLength;
}
if (tokenLength > 1 && tokenLength <= 16)
{
possible.writeNull();
if (isReservedKeyword (String::CharPointerType (possibleIdentifier), tokenLength))
return CPlusPlusCodeTokeniser::tokenType_builtInKeyword;
}
return CPlusPlusCodeTokeniser::tokenType_identifier;
}
示例3: parseHeader
bool XmlDocument::parseHeader()
{
skipNextWhiteSpace();
if (CharacterFunctions::compareUpTo (input, CharPointer_ASCII ("<?xml"), 5) == 0)
{
const String::CharPointerType headerEnd (CharacterFunctions::find (input, CharPointer_ASCII ("?>")));
if (headerEnd.isEmpty())
return false;
#if JUCE_DEBUG
const String encoding (String (input, headerEnd)
.fromFirstOccurrenceOf ("encoding", false, true)
.fromFirstOccurrenceOf ("=", false, false)
.fromFirstOccurrenceOf ("\"", false, false)
.upToFirstOccurrenceOf ("\"", false, false).trim());
/* If you load an XML document with a non-UTF encoding type, it may have been
loaded wrongly.. Since all the files are read via the normal juce file streams,
they're treated as UTF-8, so by the time it gets to the parser, the encoding will
have been lost. Best plan is to stick to utf-8 or if you have specific files to
read, use your own code to convert them to a unicode String, and pass that to the
XML parser.
*/
jassert (encoding.isEmpty() || encoding.startsWithIgnoreCase ("utf-"));
#endif
input = headerEnd + 2;
skipNextWhiteSpace();
}
return true;
}
示例4: parseIdentifier
static int parseIdentifier (Iterator& source) noexcept
{
int tokenLength = 0;
String::CharPointerType::CharType possibleIdentifier [100];
String::CharPointerType possible (possibleIdentifier);
while (CppTokeniserFunctions::isIdentifierBody (source.peekNextChar()))
{
const juce_wchar c = source.nextChar();
if (tokenLength < 20)
possible.write (c);
++tokenLength;
}
if (tokenLength > 1 && tokenLength <= 16)
{
possible.writeNull();
if (isReservedKeyword (String::CharPointerType (possibleIdentifier), tokenLength))
return LuaTokeniser::tokenType_keyword;
}
return LuaTokeniser::tokenType_identifier;
}
示例5: stringLiteral
String stringLiteral (const String& text, int maxLineLength)
{
if (text.isEmpty())
return "String::empty";
StringArray lines;
{
String::CharPointerType t (text.getCharPointer());
bool finished = t.isEmpty();
while (! finished)
{
for (String::CharPointerType startOfLine (t);;)
{
switch (t.getAndAdvance())
{
case 0: finished = true; break;
case '\n': break;
case '\r': if (*t == '\n') ++t; break;
default: continue;
}
lines.add (String (startOfLine, t));
break;
}
}
}
if (maxLineLength > 0)
{
for (int i = 0; i < lines.size(); ++i)
{
String& line = lines.getReference (i);
if (line.length() > maxLineLength)
{
const String start (line.substring (0, maxLineLength));
const String end (line.substring (maxLineLength));
line = start;
lines.insert (i + 1, end);
}
}
}
for (int i = 0; i < lines.size(); ++i)
lines.getReference(i) = CppTokeniserFunctions::addEscapeChars (lines.getReference(i));
lines.removeEmptyStrings();
for (int i = 0; i < lines.size(); ++i)
lines.getReference(i) = "\"" + lines.getReference(i) + "\"";
String result (lines.joinIntoString (newLine));
if (! CharPointer_ASCII::isValidString (text.toUTF8(), std::numeric_limits<int>::max()))
result = "CharPointer_UTF8 (" + result + ")";
return result;
}
示例6: findOriginalValueInCode
void LivePropertyEditorBase::findOriginalValueInCode()
{
CodeDocument::Position pos (document, value.sourceLine, 0);
String line (pos.getLineText());
String::CharPointerType p (line.getCharPointer());
p = CharacterFunctions::find (p, CharPointer_ASCII ("JUCE_LIVE_CONSTANT"));
if (p.isEmpty())
{
// Not sure how this would happen - some kind of mix-up between source code and line numbers..
jassertfalse;
return;
}
p += (int) (sizeof ("JUCE_LIVE_CONSTANT") - 1);
p = p.findEndOfWhitespace();
if (! CharacterFunctions::find (p, CharPointer_ASCII ("JUCE_LIVE_CONSTANT")).isEmpty())
{
// Aargh! You've added two JUCE_LIVE_CONSTANT macros on the same line!
// They're identified by their line number, so you must make sure each
// one goes on a separate line!
jassertfalse;
}
if (p.getAndAdvance() == '(')
{
String::CharPointerType start (p), end (p);
int depth = 1;
while (! end.isEmpty())
{
const juce_wchar c = end.getAndAdvance();
if (c == '(') ++depth;
if (c == ')') --depth;
if (depth == 0)
{
--end;
break;
}
}
if (end > start)
{
valueStart = CodeDocument::Position (document, value.sourceLine, (int) (start - line.getCharPointer()));
valueEnd = CodeDocument::Position (document, value.sourceLine, (int) (end - line.getCharPointer()));
valueStart.setPositionMaintained (true);
valueEnd.setPositionMaintained (true);
wasHex = String (start, end).containsIgnoreCase ("0x");
}
}
}
示例7: writeText
void OutputStream::writeText (const String& text, const bool asUTF16,
const bool writeUTF16ByteOrderMark)
{
if (asUTF16)
{
if (writeUTF16ByteOrderMark)
write ("\x0ff\x0fe", 2);
String::CharPointerType src (text.getCharPointer());
bool lastCharWasReturn = false;
for (;;)
{
const juce_wchar c = src.getAndAdvance();
if (c == 0)
break;
if (c == '\n' && ! lastCharWasReturn)
writeShort ((short) '\r');
lastCharWasReturn = (c == L'\r');
writeShort ((short) c);
}
}
else
{
const char* src = text.toUTF8();
const char* t = src;
for (;;)
{
if (*t == '\n')
{
if (t > src)
write (src, (int) (t - src));
write ("\r\n", 2);
src = t + 1;
}
else if (*t == '\r')
{
if (t[1] == '\n')
++t;
}
else if (*t == 0)
{
if (t > src)
write (src, (int) (t - src));
break;
}
++t;
}
}
}
示例8: parseString
static Result parseString (const juce_wchar quoteChar, String::CharPointerType& t, var& result)
{
MemoryOutputStream buffer (256);
for (;;)
{
juce_wchar c = t.getAndAdvance();
if (c == quoteChar)
break;
if (c == '\\')
{
c = t.getAndAdvance();
switch (c)
{
case '"':
case '\'':
case '\\':
case '/': break;
case 'a': c = '\a'; break;
case 'b': c = '\b'; break;
case 'f': c = '\f'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
case 't': c = '\t'; break;
case 'u':
{
c = 0;
for (int i = 4; --i >= 0;)
{
const int digitValue = CharacterFunctions::getHexDigitValue (t.getAndAdvance());
if (digitValue < 0)
return createFail ("Syntax error in unicode escape sequence");
c = (juce_wchar) ((c << 4) + digitValue);
}
break;
}
}
}
if (c == 0)
return createFail ("Unexpected end-of-input in string constant");
buffer.appendUTF8Char (c);
}
result = buffer.toUTF8();
return Result::ok();
}
示例9: createLines
static void createLines (Array <CodeDocumentLine*>& newLines, const String& text)
{
String::CharPointerType t (text.getCharPointer());
int charNumInFile = 0;
bool finished = false;
while (! (finished || t.isEmpty()))
{
String::CharPointerType startOfLine (t);
int startOfLineInFile = charNumInFile;
int lineLength = 0;
int numNewLineChars = 0;
for (;;)
{
const juce_wchar c = t.getAndAdvance();
if (c == 0)
{
finished = true;
break;
}
++charNumInFile;
++lineLength;
if (c == '\r')
{
++numNewLineChars;
if (*t == '\n')
{
++t;
++charNumInFile;
++lineLength;
++numNewLineChars;
}
break;
}
if (c == '\n')
{
++numNewLineChars;
break;
}
}
newLines.add (new CodeDocumentLine (startOfLine, lineLength,
numNewLineChars, startOfLineInFile));
}
jassert (charNumInFile == text.length());
}
示例10: appendText
void SimpleTypeLayout::appendText (const AttributedString& text,
const Range<int>& stringRange, const Font& font,
const Colour& colour)
{
String stringText = text.getText().substring(stringRange.getStart(), stringRange.getEnd());
String::CharPointerType t (stringText.getCharPointer());
String currentString;
int lastCharType = 0;
for (;;)
{
const juce_wchar c = t.getAndAdvance();
if (c == 0)
break;
int charType;
if (c == '\r' || c == '\n')
{
charType = 0;
}
else if (CharacterFunctions::isWhitespace (c))
{
charType = 2;
}
else
{
charType = 1;
}
if (charType == 0 || charType != lastCharType)
{
if (currentString.isNotEmpty())
{
tokens.add (new Token (currentString, font, colour,
lastCharType == 2 || lastCharType == 0));
}
currentString = String::charToString (c);
if (c == '\r' && *t == '\n')
currentString += t.getAndAdvance();
}
else
{
currentString += c;
}
lastCharType = charType;
}
if (currentString.isNotEmpty())
tokens.add (new Token (currentString, font, colour, lastCharType == 2));
}
示例11: parseObjectOrArray
static Result parseObjectOrArray (String::CharPointerType t, var& result)
{
t = t.findEndOfWhitespace();
switch (t.getAndAdvance())
{
case 0: result = var::null; return Result::ok();
case '{': return parseObject (t, result);
case '[': return parseArray (t, result);
}
return createFail ("Expected '{' or '['", &t);
}
示例12: nextToken
static String nextToken (String::CharPointerType& t)
{
t = t.findEndOfWhitespace();
String::CharPointerType start (t);
size_t numChars = 0;
while (! (t.isEmpty() || t.isWhitespace()))
{
++t;
++numChars;
}
return String (start, numChars);
}
示例13: findFirstNonWhitespaceChar
int findFirstNonWhitespaceChar (const String& line) noexcept
{
String::CharPointerType t (line.getCharPointer());
int i = 0;
while (! t.isEmpty())
{
if (! t.isWhitespace())
return i;
++t;
++i;
}
return 0;
}
示例14: indexToColumn
int indexToColumn (int index, const String& line, int spacesPerTab) const noexcept
{
jassert (index <= line.length());
String::CharPointerType t (line.getCharPointer());
int col = 0;
for (int i = 0; i < index; ++i)
{
if (t.getAndAdvance() != '\t')
++col;
else
col += spacesPerTab - (col % spacesPerTab);
}
return col;
}
示例15: t
MD5::MD5 (const String& text)
{
ProcessContext context;
String::CharPointerType t (text.getCharPointer());
while (! t.isEmpty())
{
// force the string into integer-sized unicode characters, to try to make it
// get the same results on all platforms + compilers.
uint32 unicodeChar = ByteOrder::swapIfBigEndian ((uint32) t.getAndAdvance());
context.processBlock (&unicodeChar, sizeof (unicodeChar));
}
context.finish (result);
}