diff --git a/src/Makefile.dep b/src/Makefile.dep index a2410fd..ba664bc 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -5,39 +5,30 @@ ./convert/text.o: ./convert/text.h ./convert/text_private.h ./date/date.o: ./date/date.h convert/inttostr.h ./log/filelog.o: ./log/filelog.h textstream/textstream.h space/space.h -./log/filelog.o: textstream/types.h convert/inttostr.h date/date.h -./log/filelog.o: membuffer/membuffer.h textstream/types.h utf8/utf8.h -./log/filelog.o: utf8/utf8_templates.h utf8/utf8_private.h +./log/filelog.o: textstream/types.h convert/inttostr.h utf8/utf8.h +./log/filelog.o: utf8/utf8_templates.h utf8/utf8_private.h date/date.h +./log/filelog.o: membuffer/membuffer.h textstream/types.h ./log/log.o: ./log/log.h textstream/textstream.h space/space.h -./log/log.o: textstream/types.h convert/inttostr.h date/date.h +./log/log.o: textstream/types.h convert/inttostr.h utf8/utf8.h +./log/log.o: utf8/utf8_templates.h utf8/utf8_private.h date/date.h ./log/log.o: membuffer/membuffer.h textstream/types.h ./log/filelog.h -./log/log.o: utf8/utf8.h utf8/utf8_templates.h utf8/utf8_private.h ./space/space.o: ./space/space.h textstream/types.h convert/inttostr.h -./space/space.o: utf8/utf8.h textstream/textstream.h space/space.h -./space/space.o: date/date.h membuffer/membuffer.h textstream/types.h -./space/space.o: utf8/utf8_templates.h utf8/utf8_private.h convert/convert.h -./space/space.o: ./convert/inttostr.h convert/patternreplacer.h -./space/space.o: convert/strtoint.h ./convert/text.h ./convert/misc.h +./space/space.o: utf8/utf8.h utf8/utf8_templates.h utf8/utf8_private.h +./space/space.o: convert/convert.h ./convert/inttostr.h +./space/space.o: convert/patternreplacer.h textstream/textstream.h +./space/space.o: space/space.h date/date.h membuffer/membuffer.h +./space/space.o: textstream/types.h convert/strtoint.h ./convert/text.h +./space/space.o: ./convert/misc.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: textstream/textstream.h space/space.h date/date.h -./space/spaceparser.o: membuffer/membuffer.h textstream/types.h ./space/spaceparser.o: utf8/utf8_templates.h utf8/utf8_private.h ./space/spaceparser.o: convert/strtoint.h ./convert/text.h ./convert/misc.h -./utf8/utf8.o: ./utf8/utf8.h textstream/textstream.h space/space.h -./utf8/utf8.o: textstream/types.h convert/inttostr.h date/date.h -./utf8/utf8.o: membuffer/membuffer.h textstream/types.h utf8/utf8_templates.h -./utf8/utf8.o: utf8/utf8_private.h -./utf8/utf8_private.o: utf8/utf8_private.h textstream/textstream.h -./utf8/utf8_private.o: space/space.h textstream/types.h convert/inttostr.h -./utf8/utf8_private.o: date/date.h membuffer/membuffer.h textstream/types.h +./utf8/utf8.o: ./utf8/utf8.h utf8/utf8_templates.h utf8/utf8_private.h +./utf8/utf8_private.o: utf8/utf8_private.h ./csv/csvparser.o: ./csv/csvparser.h space/space.h textstream/types.h -./csv/csvparser.o: convert/inttostr.h utf8/utf8.h textstream/textstream.h -./csv/csvparser.o: date/date.h membuffer/membuffer.h textstream/types.h -./csv/csvparser.o: utf8/utf8_templates.h utf8/utf8_private.h +./csv/csvparser.o: convert/inttostr.h utf8/utf8.h utf8/utf8_templates.h +./csv/csvparser.o: utf8/utf8_private.h ./mainoptions/mainoptionsparser.o: ./mainoptions/mainoptionsparser.h ./mainoptions/mainoptionsparser.o: space/space.h textstream/types.h ./mainoptions/mainoptionsparser.o: convert/inttostr.h utf8/utf8.h -./mainoptions/mainoptionsparser.o: textstream/textstream.h date/date.h -./mainoptions/mainoptionsparser.o: membuffer/membuffer.h textstream/types.h ./mainoptions/mainoptionsparser.o: utf8/utf8_templates.h utf8/utf8_private.h diff --git a/src/space/space.h b/src/space/space.h index 1a79748..227dffd 100644 --- a/src/space/space.h +++ b/src/space/space.h @@ -44,9 +44,10 @@ #include #include #include +#include #include "textstream/types.h" #include "convert/inttostr.h" -#include +#include "utf8/utf8.h" diff --git a/src/textstream/textstream.h b/src/textstream/textstream.h index 1ad96cc..1970d1a 100644 --- a/src/textstream/textstream.h +++ b/src/textstream/textstream.h @@ -45,10 +45,10 @@ #include "membuffer/membuffer.h" #include "types.h" - // for snprintf #include + namespace pt { @@ -96,18 +96,23 @@ public: TextStreamBase & operator<<(const std::string & str); TextStreamBase & operator<<(const wchar_t * str); - TextStreamBase & operator<<(const std::wstring * str); TextStreamBase & operator<<(const std::wstring & str); TextStreamBase & operator<<(char); + TextStreamBase & operator<<(unsigned char); TextStreamBase & operator<<(wchar_t); + TextStreamBase & operator<<(bool); + TextStreamBase & operator<<(short); TextStreamBase & operator<<(int); TextStreamBase & operator<<(long); TextStreamBase & operator<<(long long); + TextStreamBase & operator<<(unsigned short); TextStreamBase & operator<<(unsigned int); TextStreamBase & operator<<(unsigned long); TextStreamBase & operator<<(unsigned long long); + TextStreamBase & operator<<(float); TextStreamBase & operator<<(double); + TextStreamBase & operator<<(long double); TextStreamBase & operator<<(const void *); // printing a pointer TextStreamBase & operator<<(const Space & space); TextStreamBase & operator<<(const Date & date); @@ -324,6 +329,16 @@ return *this; } +template +TextStreamBase & +TextStreamBase::operator<<(unsigned char v) +{ + buffer.append(static_cast(v)); + +return *this; +} + + template TextStreamBase & TextStreamBase::operator<<(wchar_t v) @@ -334,6 +349,25 @@ return *this; } +template +TextStreamBase & +TextStreamBase::operator<<(bool v) +{ + char c = v ? '1' : '0'; + buffer.append(static_cast(c)); + +return *this; +} + + +template +TextStreamBase & +TextStreamBase::operator<<(short v) +{ + return operator<<(static_cast(v)); +} + + template TextStreamBase & TextStreamBase::operator<<(int v) @@ -368,6 +402,14 @@ return *this; } +template +TextStreamBase & +TextStreamBase::operator<<(unsigned short v) +{ + return operator<<(static_cast(v)); +} + + template TextStreamBase & TextStreamBase::operator<<(unsigned int v) @@ -402,6 +444,13 @@ return *this; } +template +TextStreamBase & +TextStreamBase::operator<<(float v) +{ + return operator<<(static_cast(v)); +} + template TextStreamBase & TextStreamBase::operator<<(double v) @@ -413,6 +462,17 @@ char buf[100]; } +template +TextStreamBase & +TextStreamBase::operator<<(long double v) +{ +char buf[100]; + + snprintf(buf, sizeof(buf)/sizeof(char), "%Lf", v); + return operator<<(buf); +} + + template TextStreamBase & TextStreamBase::operator<<(const void * v) diff --git a/src/utf8/utf8.cpp b/src/utf8/utf8.cpp index d891dd6..4aaeb7d 100644 --- a/src/utf8/utf8.cpp +++ b/src/utf8/utf8.cpp @@ -35,6 +35,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include "utf8.h" #include "utf8_private.h" diff --git a/src/utf8/utf8.h b/src/utf8/utf8.h index 7edabda..633e992 100644 --- a/src/utf8/utf8.h +++ b/src/utf8/utf8.h @@ -39,7 +39,6 @@ #define headerfile_picotools_utf8_utf8 #include -#include "textstream/textstream.h" namespace pt diff --git a/src/utf8/utf8_private.h b/src/utf8/utf8_private.h index 1fb3726..42091a4 100644 --- a/src/utf8/utf8_private.h +++ b/src/utf8/utf8_private.h @@ -38,7 +38,7 @@ #ifndef headerfile_picotools_utf8_utf8_private #define headerfile_picotools_utf8_utf8_private -#include "textstream/textstream.h" +#include namespace pt @@ -186,15 +186,15 @@ void int_to_wide(int c, StreamType & res) // not tested // FIX ME it is not using surrogate pairs from input stream // and mode parameter -template -void wide_to_utf8_generic(TextStreamBase & buffer, int mode, function_type write_function) +template +void wide_to_utf8_generic(StreamType & buffer, int mode, function_type write_function) { char utf8_buffer[256]; std::size_t buffer_len = sizeof(utf8_buffer) / sizeof(char); std::size_t utf8_sequence_max_length = 10; std::size_t index = 0; - typename TextStreamBase::const_iterator i = buffer.begin(); + typename StreamType::const_iterator i = buffer.begin(); while( i != buffer.end() ) { diff --git a/tests/Makefile.dep b/tests/Makefile.dep index 7af1bb8..5a563bb 100644 --- a/tests/Makefile.dep +++ b/tests/Makefile.dep @@ -1,25 +1,29 @@ # DO NOT DELETE -./main.o: convert.h mainoptionsparser.h csvparser.h ./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/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 -./test.o: test.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 +./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 +./csvparser.o: ../src/utf8/utf8_private.h test.h +./main.o: convert.h mainoptionsparser.h csvparser.h ./mainoptionsparser.o: mainoptionsparser.h test.h ./mainoptionsparser.o: ../src/mainoptions/mainoptionsparser.h ./mainoptionsparser.o: ../src/space/space.h ../src/textstream/types.h ./mainoptionsparser.o: ../src/convert/inttostr.h ../src/utf8/utf8.h -./mainoptionsparser.o: ../src/textstream/textstream.h ../src/date/date.h -./mainoptionsparser.o: ../src/membuffer/membuffer.h ../src/textstream/types.h ./mainoptionsparser.o: ../src/utf8/utf8_templates.h ./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/membuffer/membuffer.h ../src/textstream/types.h ./mainoptionsparser.o: ../src/convert/strtoint.h ../src/convert/text.h ./mainoptionsparser.o: ../src/convert/misc.h -./csvparser.o: csvparser.h ../src/csv/csvparser.h ../src/space/space.h -./csvparser.o: ../src/textstream/types.h ../src/convert/inttostr.h test.h +./test.o: test.h