本文整理汇总了C++中BYTE_TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ BYTE_TYPE函数的具体用法?C++ BYTE_TYPE怎么用?C++ BYTE_TYPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BYTE_TYPE函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PREFIX
static
int PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
const char **badPtr)
{
ptr += MINBPC(enc);
end -= MINBPC(enc);
for (; ptr != end; ptr += MINBPC(enc)) {
switch (BYTE_TYPE(enc, ptr)) {
case BT_DIGIT:
case BT_HEX:
case BT_MINUS:
case BT_APOS:
case BT_LPAR:
case BT_RPAR:
case BT_PLUS:
case BT_COMMA:
case BT_SOL:
case BT_EQUALS:
case BT_QUEST:
case BT_CR:
case BT_LF:
case BT_SEMI:
case BT_EXCL:
case BT_AST:
case BT_PERCNT:
case BT_NUM:
#ifdef XML_NS
case BT_COLON:
#endif
break;
case BT_S:
if (CHAR_MATCHES(enc, ptr, ASCII_TAB)) {
*badPtr = ptr;
return 0;
}
break;
case BT_NAME:
case BT_NMSTRT:
if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
break;
default:
switch (BYTE_TO_ASCII(enc, ptr)) {
case 0x24: /* $ */
case 0x40: /* @ */
break;
default:
*badPtr = ptr;
return 0;
}
break;
}
}
return 1;
}
示例2: MOZ_XMLCheckQName
int MOZ_XMLCheckQName(const char* ptr, const char* end, int ns_aware,
const char** colon)
{
int result = MOZ_EXPAT_VALID_QNAME;
int nmstrt = 1;
*colon = 0;
if (ptr == end) {
return MOZ_EXPAT_EMPTY_QNAME;
}
do {
switch (BYTE_TYPE(ptr)) {
case BT_COLON:
/* We're namespace-aware and either first or last character is a colon
or we've already seen a colon. */
if (ns_aware && (nmstrt || *colon || ptr + 2 == end)) {
return MOZ_EXPAT_MALFORMED;
}
*colon = ptr;
nmstrt = ns_aware; /* e.g. "a:0" should be valid if !ns_aware */
break;
case BT_NONASCII:
if (nmstrt && !IS_NMSTRT_CHAR_MINBPC(ptr)) {
/* If this is a valid name character and we're namespace-aware, the
QName is malformed. Otherwise, this character's invalid at the
start of a name (or, if we're namespace-aware, at the start of a
localpart). */
return (IS_NAME_CHAR_MINBPC(ptr) && ns_aware) ?
MOZ_EXPAT_MALFORMED :
MOZ_EXPAT_INVALID_CHARACTER;
}
if (!IS_NAME_CHAR_MINBPC(ptr)) {
return MOZ_EXPAT_INVALID_CHARACTER;
}
nmstrt = 0;
break;
case BT_NMSTRT:
case BT_HEX:
nmstrt = 0;
break;
case BT_DIGIT:
case BT_NAME:
case BT_MINUS:
if (nmstrt) {
return MOZ_EXPAT_INVALID_CHARACTER;
}
break;
default:
return MOZ_EXPAT_INVALID_CHARACTER;
}
ptr += 2;
} while (ptr != end);
return result;
}
示例3: PREFIX
static
int PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr)
{
if (ptr == end)
return XML_TOK_PARTIAL;
switch (BYTE_TYPE(enc, ptr)) {
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
default:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
while (ptr != end) {
switch (BYTE_TYPE(enc, ptr)) {
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
case BT_S: case BT_CR: case BT_LF:
for (ptr += MINBPC; ptr != end; ptr += MINBPC) {
switch (BYTE_TYPE(enc, ptr)) {
case BT_S: case BT_CR: case BT_LF:
break;
case BT_GT:
*nextTokPtr = ptr + MINBPC;
return XML_TOK_END_TAG;
default:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
}
return XML_TOK_PARTIAL;
case BT_GT:
*nextTokPtr = ptr + MINBPC;
return XML_TOK_END_TAG;
default:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
}
return XML_TOK_PARTIAL;
}
示例4: MOZ_XMLIsLetter
int MOZ_XMLIsLetter(const char* ptr)
{
switch (BYTE_TYPE(ptr)) {
case BT_NONASCII:
if (!IS_NMSTRT_CHAR_MINBPC(ptr)) {
return 0;
}
case BT_NMSTRT:
case BT_HEX:
return 1;
default:
return 0;
}
}
示例5: PREFIX
static int PTRCALL
PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr,
const char *end, const char **nextTokPtr)
{
int level = 0;
if (MINBPC(enc) > 1) {
size_t n = end - ptr;
if (n & (MINBPC(enc) - 1)) {
n &= ~(MINBPC(enc) - 1);
end = ptr + n;
}
}
while (ptr != end) {
switch (BYTE_TYPE(enc, ptr)) {
INVALID_CASES(ptr, nextTokPtr)
case BT_LT:
if ((ptr += MINBPC(enc)) == end)
return XML_TOK_PARTIAL;
if (CHAR_MATCHES(enc, ptr, ASCII_EXCL)) {
if ((ptr += MINBPC(enc)) == end)
return XML_TOK_PARTIAL;
if (CHAR_MATCHES(enc, ptr, ASCII_LSQB)) {
++level;
ptr += MINBPC(enc);
}
}
break;
case BT_RSQB:
if ((ptr += MINBPC(enc)) == end)
return XML_TOK_PARTIAL;
if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
if ((ptr += MINBPC(enc)) == end)
return XML_TOK_PARTIAL;
if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
ptr += MINBPC(enc);
if (level == 0) {
*nextTokPtr = ptr;
return XML_TOK_IGNORE_SECT;
}
--level;
}
}
break;
default:
ptr += MINBPC(enc);
break;
}
}
return XML_TOK_PARTIAL;
}
示例6: MOZ_XMLCheckQName
int MOZ_XMLCheckQName(const char* ptr, const char* end, int ns_aware,
const char** colon)
{
int result = MOZ_EXPAT_VALID_QNAME;
int nmstrt = 1;
*colon = 0;
if (ptr == end) {
return MOZ_EXPAT_EMPTY_QNAME;
}
do {
switch (BYTE_TYPE(ptr)) {
case BT_COLON:
/* We're namespace-aware and either first or last character is a colon
or we've already seen a colon. */
if (ns_aware && (nmstrt || *colon || ptr + 2 == end)) {
return MOZ_EXPAT_MALFORMED;
}
*colon = ptr;
nmstrt = ns_aware; /* e.g. "a:0" should be valid if !ns_aware */
break;
case BT_NONASCII:
if (!IS_NAME_CHAR_MINBPC(ptr) ||
(nmstrt && !*colon && !IS_NMSTRT_CHAR_MINBPC(ptr))) {
return MOZ_EXPAT_INVALID_CHARACTER;
}
if (nmstrt && *colon && !IS_NMSTRT_CHAR_MINBPC(ptr)) {
/* If a non-starting character like a number is right after the colon,
this is a namespace error, not invalid character */
return MOZ_EXPAT_MALFORMED;
}
nmstrt = 0;
break;
case BT_NMSTRT:
case BT_HEX:
nmstrt = 0;
break;
case BT_DIGIT:
case BT_NAME:
case BT_MINUS:
if (nmstrt) {
return MOZ_EXPAT_INVALID_CHARACTER;
}
break;
default:
return MOZ_EXPAT_INVALID_CHARACTER;
}
ptr += 2;
} while (ptr != end);
return result;
}
示例7: PREFIX
static void PTRCALL
PREFIX(updatePosition)(const ENCODING *enc,
const char *ptr,
const char *end,
POSITION *pos)
{
while (ptr != end) {
switch (BYTE_TYPE(enc, ptr)) {
#define LEAD_CASE(n) \
case BT_LEAD ## n: \
if (end - ptr < n) { \
return; \
} \
ptr += n; \
break;
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
#undef LEAD_CASE
case BT_LF:
pos->columnNumber = (XML_Size)-1;
pos->lineNumber++;
ptr += MINBPC(enc);
break;
case BT_CR:
pos->lineNumber++;
ptr += MINBPC(enc);
if (ptr != end && BYTE_TYPE(enc, ptr) == BT_LF)
ptr += MINBPC(enc);
pos->columnNumber = (XML_Size)-1;
break;
default:
ptr += MINBPC(enc);
break;
}
pos->columnNumber++;
}
}
示例8: MOZ_XMLIsNCNameChar
int MOZ_XMLIsNCNameChar(const char* ptr)
{
switch (BYTE_TYPE(ptr)) {
case BT_NONASCII:
if (!IS_NAME_CHAR_MINBPC(ptr)) {
return 0;
}
case BT_NMSTRT:
case BT_HEX:
case BT_DIGIT:
case BT_NAME:
case BT_MINUS:
return 1;
default:
return 0;
}
}
示例9: PREFIX
static int PTRFASTCALL PREFIX (nameLength) (const ENCODING * enc, const char *ptr) {
const char *start = ptr;
for (;;) {
switch (BYTE_TYPE (enc, ptr)) {
#define LEAD_CASE(n) \
case BT_LEAD ## n: ptr += n; break;
LEAD_CASE (2) LEAD_CASE (3) LEAD_CASE (4)
#undef LEAD_CASE
case BT_NONASCII:
case BT_NMSTRT:
#ifdef XML_NS
case BT_COLON:
#endif
case BT_HEX:
case BT_DIGIT:
case BT_NAME:
case BT_MINUS:
ptr += MINBPC (enc);
break;
default:
return (int) (ptr - start);
}
}
}
示例10: MOZ_XMLCheckQName
int MOZ_XMLCheckQName(const char* ptr, const char* end, int ns_aware,
const char** colon)
{
int result = MOZ_EXPAT_VALID_QNAME;
int nmstrt = 1;
*colon = 0;
if (ptr == end) {
return MOZ_EXPAT_EMPTY_QNAME;
}
do {
switch (BYTE_TYPE(ptr)) {
case BT_COLON:
if (ns_aware) {
if (*colon != 0 || nmstrt || ptr + 2 == end) {
/* We already encountered a colon or this is the first or the last
character so the QName is malformed. */
result |= MOZ_EXPAT_MALFORMED;
}
*colon = ptr;
nmstrt = 1;
}
else if (nmstrt) {
/* This is the first character so the QName is malformed. */
result |= MOZ_EXPAT_MALFORMED;
nmstrt = 0;
}
break;
case BT_NONASCII:
if (nmstrt) {
if (!IS_NMSTRT_CHAR_MINBPC(ptr)) {
/* If this is a valid name character the QName is malformed,
otherwise it contains an invalid character. */
result |= IS_NAME_CHAR_MINBPC(ptr) ? MOZ_EXPAT_MALFORMED :
MOZ_EXPAT_INVALID_CHARACTER;
}
}
else if (!IS_NAME_CHAR_MINBPC(ptr)) {
result |= MOZ_EXPAT_INVALID_CHARACTER;
}
nmstrt = 0;
break;
case BT_NMSTRT:
case BT_HEX:
nmstrt = 0;
break;
case BT_DIGIT:
case BT_NAME:
case BT_MINUS:
if (nmstrt) {
result |= MOZ_EXPAT_MALFORMED;
nmstrt = 0;
}
break;
default:
result |= MOZ_EXPAT_INVALID_CHARACTER;
nmstrt = 0;
}
ptr += 2;
} while (ptr != end);
return result;
}
示例11: PREFIX
static int PTRCALL
PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
const char *end, const char **nextTokPtr)
{
const char *start;
if (ptr >= end)
return XML_TOK_NONE;
else if (! HAS_CHAR(enc, ptr, end)) {
/* This line cannot be executed. The incoming data has already
* been tokenized once, so incomplete characters like this have
* already been eliminated from the input. Retaining the paranoia
* check is still valuable, however.
*/
return XML_TOK_PARTIAL; /* LCOV_EXCL_LINE */
}
start = ptr;
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
#define LEAD_CASE(n) \
case BT_LEAD ## n: ptr += n; break;
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
#undef LEAD_CASE
case BT_AMP:
if (ptr == start)
return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
*nextTokPtr = ptr;
return XML_TOK_DATA_CHARS;
case BT_PERCNT:
if (ptr == start) {
int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc),
end, nextTokPtr);
return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok;
}
*nextTokPtr = ptr;
return XML_TOK_DATA_CHARS;
case BT_LF:
if (ptr == start) {
*nextTokPtr = ptr + MINBPC(enc);
return XML_TOK_DATA_NEWLINE;
}
*nextTokPtr = ptr;
return XML_TOK_DATA_CHARS;
case BT_CR:
if (ptr == start) {
ptr += MINBPC(enc);
if (! HAS_CHAR(enc, ptr, end))
return XML_TOK_TRAILING_CR;
if (BYTE_TYPE(enc, ptr) == BT_LF)
ptr += MINBPC(enc);
*nextTokPtr = ptr;
return XML_TOK_DATA_NEWLINE;
}
*nextTokPtr = ptr;
return XML_TOK_DATA_CHARS;
default:
ptr += MINBPC(enc);
break;
}
}
*nextTokPtr = ptr;
return XML_TOK_DATA_CHARS;
}