version 1.6.4.2, 2009/09/03 13:54:05
|
version 1.6.4.6, 2009/10/27 18:38:08
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, |
}; | }; |
| |
|
// If _isSpecialChar7[ch] is true, then ch is a special character, which must |
|
// have a special encoding in XML. But only use 7-biat ASCII characters to |
|
// index this array. |
|
static const int _isNormalChar7[] = |
|
{ |
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1, |
|
1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1, |
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0, |
|
}; |
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
Buffer& operator<<(Buffer& out, const Char16& x) | Buffer& operator<<(Buffer& out, const Char16& x) |
|
|
STRLIT("TYPE=\"instance\"") | STRLIT("TYPE=\"instance\"") |
}; | }; |
| |
|
const StrLit XmlGenerator::_XmlWriterKeyTypeStrings[17] = |
|
{ |
|
STRLIT("boolean"), STRLIT("numeric"), |
|
STRLIT("numeric"), STRLIT("numeric"), |
|
STRLIT("numeric"), STRLIT("numeric"), |
|
STRLIT("numeric"), STRLIT("numeric"), |
|
STRLIT("numeric"), STRLIT("numeric"), |
|
STRLIT("numeric"), STRLIT("string"), |
|
STRLIT("string"), STRLIT("string"), |
|
/* The following are not valid values for a keytype, but left in here |
|
so in case something is going wrong it can be easily concluded from the |
|
generated XML */ |
|
STRLIT("reference"), STRLIT("object"), |
|
STRLIT("instance") |
|
}; |
|
|
void XmlGenerator::_appendChar(Buffer& out, const Char16& c) | void XmlGenerator::_appendChar(Buffer& out, const Char16& c) |
{ | { |
// We need to convert the Char16 to UTF8 then append the UTF8 | // We need to convert the Char16 to UTF8 then append the UTF8 |
|
|
} | } |
} | } |
| |
|
// str has to be UTF-8 encoded |
|
// that means the characters used cannot be larger than 7bit ASCII in value |
|
// range |
void XmlGenerator::appendSpecial(Buffer& out, const char* str, Uint32 size) | void XmlGenerator::appendSpecial(Buffer& out, const char* str, Uint32 size) |
{ | { |
// employ loop unrolling and a less checking optimized Buffer access | // employ loop unrolling and a less checking optimized Buffer access |
| |
|
|
// Buffer cannot grow more than 6*size characters (ie. 4*size+2*size) | // Buffer cannot grow more than 6*size characters (ie. 4*size+2*size) |
out.reserveCapacity(out.capacity() + size << 2 + size << 1); |
Uint32 newMaxSize = (size << 2) + (size << 1); |
|
if (out.size() + newMaxSize >= out.capacity()) |
|
{ |
|
out.reserveCapacity(out.capacity() + newMaxSize); |
|
} |
|
|
|
// Before using a loop unrolled algorithm to pick out the special chars |
|
// we are going to assume there is no special char as this is the case most |
|
// of the time anyway |
|
Uint32 sizeStart=size; |
|
const Uint8* p= (const Uint8*) str; |
|
|
|
while (size >= 4 && |
|
(_isNormalChar7[p[0]] | |
|
_isNormalChar7[p[1]] | |
|
_isNormalChar7[p[2]] | |
|
_isNormalChar7[p[3]])) |
|
{ |
|
size -= 4; |
|
p += 4; |
|
} |
|
out.append_unchecked(str,sizeStart-size); |
|
str=(const char*)p; |
| |
while (size>=8) | while (size>=8) |
{ | { |
|
|
} | } |
str++; | str++; |
} | } |
|
|
} | } |
| |
| |