commit 43e225b6f2efb308562f515a14969df931638316 Author: Daniel Swanson Date: Mon Jun 7 18:39:14 2021 -0500 more helper stuff diff --git a/lttoolbox/input_file.cc b/lttoolbox/input_file.cc index 51c9b11..d0a150b 100644 --- a/lttoolbox/input_file.cc +++ b/lttoolbox/input_file.cc @@ -133,3 +133,14 @@ InputFile::eof() { return (infile == nullptr) || feof(infile); } + +void +InputFile::rewind() +{ + if (infile != nullptr) { + if (std::fseek(infile, 0, SEEK_SET) != 0) { + std::cerr << "Error: Unable to rewind file" << std::endl; + exit(EXIT_FAILURE); + } + } +} diff --git a/lttoolbox/input_file.h b/lttoolbox/input_file.h index 7a8aad7..9cabc64 100644 --- a/lttoolbox/input_file.h +++ b/lttoolbox/input_file.h @@ -39,6 +39,7 @@ public: UChar32 peek(); void unget(UChar32 c); bool eof(); + void rewind(); }; #endif diff --git a/lttoolbox/ustring.cc b/lttoolbox/ustring.cc index 9bdfd24..b537a78 100644 --- a/lttoolbox/ustring.cc +++ b/lttoolbox/ustring.cc @@ -63,16 +63,6 @@ to_ustring(const char* s) return ret; } -UString -to_ustring(char* s) -{ - auto sz = strlen(s); - UString ret; - ret.reserve(sz); - utf8::utf8to16(s, s+sz, std::back_inserter(ret)); - return ret; -} - void ustring_to_vec32(const UString& str, std::vector& vec) { diff --git a/lttoolbox/ustring.h b/lttoolbox/ustring.h index c181e98..459fcfa 100644 --- a/lttoolbox/ustring.h +++ b/lttoolbox/ustring.h @@ -37,13 +37,11 @@ double stod(const UString& str); // for command-line arguments UString to_ustring(const char* str); -// for XML -UString to_ustring(char* str); - // append UTF-16 string to UTF-32 vector of symbols void ustring_to_vec32(const UString& str, std::vector& vec); -inline std::ostream& operator<<(std::ostream& ostr, const UString& str) +inline std::basic_ostream& +operator<<(std::basic_ostream& ostr, const UString& str) { std::string res; utf8::utf16to8(str.begin(), str.end(), std::back_inserter(res));