mirror of
https://github.com/RPCS3/cereal.git
synced 2025-03-04 13:37:05 +00:00
Wrapping up external code in cereal namespace
Covers base64 and rapidxml, still need to do json see #121
This commit is contained in:
parent
1479f8e635
commit
7a3933ff0f
146
include/cereal/external/base64.hpp
vendored
146
include/cereal/external/base64.hpp
vendored
@ -27,99 +27,103 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace base64
|
||||
namespace cereal
|
||||
{
|
||||
static const std::string chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
namespace base64
|
||||
{
|
||||
static const std::string chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
static inline bool is_base64(unsigned char c) {
|
||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||
}
|
||||
static inline bool is_base64(unsigned char c) {
|
||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||
}
|
||||
|
||||
inline std::string encode(unsigned char const* bytes_to_encode, size_t in_len) {
|
||||
std::string ret;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
unsigned char char_array_3[3];
|
||||
unsigned char char_array_4[4];
|
||||
inline std::string encode(unsigned char const* bytes_to_encode, size_t in_len) {
|
||||
std::string ret;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
unsigned char char_array_3[3];
|
||||
unsigned char char_array_4[4];
|
||||
|
||||
while (in_len--) {
|
||||
char_array_3[i++] = *(bytes_to_encode++);
|
||||
if (i == 3) {
|
||||
char_array_4[0] = (unsigned char) ((char_array_3[0] & 0xfc) >> 2);
|
||||
char_array_4[1] = (unsigned char) ( ( ( char_array_3[0] & 0x03 ) << 4 ) + ( ( char_array_3[1] & 0xf0 ) >> 4 ) );
|
||||
char_array_4[2] = (unsigned char) ( ( ( char_array_3[1] & 0x0f ) << 2 ) + ( ( char_array_3[2] & 0xc0 ) >> 6 ) );
|
||||
char_array_4[3] = (unsigned char) ( char_array_3[2] & 0x3f );
|
||||
while (in_len--) {
|
||||
char_array_3[i++] = *(bytes_to_encode++);
|
||||
if (i == 3) {
|
||||
char_array_4[0] = (unsigned char) ((char_array_3[0] & 0xfc) >> 2);
|
||||
char_array_4[1] = (unsigned char) ( ( ( char_array_3[0] & 0x03 ) << 4 ) + ( ( char_array_3[1] & 0xf0 ) >> 4 ) );
|
||||
char_array_4[2] = (unsigned char) ( ( ( char_array_3[1] & 0x0f ) << 2 ) + ( ( char_array_3[2] & 0xc0 ) >> 6 ) );
|
||||
char_array_4[3] = (unsigned char) ( char_array_3[2] & 0x3f );
|
||||
|
||||
for(i = 0; (i <4) ; i++)
|
||||
ret += chars[char_array_4[i]];
|
||||
i = 0;
|
||||
for(i = 0; (i <4) ; i++)
|
||||
ret += chars[char_array_4[i]];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
for(j = i; j < 3; j++)
|
||||
char_array_3[j] = '\0';
|
||||
if (i)
|
||||
{
|
||||
for(j = i; j < 3; j++)
|
||||
char_array_3[j] = '\0';
|
||||
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for (j = 0; (j < i + 1); j++)
|
||||
ret += chars[char_array_4[j]];
|
||||
for (j = 0; (j < i + 1); j++)
|
||||
ret += chars[char_array_4[j]];
|
||||
|
||||
while((i++ < 3))
|
||||
ret += '=';
|
||||
while((i++ < 3))
|
||||
ret += '=';
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
inline std::string decode(std::string const& encoded_string) {
|
||||
size_t in_len = encoded_string.size();
|
||||
size_t i = 0;
|
||||
size_t j = 0;
|
||||
int in_ = 0;
|
||||
unsigned char char_array_4[4], char_array_3[3];
|
||||
std::string ret;
|
||||
|
||||
}
|
||||
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||
if (i ==4) {
|
||||
for (i = 0; i <4; i++)
|
||||
char_array_4[i] = (unsigned char) chars.find( char_array_4[i] );
|
||||
|
||||
inline std::string decode(std::string const& encoded_string) {
|
||||
size_t in_len = encoded_string.size();
|
||||
size_t i = 0;
|
||||
size_t j = 0;
|
||||
int in_ = 0;
|
||||
unsigned char char_array_4[4], char_array_3[3];
|
||||
std::string ret;
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||
if (i ==4) {
|
||||
for (i = 0; i <4; i++)
|
||||
char_array_4[i] = (unsigned char) chars.find( char_array_4[i] );
|
||||
for (i = 0; (i < 3); i++)
|
||||
ret += char_array_3[i];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i) {
|
||||
for (j = i; j <4; j++)
|
||||
char_array_4[j] = 0;
|
||||
|
||||
for (j = 0; j <4; j++)
|
||||
char_array_4[j] = (unsigned char) chars.find( char_array_4[j] );
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (i = 0; (i < 3); i++)
|
||||
ret += char_array_3[i];
|
||||
i = 0;
|
||||
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace base64
|
||||
} // namespace cereal
|
||||
|
||||
if (i) {
|
||||
for (j = i; j <4; j++)
|
||||
char_array_4[j] = 0;
|
||||
|
||||
for (j = 0; j <4; j++)
|
||||
char_array_4[j] = (unsigned char) chars.find( char_array_4[j] );
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // base64
|
||||
#endif // CEREAL_EXTERNAL_BASE64_HPP_
|
||||
|
122
include/cereal/external/rapidxml/rapidxml.hpp
vendored
122
include/cereal/external/rapidxml/rapidxml.hpp
vendored
@ -1,12 +1,12 @@
|
||||
#ifndef RAPIDXML_HPP_INCLUDED
|
||||
#define RAPIDXML_HPP_INCLUDED
|
||||
#ifndef CEREAL_RAPIDXML_HPP_INCLUDED
|
||||
#define CEREAL_RAPIDXML_HPP_INCLUDED
|
||||
|
||||
// Copyright (C) 2006, 2009 Marcin Kalicinski
|
||||
// Version 1.13
|
||||
// Revision $DateTime: 2009/05/13 01:46:17 $
|
||||
|
||||
// If standard library is disabled, user must provide implementations of required functions and typedefs
|
||||
#if !defined(RAPIDXML_NO_STDLIB)
|
||||
#if !defined(CEREAL_RAPIDXML_NO_STDLIB)
|
||||
#include <cstdlib> // For std::size_t
|
||||
#include <cassert> // For assert
|
||||
#include <new> // For placement new
|
||||
@ -21,15 +21,16 @@
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RAPIDXML_PARSE_ERROR
|
||||
// CEREAL_RAPIDXML_PARSE_ERROR
|
||||
|
||||
#if defined(RAPIDXML_NO_EXCEPTIONS)
|
||||
#if defined(CEREAL_RAPIDXML_NO_EXCEPTIONS)
|
||||
|
||||
#define RAPIDXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); }
|
||||
#define CEREAL_RAPIDXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); }
|
||||
|
||||
namespace cereal {
|
||||
namespace rapidxml
|
||||
{
|
||||
//! When exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS,
|
||||
//! When exceptions are disabled by defining CEREAL_RAPIDXML_NO_EXCEPTIONS,
|
||||
//! this function is called to notify user about the error.
|
||||
//! It must be defined by the user.
|
||||
//! <br><br>
|
||||
@ -47,13 +48,15 @@ namespace rapidxml
|
||||
//! \param where Pointer to character data where error was detected.
|
||||
void parse_error_handler(const char *what, void *where);
|
||||
}
|
||||
} // end namespace cereal
|
||||
|
||||
#else
|
||||
|
||||
#include <exception> // For std::exception
|
||||
|
||||
#define RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where)
|
||||
#define CEREAL_RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where)
|
||||
|
||||
namespace cereal {
|
||||
namespace rapidxml
|
||||
{
|
||||
|
||||
@ -63,7 +66,7 @@ namespace rapidxml
|
||||
//! Use where() function to get a pointer to position within source text where error was detected.
|
||||
//! <br><br>
|
||||
//! If throwing exceptions by the parser is undesirable,
|
||||
//! it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included.
|
||||
//! it can be disabled by defining CEREAL_RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included.
|
||||
//! This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception.
|
||||
//! This function must be defined by the user.
|
||||
//! <br><br>
|
||||
@ -103,34 +106,36 @@ namespace rapidxml
|
||||
|
||||
};
|
||||
}
|
||||
} // end namespace cereal
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Pool sizes
|
||||
|
||||
#ifndef RAPIDXML_STATIC_POOL_SIZE
|
||||
#ifndef CEREAL_RAPIDXML_STATIC_POOL_SIZE
|
||||
// Size of static memory block of memory_pool.
|
||||
// Define RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.
|
||||
// Define CEREAL_RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.
|
||||
// No dynamic memory allocations are performed by memory_pool until static memory is exhausted.
|
||||
#define RAPIDXML_STATIC_POOL_SIZE (64 * 1024)
|
||||
#define CEREAL_RAPIDXML_STATIC_POOL_SIZE (64 * 1024)
|
||||
#endif
|
||||
|
||||
#ifndef RAPIDXML_DYNAMIC_POOL_SIZE
|
||||
#ifndef CEREAL_RAPIDXML_DYNAMIC_POOL_SIZE
|
||||
// Size of dynamic memory block of memory_pool.
|
||||
// Define RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.
|
||||
// Define CEREAL_RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.
|
||||
// After the static block is exhausted, dynamic blocks with approximately this size are allocated by memory_pool.
|
||||
#define RAPIDXML_DYNAMIC_POOL_SIZE (64 * 1024)
|
||||
#define CEREAL_RAPIDXML_DYNAMIC_POOL_SIZE (64 * 1024)
|
||||
#endif
|
||||
|
||||
#ifndef RAPIDXML_ALIGNMENT
|
||||
#ifndef CEREAL_RAPIDXML_ALIGNMENT
|
||||
// Memory allocation alignment.
|
||||
// Define RAPIDXML_ALIGNMENT before including rapidxml.hpp if you want to override the default value, which is the size of pointer.
|
||||
// Define CEREAL_RAPIDXML_ALIGNMENT before including rapidxml.hpp if you want to override the default value, which is the size of pointer.
|
||||
// All memory allocations for nodes, attributes and strings will be aligned to this value.
|
||||
// This must be a power of 2 and at least 1, otherwise memory_pool will not work.
|
||||
#define RAPIDXML_ALIGNMENT sizeof(void *)
|
||||
#define CEREAL_RAPIDXML_ALIGNMENT sizeof(void *)
|
||||
#endif
|
||||
|
||||
namespace cereal {
|
||||
namespace rapidxml
|
||||
{
|
||||
// Forward declarations
|
||||
@ -366,20 +371,20 @@ namespace rapidxml
|
||||
//! It is also possible to create a standalone memory_pool, and use it
|
||||
//! to allocate nodes, whose lifetime will not be tied to any document.
|
||||
//! <br><br>
|
||||
//! Pool maintains <code>RAPIDXML_STATIC_POOL_SIZE</code> bytes of statically allocated memory.
|
||||
//! Pool maintains <code>CEREAL_RAPIDXML_STATIC_POOL_SIZE</code> bytes of statically allocated memory.
|
||||
//! Until static memory is exhausted, no dynamic memory allocations are done.
|
||||
//! When static memory is exhausted, pool allocates additional blocks of memory of size <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> each,
|
||||
//! When static memory is exhausted, pool allocates additional blocks of memory of size <code>CEREAL_RAPIDXML_DYNAMIC_POOL_SIZE</code> each,
|
||||
//! by using global <code>new[]</code> and <code>delete[]</code> operators.
|
||||
//! This behaviour can be changed by setting custom allocation routines.
|
||||
//! Use set_allocator() function to set them.
|
||||
//! <br><br>
|
||||
//! Allocations for nodes, attributes and strings are aligned at <code>RAPIDXML_ALIGNMENT</code> bytes.
|
||||
//! Allocations for nodes, attributes and strings are aligned at <code>CEREAL_RAPIDXML_ALIGNMENT</code> bytes.
|
||||
//! This value defaults to the size of pointer on target architecture.
|
||||
//! <br><br>
|
||||
//! To obtain absolutely top performance from the parser,
|
||||
//! it is important that all nodes are allocated from a single, contiguous block of memory.
|
||||
//! Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably.
|
||||
//! If required, you can tweak <code>RAPIDXML_STATIC_POOL_SIZE</code>, <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> and <code>RAPIDXML_ALIGNMENT</code>
|
||||
//! If required, you can tweak <code>CEREAL_RAPIDXML_STATIC_POOL_SIZE</code>, <code>CEREAL_RAPIDXML_DYNAMIC_POOL_SIZE</code> and <code>CEREAL_RAPIDXML_ALIGNMENT</code>
|
||||
//! to obtain best wasted memory to performance compromise.
|
||||
//! To do it, define their values before rapidxml.hpp file is included.
|
||||
//! \param Ch Character type of created nodes.
|
||||
@ -412,7 +417,7 @@ namespace rapidxml
|
||||
|
||||
//! Allocates a new node from the pool, and optionally assigns name and value to it.
|
||||
//! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.
|
||||
//! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function
|
||||
//! If exceptions are disabled by defining CEREAL_RAPIDXML_NO_EXCEPTIONS, this function
|
||||
//! will call rapidxml::parse_error_handler() function.
|
||||
//! \param type Type of node to create.
|
||||
//! \param name Name to assign to the node, or 0 to assign no name.
|
||||
@ -445,7 +450,7 @@ namespace rapidxml
|
||||
|
||||
//! Allocates a new attribute from the pool, and optionally assigns name and value to it.
|
||||
//! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.
|
||||
//! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function
|
||||
//! If exceptions are disabled by defining CEREAL_RAPIDXML_NO_EXCEPTIONS, this function
|
||||
//! will call rapidxml::parse_error_handler() function.
|
||||
//! \param name Name to assign to the attribute, or 0 to assign no name.
|
||||
//! \param value Value to assign to the attribute, or 0 to assign no value.
|
||||
@ -476,7 +481,7 @@ namespace rapidxml
|
||||
|
||||
//! Allocates a char array of given size from the pool, and optionally copies a given string to it.
|
||||
//! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.
|
||||
//! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function
|
||||
//! If exceptions are disabled by defining CEREAL_RAPIDXML_NO_EXCEPTIONS, this function
|
||||
//! will call rapidxml::parse_error_handler() function.
|
||||
//! \param source String to initialize the allocated memory with, or 0 to not initialize it.
|
||||
//! \param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated.
|
||||
@ -580,7 +585,7 @@ namespace rapidxml
|
||||
|
||||
char *align(char *ptr)
|
||||
{
|
||||
std::size_t alignment = ((RAPIDXML_ALIGNMENT - (std::size_t(ptr) & (RAPIDXML_ALIGNMENT - 1))) & (RAPIDXML_ALIGNMENT - 1));
|
||||
std::size_t alignment = ((CEREAL_RAPIDXML_ALIGNMENT - (std::size_t(ptr) & (CEREAL_RAPIDXML_ALIGNMENT - 1))) & (CEREAL_RAPIDXML_ALIGNMENT - 1));
|
||||
return ptr + alignment;
|
||||
}
|
||||
|
||||
@ -596,9 +601,9 @@ namespace rapidxml
|
||||
else
|
||||
{
|
||||
memory = new char[size];
|
||||
#ifdef RAPIDXML_NO_EXCEPTIONS
|
||||
#ifdef CEREAL_RAPIDXML_NO_EXCEPTIONS
|
||||
if (!memory) // If exceptions are disabled, verify memory allocation, because new will not be able to throw bad_alloc
|
||||
RAPIDXML_PARSE_ERROR("out of memory", 0);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("out of memory", 0);
|
||||
#endif
|
||||
}
|
||||
return static_cast<char *>(memory);
|
||||
@ -612,13 +617,13 @@ namespace rapidxml
|
||||
// If not enough memory left in current pool, allocate a new pool
|
||||
if (result + size > m_end)
|
||||
{
|
||||
// Calculate required pool size (may be bigger than RAPIDXML_DYNAMIC_POOL_SIZE)
|
||||
std::size_t pool_size = RAPIDXML_DYNAMIC_POOL_SIZE;
|
||||
// Calculate required pool size (may be bigger than CEREAL_RAPIDXML_DYNAMIC_POOL_SIZE)
|
||||
std::size_t pool_size = CEREAL_RAPIDXML_DYNAMIC_POOL_SIZE;
|
||||
if (pool_size < size)
|
||||
pool_size = size;
|
||||
|
||||
// Allocate
|
||||
std::size_t alloc_size = sizeof(header) + (2 * RAPIDXML_ALIGNMENT - 2) + pool_size; // 2 alignments required in worst case: one for header, one for actual allocation
|
||||
std::size_t alloc_size = sizeof(header) + (2 * CEREAL_RAPIDXML_ALIGNMENT - 2) + pool_size; // 2 alignments required in worst case: one for header, one for actual allocation
|
||||
char *raw_memory = allocate_raw(alloc_size);
|
||||
|
||||
// Setup new pool in allocated memory
|
||||
@ -641,7 +646,7 @@ namespace rapidxml
|
||||
char *m_begin; // Start of raw memory making up current pool
|
||||
char *m_ptr; // First free byte in current pool
|
||||
char *m_end; // One past last available byte in current pool
|
||||
char m_static_memory[RAPIDXML_STATIC_POOL_SIZE]; // Static raw memory
|
||||
char m_static_memory[CEREAL_RAPIDXML_STATIC_POOL_SIZE]; // Static raw memory
|
||||
alloc_func *m_alloc_func; // Allocator function, or 0 if default is to be used
|
||||
free_func *m_free_func; // Free function, or 0 if default is to be used
|
||||
};
|
||||
@ -1413,7 +1418,7 @@ namespace rapidxml
|
||||
this->append_node(node);
|
||||
}
|
||||
else
|
||||
RAPIDXML_PARSE_ERROR("expected <", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected <", text);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1556,7 +1561,7 @@ namespace rapidxml
|
||||
}
|
||||
else // Invalid, only codes up to 0x10FFFF are allowed in Unicode
|
||||
{
|
||||
RAPIDXML_PARSE_ERROR("invalid numeric character entity", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("invalid numeric character entity", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1687,7 +1692,7 @@ namespace rapidxml
|
||||
if (*src == Ch(';'))
|
||||
++src;
|
||||
else
|
||||
RAPIDXML_PARSE_ERROR("expected ;", src);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected ;", src);
|
||||
continue;
|
||||
|
||||
// Something else
|
||||
@ -1752,7 +1757,7 @@ namespace rapidxml
|
||||
while (text[0] != Ch('?') || text[1] != Ch('>'))
|
||||
{
|
||||
if (!text[0])
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
++text;
|
||||
}
|
||||
text += 2; // Skip '?>'
|
||||
@ -1770,7 +1775,7 @@ namespace rapidxml
|
||||
|
||||
// Skip ?>
|
||||
if (text[0] != Ch('?') || text[1] != Ch('>'))
|
||||
RAPIDXML_PARSE_ERROR("expected ?>", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected ?>", text);
|
||||
text += 2;
|
||||
|
||||
return declaration;
|
||||
@ -1787,7 +1792,7 @@ namespace rapidxml
|
||||
while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))
|
||||
{
|
||||
if (!text[0])
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
++text;
|
||||
}
|
||||
text += 3; // Skip '-->'
|
||||
@ -1801,7 +1806,7 @@ namespace rapidxml
|
||||
while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))
|
||||
{
|
||||
if (!text[0])
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
++text;
|
||||
}
|
||||
|
||||
@ -1843,7 +1848,7 @@ namespace rapidxml
|
||||
{
|
||||
case Ch('['): ++depth; break;
|
||||
case Ch(']'): --depth; break;
|
||||
case 0: RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
case 0: CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
}
|
||||
++text;
|
||||
}
|
||||
@ -1852,7 +1857,7 @@ namespace rapidxml
|
||||
|
||||
// Error on end of text
|
||||
case Ch('\0'):
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
|
||||
// Other character, skip it
|
||||
default:
|
||||
@ -1897,7 +1902,7 @@ namespace rapidxml
|
||||
Ch *name_ = text;
|
||||
skip<node_name_pred, Flags>(text);
|
||||
if (text == name_)
|
||||
RAPIDXML_PARSE_ERROR("expected PI target", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected PI target", text);
|
||||
pi->name(name_, text - name_);
|
||||
|
||||
// Skip whitespace between pi target and pi
|
||||
@ -1910,7 +1915,7 @@ namespace rapidxml
|
||||
while (text[0] != Ch('?') || text[1] != Ch('>'))
|
||||
{
|
||||
if (*text == Ch('\0'))
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
++text;
|
||||
}
|
||||
|
||||
@ -1933,7 +1938,7 @@ namespace rapidxml
|
||||
while (text[0] != Ch('?') || text[1] != Ch('>'))
|
||||
{
|
||||
if (*text == Ch('\0'))
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
++text;
|
||||
}
|
||||
text += 2; // Skip '?>'
|
||||
@ -2014,7 +2019,7 @@ namespace rapidxml
|
||||
while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))
|
||||
{
|
||||
if (!text[0])
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
++text;
|
||||
}
|
||||
text += 3; // Skip ]]>
|
||||
@ -2026,7 +2031,7 @@ namespace rapidxml
|
||||
while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))
|
||||
{
|
||||
if (!text[0])
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
++text;
|
||||
}
|
||||
|
||||
@ -2053,7 +2058,7 @@ namespace rapidxml
|
||||
Ch *name_ = text;
|
||||
skip<node_name_pred, Flags>(text);
|
||||
if (text == name_)
|
||||
RAPIDXML_PARSE_ERROR("expected element name", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected element name", text);
|
||||
element->name(name_, text - name_);
|
||||
|
||||
// Skip whitespace between element name and attributes or >
|
||||
@ -2072,11 +2077,11 @@ namespace rapidxml
|
||||
{
|
||||
++text;
|
||||
if (*text != Ch('>'))
|
||||
RAPIDXML_PARSE_ERROR("expected >", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected >", text);
|
||||
++text;
|
||||
}
|
||||
else
|
||||
RAPIDXML_PARSE_ERROR("expected >", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected >", text);
|
||||
|
||||
// Place zero terminator after name
|
||||
if (!(Flags & parse_no_string_terminators))
|
||||
@ -2163,7 +2168,7 @@ namespace rapidxml
|
||||
while (*text != Ch('>'))
|
||||
{
|
||||
if (*text == 0)
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
++text;
|
||||
}
|
||||
++text; // Skip '>'
|
||||
@ -2212,7 +2217,7 @@ namespace rapidxml
|
||||
Ch *closing_name = text;
|
||||
skip<node_name_pred, Flags>(text);
|
||||
if (!internal::compare(node->name(), node->name_size(), closing_name, text - closing_name, true))
|
||||
RAPIDXML_PARSE_ERROR("invalid closing tag name", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("invalid closing tag name", text);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2222,7 +2227,7 @@ namespace rapidxml
|
||||
// Skip remaining whitespace after node name
|
||||
skip<whitespace_pred, Flags>(text);
|
||||
if (*text != Ch('>'))
|
||||
RAPIDXML_PARSE_ERROR("expected >", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected >", text);
|
||||
++text; // Skip '>'
|
||||
|
||||
if (contents_end && contents_end != contents_start)
|
||||
@ -2243,7 +2248,7 @@ namespace rapidxml
|
||||
|
||||
// End of data - error
|
||||
case Ch('\0'):
|
||||
RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("unexpected end of data", text);
|
||||
|
||||
// Data node
|
||||
default:
|
||||
@ -2266,7 +2271,7 @@ namespace rapidxml
|
||||
++text; // Skip first character of attribute name
|
||||
skip<attribute_name_pred, Flags>(text);
|
||||
if (text == name_)
|
||||
RAPIDXML_PARSE_ERROR("expected attribute name", name_);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected attribute name", name_);
|
||||
|
||||
// Create new attribute
|
||||
xml_attribute<Ch> *attribute = this->allocate_attribute();
|
||||
@ -2278,7 +2283,7 @@ namespace rapidxml
|
||||
|
||||
// Skip =
|
||||
if (*text != Ch('='))
|
||||
RAPIDXML_PARSE_ERROR("expected =", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected =", text);
|
||||
++text;
|
||||
|
||||
// Add terminating zero after name
|
||||
@ -2291,7 +2296,7 @@ namespace rapidxml
|
||||
// Skip quote and remember if it was ' or "
|
||||
Ch quote = *text;
|
||||
if (quote != Ch('\'') && quote != Ch('"'))
|
||||
RAPIDXML_PARSE_ERROR("expected ' or \"", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected ' or \"", text);
|
||||
++text;
|
||||
|
||||
// Extract attribute value and expand char refs in it
|
||||
@ -2307,7 +2312,7 @@ namespace rapidxml
|
||||
|
||||
// Make sure that end quote is present
|
||||
if (*text != quote)
|
||||
RAPIDXML_PARSE_ERROR("expected ' or \"", text);
|
||||
CEREAL_RAPIDXML_PARSE_ERROR("expected ' or \"", text);
|
||||
++text; // Skip quote
|
||||
|
||||
// Add terminating zero after value
|
||||
@ -2606,9 +2611,10 @@ namespace rapidxml
|
||||
//! \endcond
|
||||
|
||||
}
|
||||
} // end namespace cereal
|
||||
|
||||
// Undefine internal macros
|
||||
#undef RAPIDXML_PARSE_ERROR
|
||||
#undef CEREAL_RAPIDXML_PARSE_ERROR
|
||||
|
||||
// On MSVC, restore warnings state
|
||||
#ifdef _MSC_VER
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED
|
||||
#define RAPIDXML_ITERATORS_HPP_INCLUDED
|
||||
#ifndef CEREAL_RAPIDXML_ITERATORS_HPP_INCLUDED
|
||||
#define CEREAL_RAPIDXML_ITERATORS_HPP_INCLUDED
|
||||
|
||||
// Copyright (C) 2006, 2009 Marcin Kalicinski
|
||||
// Version 1.13
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include "rapidxml.hpp"
|
||||
|
||||
namespace cereal {
|
||||
namespace rapidxml
|
||||
{
|
||||
|
||||
@ -169,5 +170,6 @@ namespace rapidxml
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef RAPIDXML_PRINT_HPP_INCLUDED
|
||||
#define RAPIDXML_PRINT_HPP_INCLUDED
|
||||
#ifndef CEREAL_RAPIDXML_PRINT_HPP_INCLUDED
|
||||
#define CEREAL_RAPIDXML_PRINT_HPP_INCLUDED
|
||||
|
||||
// Copyright (C) 2006, 2009 Marcin Kalicinski
|
||||
// Version 1.13
|
||||
@ -8,11 +8,12 @@
|
||||
#include "rapidxml.hpp"
|
||||
|
||||
// Only include streams if not disabled
|
||||
#ifndef RAPIDXML_NO_STREAMS
|
||||
#ifndef CEREAL_RAPIDXML_NO_STREAMS
|
||||
#include <ostream>
|
||||
#include <iterator>
|
||||
#endif
|
||||
|
||||
namespace cereal {
|
||||
namespace rapidxml
|
||||
{
|
||||
|
||||
@ -393,7 +394,7 @@ namespace rapidxml
|
||||
return internal::print_node(out, &node, flags, 0);
|
||||
}
|
||||
|
||||
#ifndef RAPIDXML_NO_STREAMS
|
||||
#ifndef CEREAL_RAPIDXML_NO_STREAMS
|
||||
|
||||
//! Prints XML to given output stream.
|
||||
//! \param out Output stream to print to.
|
||||
@ -420,5 +421,6 @@ namespace rapidxml
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef RAPIDXML_UTILS_HPP_INCLUDED
|
||||
#define RAPIDXML_UTILS_HPP_INCLUDED
|
||||
#ifndef CEREAL_RAPIDXML_UTILS_HPP_INCLUDED
|
||||
#define CEREAL_RAPIDXML_UTILS_HPP_INCLUDED
|
||||
|
||||
// Copyright (C) 2006, 2009 Marcin Kalicinski
|
||||
// Version 1.13
|
||||
@ -12,6 +12,7 @@
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace cereal {
|
||||
namespace rapidxml
|
||||
{
|
||||
|
||||
@ -117,5 +118,6 @@ namespace rapidxml
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace cereal
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user