17 template<
typename LOC,
typename STR>
34 virtual bool operator()
35 (
const typename STR::charType*)
47 if (!!config && (
length == 0))
54 template<
typename LOC,
typename STR>
64 virtual bool operator()
65 (
const typename STR::charType*)
override 73 template <
typename LOC,
typename STR>
84 switch (t.getBaseType())
93 translate_string.reset(
new TranslateStringFloat<LOC, STR>(config, sink, onError));
101 (
const typename STR::charType* val)
override 103 return (*translate_string)(STR((
typename STR::charType*)val, this->
length));
107 std::unique_ptr<TranslateString<LOC, STR>> translate_string;
110 template <
typename LOC,
typename STR>
120 translate_string(ts),
121 is_delim((
sizeof(
typename STR::charType) == 1) ? 256 : 65536)
124 for (
size_t i(0); i < delims.getLength(); ++i)
126 utf16_t ch(delims.toUtf16()[i]);
127 if (ch < is_delim.size())
133 (
const typename STR::charType* val)
override 135 STR v((
typename STR::charType*)val, this->
length);
136 while (v.length && is_delim[v.data[v.length - 1]])
139 return (!v.length || (*translate_string)(v));
143 std::unique_ptr<TranslateString<LOC, STR>> translate_string;
145 std::vector<bool> is_delim;
150 template <
typename LOC,
typename STR,
bool SIGNED, u
int SIZE>
162 virtual bool operator()
163 (
const typename STR::charType* val)
override 166 memcpy(&v, val, SIZE);
167 if (SIGNED &&
int8(*(val + SIZE - 1)) < 0)
169 return this->sink->
set(this->
loc, v);
173 template <
typename LOC,
typename STR>
185 virtual bool operator()
186 (
const typename STR::charType* val)
override 192 template <
typename LOC,
typename STR>
204 virtual bool operator()
205 (
const typename STR::charType* val)
override 207 return this->sink->
set(this->
loc,
int64(*reinterpret_cast<const int8*>(val)));
211 template <
typename LOC,
typename STR>
223 virtual bool operator()
224 (
const typename STR::charType* val)
override 226 return this->sink->
set(this->
loc,
int64(*reinterpret_cast<const uint16*>(val)));
230 template <
typename LOC,
typename STR>
242 virtual bool operator()
243 (
const typename STR::charType* val)
override 245 return this->sink->
set(this->
loc,
int64(*reinterpret_cast<const int16*>(val)));
249 template <
typename LOC,
typename STR>
261 virtual bool operator()
262 (
const typename STR::charType* val)
override 264 return this->sink->
set(this->
loc,
int64(*reinterpret_cast<const uint32*>(val)));
268 template <
typename LOC,
typename STR>
280 virtual bool operator()
281 (
const typename STR::charType* val)
override 283 return this->sink->
set(this->
loc,
int64(*reinterpret_cast<const int32*>(val)));
286 template <
typename LOC,
typename STR>
298 virtual bool operator()
299 (
const typename STR::charType* val)
override 301 return this->sink->
set(this->
loc,
int64(*reinterpret_cast<const uint64*>(val)));
305 template <
typename LOC,
typename STR>
317 virtual bool operator()
318 (
const typename STR::charType* val)
override 320 return this->sink->
set(this->
loc, *reinterpret_cast<const int64*>(val));
328 template<
typename LOC,
typename STR>
387 #ifdef XPACE_DECIMAL_FLOAT_H
const Xpace_Char16 Xpace_Data_Type type
virtual RET set(LOC location, int64 value)
Write an int64.
Each high-level Xpace object has a Configuration.
A string, Unicode UTF-16 and reference-counted.
TranslatePtr(const Configuration &config, BaseDataType t, Sink< LOC > *sink, TranslationError onErr=default_on_error)
virtual bool isSkip() const
bool getValueBool(const String &tag=String()) const
type getDerivedType() const
Can't find a named value.
int64 getValueInt(const String &tag=String(), int64 def=0, bool *ok=0) const
String getValue(const String &tag=String()) const
get a node's value or an attribute search for attribute first, then child value
static TranslatePtr * create(const Configuration &config, Sink< LOC > *sink, TranslationError onError=default_on_error)
static const char * NUMERAL_TAG
static const char * DELIMS_TAG
static const char * SUBTYPE_TAG
static const char * VECTOR_TAG
static const char * LENGTH_TAG
Translate content Input can be anything Output is to a Sink<LOC> so must be one of its supported type...
std::function< bool(utf16_t ch, const String &term)> TranslationError
Called on translation error.
Xpace project main namespace
bool default_on_error(utf16_t, const String &)
Default error handler.
Copyright (C) 2012 Xpace, LLC.