diff --git a/src/Makefile.dep b/src/Makefile.dep index 773aa26..74cf0df 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -3,6 +3,11 @@ ./convert/inttostr.o: ./convert/inttostr.h ./convert/misc.o: ./convert/misc.h ./convert/text.h ./convert/text.o: ./convert/text.h ./convert/text_private.h +./convert/double.o: ./convert/double.h textstream/textstream.h +./convert/double.o: textstream/stream.h space/space.h textstream/types.h +./convert/double.o: convert/inttostr.h utf8/utf8.h utf8/utf8_templates.h +./convert/double.o: utf8/utf8_private.h date/date.h membuffer/membuffer.h +./convert/double.o: textstream/types.h ./date/date.o: ./date/date.h convert/inttostr.h ./log/filelog.o: ./log/filelog.h textstream/textstream.h textstream/stream.h ./log/filelog.o: space/space.h textstream/types.h convert/inttostr.h @@ -18,7 +23,7 @@ ./space/space.o: convert/patternreplacer.h textstream/textstream.h ./space/space.o: textstream/stream.h space/space.h date/date.h ./space/space.o: membuffer/membuffer.h textstream/types.h convert/strtoint.h -./space/space.o: ./convert/text.h ./convert/misc.h +./space/space.o: ./convert/text.h ./convert/misc.h ./convert/double.h ./space/spaceparser.o: ./space/spaceparser.h ./space/space.h ./space/spaceparser.o: textstream/types.h convert/inttostr.h utf8/utf8.h ./space/spaceparser.o: utf8/utf8_templates.h utf8/utf8_private.h diff --git a/src/convert/convert.h b/src/convert/convert.h index 2feb28c..9463e76 100644 --- a/src/convert/convert.h +++ b/src/convert/convert.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2012-2018, Tomasz Sowa + * Copyright (c) 2012-2021, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,5 +43,6 @@ #include "patternreplacer.h" #include "strtoint.h" #include "text.h" +#include "double.h" #endif diff --git a/src/convert/double.cpp b/src/convert/double.cpp new file mode 100644 index 0000000..dc2893f --- /dev/null +++ b/src/convert/double.cpp @@ -0,0 +1,225 @@ +/* + * This file is a part of PikoTools + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2021, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include "double.h" +#include "textstream/textstream.h" + + + +namespace pt +{ + + +float to_float(const char * str, const char ** after) +{ + char * after_local; + float res = std::strtof(str, &after_local); + + if( after ) + { + *after = after_local; + } + + return res; +} + + +float to_float(const wchar_t * str, const wchar_t ** after) +{ + wchar_t * after_local; + float res = std::wcstof(str, &after_local); + + if( after ) + { + *after = after_local; + } + + return res; +} + + +double to_double(const char * str, const char ** after) +{ + char * after_local; + double res = std::strtod(str, &after_local); + + if( after ) + { + *after = after_local; + } + + return res; +} + + +double to_double(const wchar_t * str, const wchar_t ** after) +{ + wchar_t * after_local; + double res = std::wcstod(str, &after_local); + + if( after ) + { + *after = after_local; + } + + return res; +} + + +long double to_long_double(const char * str, const char ** after) +{ + char * after_local; + long double res = std::strtold(str, &after_local); + + if( after ) + { + *after = after_local; + } + + return res; +} + + +long double to_long_double(const wchar_t * str, const wchar_t ** after) +{ + wchar_t * after_local; + long double res = std::wcstold(str, &after_local); + + if( after ) + { + *after = after_local; + } + + return res; +} + + +float to_float(const std::string & str, const char ** after) +{ + return to_float(str.c_str(), after); +} + + +float to_float(const std::wstring & str, const wchar_t ** after) +{ + return to_float(str.c_str(), after); +} + + +double to_double(const std::string & str, const char ** after) +{ + return to_double(str.c_str(), after); +} + +double to_double(const std::wstring & str, const wchar_t ** after) +{ + return to_double(str.c_str(), after); +} + + +long double to_long_double(const std::string & str, const char ** after) +{ + return to_long_double(str.c_str(), after); +} + + +long double to_long_double(const std::wstring & str, const wchar_t ** after) +{ + return to_long_double(str.c_str(), after); +} + + + + + + +std::string to_str(float val) +{ + TextStream str; + str << val; + return str.to_str();; +} + + +std::wstring to_wstr(float val) +{ + TextStream str; + str << val; + return str.to_wstr();; +} + + +std::string to_str(double val) +{ + TextStream str; + str << val; + return str.to_str();; +} + + +std::wstring to_wstr(double val) +{ + TextStream str; + str << val; + return str.to_wstr();; +} + + +std::string to_str(long double val) +{ + TextStream str; + str << val; + return str.to_str();; +} + + +std::wstring to_wstr(long double val) +{ + TextStream str; + str << val; + return str.to_wstr();; +} + + + + + + +} + diff --git a/src/convert/double.h b/src/convert/double.h new file mode 100644 index 0000000..d179767 --- /dev/null +++ b/src/convert/double.h @@ -0,0 +1,80 @@ +/* + * This file is a part of PikoTools + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2021, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef headerfile_picotools_membuffer_convert_double +#define headerfile_picotools_membuffer_convert_double + +#include + + +namespace pt +{ + +float to_float(const char * str, const char ** after = nullptr); +float to_float(const wchar_t * str, const wchar_t ** after = nullptr); + +double to_double(const char * str, const char ** after = nullptr); +double to_double(const wchar_t * str, const wchar_t ** after = nullptr); + +long double to_long_double(const char * str, const char ** after = nullptr); +long double to_long_double(const wchar_t * str, const wchar_t ** after = nullptr); + +float to_float(const std::string & str, const char ** after = nullptr); +float to_float(const std::wstring & str, const wchar_t ** after = nullptr); + +double to_double(const std::string & str, const char ** after = nullptr); +double to_double(const std::wstring & str, const wchar_t ** after = nullptr); + +long double to_long_double(const std::string & str, const char ** after = nullptr); +long double to_long_double(const std::wstring & str, const wchar_t ** after = nullptr); + + + +std::string to_str(float val); +std::wstring to_wstr(float val); + +std::string to_str(double val); +std::wstring to_wstr(double val); + +std::string to_str(long double val); +std::wstring to_wstr(long double val); + + + +} + +#endif diff --git a/src/space/space.cpp b/src/space/space.cpp index 05af2be..3da57c3 100644 --- a/src/space/space.cpp +++ b/src/space/space.cpp @@ -152,6 +152,11 @@ Space::Space(double val) set(val); } +Space::Space(long double val) +{ + initialize(); + set(val); +} Space::Space(const char * str) { @@ -355,6 +360,12 @@ void Space::set(double val) value.value_double = val; } +void Space::set(long double val) +{ + initialize_value_long_double_if_needed(); + value.value_long_double = val; +} + void Space::set(const char * str) { @@ -473,6 +484,11 @@ Space & Space::add(double val) return add_generic(val); } +Space & Space::add(long double val) +{ + return add_generic(val); +} + Space & Space::add(const char * val) { return add_generic(val); @@ -575,6 +591,11 @@ Space & Space::add(const wchar_t * field, double val) return add_generic(field, val); } +Space & Space::add(const wchar_t * field, long double val) +{ + return add_generic(field, val); +} + Space & Space::add(const wchar_t * field, const char * val) { return add_generic(field, val); @@ -678,6 +699,11 @@ Space & Space::add(const std::wstring & field, double val) return add_generic(field, val); } +Space & Space::add(const std::wstring & field, long double val) +{ + return add_generic(field, val); +} + Space & Space::add(const std::wstring & field, const char * val) { return add_generic(field, val); @@ -753,9 +779,14 @@ bool Space::is_double() const return type == type_double; } +bool Space::is_long_double() const +{ + return type == type_long_double; +} + bool Space::is_numeric() const { - return is_long_long() || is_float() || is_double(); + return is_long_long() || is_float() || is_double() || is_long_double(); } bool Space::is_str() const @@ -835,6 +866,9 @@ long long Space::to_long_long() const case type_double: return static_cast(value.value_double); + case type_long_double: + return static_cast(value.value_long_double); + case type_string: return convert_string_to_long_long(); @@ -931,6 +965,9 @@ unsigned long long Space::to_ulong_long() const case type_double: return static_cast(value.value_double); + case type_long_double: + return static_cast(value.value_long_double); + case type_string: return convert_string_to_ulong_long(); @@ -943,6 +980,112 @@ unsigned long long Space::to_ulong_long() const +float Space::to_float() const +{ + switch(type) + { + case type_null: + case type_object: + case type_table: + return 0; + + case type_bool: + return value.value_bool ? 1.0f : 0.0f; + + case type_long: + return static_cast(value.value_long); + + case type_float: + return value.value_float; + + case type_double: + return static_cast(value.value_double); + + case type_long_double: + return static_cast(value.value_long_double); + + case type_string: + return pt::to_float(value.value_string); + + case type_wstring: + return pt::to_float(value.value_wstring); + } + + return 0; +} + +double Space::to_double() const +{ + switch(type) + { + case type_null: + case type_object: + case type_table: + return 0; + + case type_bool: + return value.value_bool ? 1.0 : 0.0; + + case type_long: + return static_cast(value.value_long); + + case type_float: + return static_cast(value.value_float); + + case type_double: + return value.value_double; + + case type_long_double: + return static_cast(value.value_long_double); + + case type_string: + return pt::to_double(value.value_string); + + case type_wstring: + return pt::to_double(value.value_wstring); + } + + return 0; +} + + +long double Space::to_long_double() const +{ + switch(type) + { + case type_null: + case type_object: + case type_table: + return 0; + + case type_bool: + return value.value_bool ? 1.0 : 0.0; + + case type_long: + return static_cast(value.value_long); + + case type_float: + return static_cast(value.value_float); + + case type_double: + return static_cast(value.value_double); + + case type_long_double: + return value.value_long_double; + + case type_string: + return pt::to_long_double(value.value_string); + + case type_wstring: + return pt::to_long_double(value.value_wstring); + } + + return 0; +} + + + + std::string Space::to_str() const { if( type == type_string ) @@ -1384,6 +1527,11 @@ double * Space::get_double() return type == type_double ? &value.value_double : nullptr; } +long double * Space::get_long_double() +{ + return type == type_long_double ? &value.value_long_double : nullptr; +} + std::string * Space::get_str() { return type == type_string ? &value.value_string : nullptr; @@ -1513,7 +1661,7 @@ bool Space::has_value(const std::wstring & val) const - +// RENAMEME to get_space(...) Space * Space::get_object_field(const wchar_t * field) { if( is_object() ) @@ -1559,6 +1707,12 @@ double * Space::get_double(const wchar_t * field) return space ? space->get_double() : nullptr; } +long double * Space::get_long_double(const wchar_t * field) +{ + Space * space = get_object_field(field); + return space ? space->get_long_double() : nullptr; +} + std::string * Space::get_str(const wchar_t * field) { Space * space = get_object_field(field); @@ -1611,6 +1765,11 @@ const double * Space::get_double() const return type == type_double ? &value.value_double : nullptr; } +const long double * Space::get_long_double() const +{ + return type == type_long_double ? &value.value_long_double : nullptr; +} + const std::string * Space::get_str() const { return type == type_string ? &value.value_string : nullptr; @@ -1703,6 +1862,12 @@ const double * Space::get_double(const wchar_t * field) const return space ? space->get_double() : nullptr; } +const long double * Space::get_long_double(const wchar_t * field) const +{ + const Space * space = get_object_field(field); + return space ? space->get_long_double() : nullptr; +} + const std::string * Space::get_str(const wchar_t * field) const { const Space * space = get_object_field(field); @@ -2186,6 +2351,11 @@ void Space::copy_value_from(const Space & space) value.value_double = space.value.value_double; break; + case type_long_double: + initialize_value_long_double_if_needed(); + value.value_long_double = space.value.value_long_double; + break; + case type_string: initialize_value_string_if_needed(); value.value_string = space.value.value_string; @@ -2339,6 +2509,17 @@ void Space::initialize_value_double_if_needed() } +void Space::initialize_value_long_double_if_needed() +{ + if( type != type_long_double ) + { + remove_value(); + new (&value) long double; + type = type_long_double; + } +} + + void Space::initialize_value_string_if_needed() { if( type != type_string ) @@ -2471,6 +2652,7 @@ void Space::remove_value() case type_long: case type_float: case type_double: + case type_long_double: type = type_null; break; diff --git a/src/space/space.h b/src/space/space.h index b6db19b..41fd446 100644 --- a/src/space/space.h +++ b/src/space/space.h @@ -153,6 +153,7 @@ public: type_long, type_float, type_double, + type_long_double, type_string, type_wstring, type_object, @@ -165,6 +166,7 @@ public: long long value_long; float value_float; double value_double; + long double value_long_double; std::string value_string; std::wstring value_wstring; ObjectType value_object; @@ -202,6 +204,7 @@ public: Space(unsigned long long val); Space(float val); Space(double val); + Space(long double val); Space(const char * str); Space(const wchar_t * str); Space(const std::string & str); @@ -235,6 +238,7 @@ public: void set(unsigned long long val); void set(float val); void set(double val); + void set(long double val); void set(const char * str); void set(const wchar_t * str); void set(const std::string & str); @@ -256,6 +260,7 @@ public: Space & add(unsigned long long val); Space & add(float val); Space & add(double val); + Space & add(long double val); Space & add(const char * val); Space & add(const wchar_t * val); Space & add(const std::string & val); @@ -279,6 +284,7 @@ public: Space & add(const wchar_t * field, unsigned long long val); Space & add(const wchar_t * field, float val); Space & add(const wchar_t * field, double val); + Space & add(const wchar_t * field, long double val); Space & add(const wchar_t * field, const char * val); Space & add(const wchar_t * field, const wchar_t * val); Space & add(const wchar_t * field, const std::string & val); @@ -299,6 +305,7 @@ public: Space & add(const std::wstring & field, unsigned long long val); Space & add(const std::wstring & field, float val); Space & add(const std::wstring & field, double val); + Space & add(const std::wstring & field, long double val); Space & add(const std::wstring & field, const char * val); Space & add(const std::wstring & field, const wchar_t * val); Space & add(const std::wstring & field, const std::string & val); @@ -336,6 +343,7 @@ public: bool is_long_long() const; bool is_float() const; bool is_double() const; + bool is_long_double() const; bool is_numeric() const; bool is_str() const; bool is_wstr() const; @@ -356,6 +364,9 @@ public: unsigned long to_ulong() const; unsigned long long to_ullong() const; unsigned long long to_ulong_long() const; + float to_float() const; + double to_double() const; + long double to_long_double() const; std::string to_str() const; std::wstring to_wstr() const; @@ -419,6 +430,7 @@ public: long long * get_long_long(); float * get_float(); double * get_double(); + long double * get_long_double(); std::string * get_str(); std::wstring * get_wstr(); ObjectType * get_object(); @@ -455,6 +467,7 @@ public: long long * get_long_long(const wchar_t * field); float * get_float(const wchar_t * field); double * get_double(const wchar_t * field); + long double * get_long_double(const wchar_t * field); std::string * get_str(const wchar_t * field); std::wstring * get_wstr(const wchar_t * field); ObjectType * get_object(const wchar_t * field); @@ -467,6 +480,7 @@ public: const long long * get_long_long() const; const float * get_float() const; const double * get_double() const; + const long double * get_long_double() const; const std::string * get_str() const; const std::wstring * get_wstr() const; const ObjectType * get_object() const; @@ -481,6 +495,7 @@ public: const long long * get_long_long(const wchar_t * field) const; const float * get_float(const wchar_t * field) const; const double * get_double(const wchar_t * field) const; + const long double * get_long_double(const wchar_t * field) const; const std::string * get_str(const wchar_t * field) const; const std::wstring * get_wstr(const wchar_t * field) const; const ObjectType * get_object(const wchar_t * field) const; @@ -569,6 +584,10 @@ public: serialize_json_double(str); break; + case type_long_double: + serialize_json_long_double(str); + break; + case type_string: serialize_json_string(str); break; @@ -970,7 +989,7 @@ protected: wchar_t buffer[100]; size_t buffer_len = sizeof(buffer) / sizeof(wchar_t); - int chars_written = std::swprintf(buffer, buffer_len, L"%e", static_cast(value.value_float)); + int chars_written = std::swprintf(buffer, buffer_len, L"%g", static_cast(value.value_float)); if( errno == EOVERFLOW || chars_written < 0 ) buffer[0] = 0; @@ -984,7 +1003,21 @@ protected: wchar_t buffer[100]; size_t buffer_len = sizeof(buffer) / sizeof(wchar_t); - int chars_written = std::swprintf(buffer, buffer_len, L"%e", value.value_double); + int chars_written = std::swprintf(buffer, buffer_len, L"%g", value.value_double); + + if( errno == EOVERFLOW || chars_written < 0 ) + buffer[0] = 0; + + serialize_string_buffer(buffer, str, Escape::escape_space); + } + + template + void serialize_space_long_double(StreamType & str) const + { + wchar_t buffer[100]; + size_t buffer_len = sizeof(buffer) / sizeof(wchar_t); + + int chars_written = std::swprintf(buffer, buffer_len, L"%Lg", value.value_long_double); if( errno == EOVERFLOW || chars_written < 0 ) buffer[0] = 0; @@ -1154,7 +1187,7 @@ protected: wchar_t buffer[100]; size_t buffer_len = sizeof(buffer) / sizeof(wchar_t); - int chars_written = std::swprintf(buffer, buffer_len, L"%e", static_cast(value.value_float)); + int chars_written = std::swprintf(buffer, buffer_len, L"%g", static_cast(value.value_float)); if( errno == EOVERFLOW || chars_written < 0 ) buffer[0] = 0; @@ -1168,7 +1201,21 @@ protected: wchar_t buffer[100]; size_t buffer_len = sizeof(buffer) / sizeof(wchar_t); - int chars_written = std::swprintf(buffer, buffer_len, L"%e", value.value_double); + int chars_written = std::swprintf(buffer, buffer_len, L"%g", value.value_double); + + if( errno == EOVERFLOW || chars_written < 0 ) + buffer[0] = 0; + + serialize_string_buffer(buffer, str, Escape::escape_json); + } + + template + void serialize_json_long_double(StreamType & str) const + { + wchar_t buffer[100]; + size_t buffer_len = sizeof(buffer) / sizeof(wchar_t); + + int chars_written = std::swprintf(buffer, buffer_len, L"%Lg", value.value_long_double); if( errno == EOVERFLOW || chars_written < 0 ) buffer[0] = 0; @@ -1266,6 +1313,10 @@ protected: serialize_space_double(str); break; + case type_long_double: + serialize_space_long_double(str); + break; + case type_string: serialize_space_string(str); break; @@ -1350,6 +1401,7 @@ protected: void initialize_value_long_if_needed(); void initialize_value_float_if_needed(); void initialize_value_double_if_needed(); + void initialize_value_long_double_if_needed(); void initialize_value_string_if_needed(); void initialize_value_string_if_needed(std::string && str); void initialize_value_wstring_if_needed(); diff --git a/src/textstream/stream.h b/src/textstream/stream.h index d541f47..e0fe797 100644 --- a/src/textstream/stream.h +++ b/src/textstream/stream.h @@ -92,6 +92,9 @@ public: virtual Stream & operator<<(const Space & space) = 0; virtual Stream & operator<<(const Date & date) = 0; + virtual char get_char(size_t index) const = 0; + virtual wchar_t get_wchar(size_t index) const = 0; + // min width for integer output // if the output value has less digits then first zeroes are added // (0 turn off) diff --git a/src/textstream/textstream.h b/src/textstream/textstream.h index d7ec22e..bb1fb90 100644 --- a/src/textstream/textstream.h +++ b/src/textstream/textstream.h @@ -124,6 +124,10 @@ public: TextStreamBase & operator<<(const Space & space); TextStreamBase & operator<<(const Date & date); + char get_char(size_t index) const; + wchar_t get_wchar(size_t index) const; + + // min width for integer output // if the output value has less digits then first zeroes are added // (0 turn off) @@ -518,7 +522,7 @@ TextStreamBase::operator<<(double v) { char buf[100]; - snprintf(buf, sizeof(buf)/sizeof(char), "%f", v); + snprintf(buf, sizeof(buf)/sizeof(char), "%g", v); return operator<<(buf); } @@ -529,7 +533,7 @@ TextStreamBase::operator<<(long double v { char buf[100]; - snprintf(buf, sizeof(buf)/sizeof(char), "%Lf", v); + snprintf(buf, sizeof(buf)/sizeof(char), "%Lg", v); return operator<<(buf); } @@ -635,6 +639,21 @@ return *this; } +template +char TextStreamBase::get_char(size_t index) const +{ + return static_cast(buffer[index]); +} + + +template +wchar_t TextStreamBase::get_wchar(size_t index) const +{ + return static_cast(buffer[index]); +} + + + template template diff --git a/tests/Makefile.dep b/tests/Makefile.dep index 5a563bb..998b6e9 100644 --- a/tests/Makefile.dep +++ b/tests/Makefile.dep @@ -2,13 +2,14 @@ ./convert.o: convert.h test.h ../src/convert/convert.h ./convert.o: ../src/convert/inttostr.h ../src/convert/patternreplacer.h -./convert.o: ../src/textstream/textstream.h ../src/space/space.h -./convert.o: ../src/textstream/types.h ../src/convert/inttostr.h -./convert.o: ../src/utf8/utf8.h ../src/utf8/utf8_templates.h -./convert.o: ../src/utf8/utf8_private.h ../src/date/date.h -./convert.o: ../src/membuffer/membuffer.h ../src/textstream/types.h -./convert.o: ../src/convert/strtoint.h ../src/convert/text.h -./convert.o: ../src/convert/misc.h +./convert.o: ../src/textstream/textstream.h ../src/textstream/stream.h +./convert.o: ../src/space/space.h ../src/textstream/types.h +./convert.o: ../src/convert/inttostr.h ../src/utf8/utf8.h +./convert.o: ../src/utf8/utf8_templates.h ../src/utf8/utf8_private.h +./convert.o: ../src/date/date.h ../src/membuffer/membuffer.h +./convert.o: ../src/textstream/types.h ../src/convert/strtoint.h +./convert.o: ../src/convert/text.h ../src/convert/misc.h +./convert.o: ../src/convert/double.h ./csvparser.o: csvparser.h ../src/csv/csvparser.h ../src/space/space.h ./csvparser.o: ../src/textstream/types.h ../src/convert/inttostr.h ./csvparser.o: ../src/utf8/utf8.h ../src/utf8/utf8_templates.h @@ -22,8 +23,9 @@ ./mainoptionsparser.o: ../src/utf8/utf8_private.h ../src/convert/convert.h ./mainoptionsparser.o: ../src/convert/inttostr.h ./mainoptionsparser.o: ../src/convert/patternreplacer.h -./mainoptionsparser.o: ../src/textstream/textstream.h ../src/date/date.h +./mainoptionsparser.o: ../src/textstream/textstream.h +./mainoptionsparser.o: ../src/textstream/stream.h ../src/date/date.h ./mainoptionsparser.o: ../src/membuffer/membuffer.h ../src/textstream/types.h ./mainoptionsparser.o: ../src/convert/strtoint.h ../src/convert/text.h -./mainoptionsparser.o: ../src/convert/misc.h +./mainoptionsparser.o: ../src/convert/misc.h ../src/convert/double.h ./test.o: test.h