diff --git a/src/helpers.h b/src/helpers.h index 935cbd9a..86a39235 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -328,9 +328,10 @@ template <> struct StringConverter { std::basic_string operator()(const char *s) { return TO_WSTRING(s); } }; -template void String2Buffer(const std::basic_string &s, NC::basic_buffer &buf) +template +void String2Buffer(const std::basic_string &s, NC::basic_buffer &buf) { - StringConverter< NC::basic_buffer > cnv; + StringConverter< NC::basic_buffer > cnv; for (auto it = s.begin(); it != s.end(); ++it) { if (*it == '$') diff --git a/src/strbuffer.h b/src/strbuffer.h index be32b31c..dd7ab648 100644 --- a/src/strbuffer.h +++ b/src/strbuffer.h @@ -30,7 +30,7 @@ namespace NC {// /// Buffer template class that can store text along with its /// format attributes. The content can be easily printed to /// window or taken as raw string at any time. -template class basic_buffer +template class basic_buffer { friend struct Scrollpad; @@ -53,7 +53,7 @@ template class basic_buffer }; /// Internal buffer for storing raw text - std::basic_string m_string; + std::basic_string m_string; /// List used for storing formatting informations std::list m_format; @@ -67,7 +67,7 @@ public: basic_buffer(const basic_buffer &b); /// @return raw content of the buffer without formatting informations - const std::basic_string &str() const; + const std::basic_string &str() const; /// Searches for given string in buffer and sets format/color at the /// beginning and end of it using val_b and val_e flags accordingly @@ -78,7 +78,7 @@ public: /// @param for_each indicates whether function searches through whole buffer and sets /// the format for all occurences of given string or stops after the first one /// @return true if at least one occurence of the string was found, false otherwise - bool setFormatting(short val_b, std::basic_string s, short val_e, + bool setFormatting(short val_b, std::basic_string s, short val_e, bool case_sensitive, bool for_each = 1); /// Searches for given string in buffer and removes given @@ -89,7 +89,7 @@ public: /// @param case_sensitive indicates whether algorithm should care about case sensitivity /// @param for_each indicates whether function searches through whole buffer and removes /// given format from all occurences of given string or stops after the first one - void removeFormatting(short val_b, std::basic_string pattern, short val_e, + void removeFormatting(short val_b, std::basic_string pattern, short val_e, bool case_sensitive, bool for_each = 1); /// Removes all formating applied to string in buffer. @@ -105,54 +105,54 @@ public: /// @param separator additional text to be placed between the end and the beginning of /// the string void write(Window &w, size_t &start_pos, size_t width, - const std::basic_string &separator) const; + const std::basic_string &separator) const; /// Clears the content of the buffer and its formatting informations void clear(); - basic_buffer &operator<<(int n) + basic_buffer &operator<<(int n) { - m_string += intTo< std::basic_string >::apply(n); + m_string += intTo< std::basic_string >::apply(n); return *this; } - basic_buffer &operator<<(long int n) + basic_buffer &operator<<(long int n) { - m_string += longIntTo< std::basic_string >::apply(n); + m_string += longIntTo< std::basic_string >::apply(n); return *this; } - basic_buffer &operator<<(unsigned int n) + basic_buffer &operator<<(unsigned int n) { - m_string += unsignedIntTo< std::basic_string >::apply(n); + m_string += unsignedIntTo< std::basic_string >::apply(n); return *this; } - basic_buffer &operator<<(unsigned long int n) + basic_buffer &operator<<(unsigned long int n) { - m_string += unsignedLongIntTo< std::basic_string >::apply(n); + m_string += unsignedLongIntTo< std::basic_string >::apply(n); return *this; } - basic_buffer &operator<<(char c) + basic_buffer &operator<<(char c) { m_string += c; return *this; } - basic_buffer &operator<<(wchar_t wc) + basic_buffer &operator<<(wchar_t wc) { m_string += wc; return *this; } - basic_buffer &operator<<(const C *s) + basic_buffer &operator<<(const CharT *s) { m_string += s; return *this; } - basic_buffer &operator<<(const std::basic_string &s) + basic_buffer &operator<<(const std::basic_string &s) { m_string += s; return *this; @@ -160,27 +160,27 @@ public: /// Handles colors /// @return reference to itself - basic_buffer &operator<<(Color color); + basic_buffer &operator<<(Color color); /// Handles format flags /// @return reference to itself - basic_buffer &operator<<(Format f); + basic_buffer &operator<<(Format f); /// Handles copying one buffer to another using operator<<() /// @param buf buffer to be copied /// @return reference to itself - basic_buffer &operator<<(const basic_buffer &buf); + basic_buffer &operator<<(const basic_buffer &buf); /// Friend operator that handles printing /// the content of buffer to window object - friend Window &operator<<(Window &w, const basic_buffer &buf) + friend Window &operator<<(Window &w, const basic_buffer &buf) { - const std::basic_string &s = buf.m_string; + const std::basic_string &s = buf.m_string; if (buf.m_format.empty()) w << s; else { - std::basic_string tmp; + std::basic_string tmp; auto b = buf.m_format.begin(), e = buf.m_format.end(); for (size_t i = 0; i < s.length() || b != e; ++i) { @@ -215,17 +215,17 @@ typedef basic_buffer Buffer; /// Standard buffer that uses wide characters typedef basic_buffer WBuffer; -template basic_buffer::basic_buffer(const basic_buffer &b) +template basic_buffer::basic_buffer(const basic_buffer &b) : m_string(b.m_string), m_format(b.m_format) { } -template const std::basic_string &basic_buffer::str() const +template const std::basic_string &basic_buffer::str() const { return m_string; } -template bool basic_buffer::setFormatting( +template bool basic_buffer::setFormatting( short val_b, - std::basic_string s, + std::basic_string s, short val_e, bool case_sensitive, bool for_each @@ -234,7 +234,7 @@ template bool basic_buffer::setFormatting( if (s.empty()) return false; bool result = false; - std::basic_string base; + std::basic_string base; if (case_sensitive) base = m_string; else @@ -243,7 +243,7 @@ template bool basic_buffer::setFormatting( s = lowercase(s); } FormatPos fp; - for (size_t i = base.find(s); i != std::basic_string::npos; i = base.find(s, i)) + for (size_t i = base.find(s); i != std::basic_string::npos; i = base.find(s, i)) { result = true; fp.Value = val_b; @@ -260,9 +260,9 @@ template bool basic_buffer::setFormatting( return result; } -template void basic_buffer::removeFormatting( +template void basic_buffer::removeFormatting( short val_b, - std::basic_string pattern, + std::basic_string pattern, short val_e, bool case_sensitive, bool for_each @@ -270,7 +270,7 @@ template void basic_buffer::removeFormatting( { if (pattern.empty()) return; - std::basic_string base; + std::basic_string base; if (case_sensitive) base = m_string; else @@ -279,7 +279,7 @@ template void basic_buffer::removeFormatting( pattern = lowercase(pattern); } FormatPos fp; - for (size_t i = base.find(pattern); i != std::basic_string::npos; i = base.find(pattern, i)) + for (size_t i = base.find(pattern); i != std::basic_string::npos; i = base.find(pattern, i)) { fp.Value = val_b; fp.Position = i; @@ -293,19 +293,19 @@ template void basic_buffer::removeFormatting( } } -template void basic_buffer::removeFormatting() +template void basic_buffer::removeFormatting() { m_format.clear(); } -template void basic_buffer::write( +template void basic_buffer::write( Window &w, size_t &start_pos, size_t width, - const std::basic_string &separator + const std::basic_string &separator ) const { - std::basic_string s = m_string; + std::basic_string s = m_string; size_t len = Window::length(s); if (len > width) @@ -356,13 +356,13 @@ template void basic_buffer::write( w << *this; } -template void basic_buffer::clear() +template void basic_buffer::clear() { m_string.clear(); m_format.clear(); } -template void basic_buffer::loadAttribute(Window &w, short value) const +template void basic_buffer::loadAttribute(Window &w, short value) const { if (value < fmtNone) w << Color(value); @@ -370,7 +370,7 @@ template void basic_buffer::loadAttribute(Window &w, short value w << Format(value); } -template basic_buffer &basic_buffer::operator<<(Color color) +template basic_buffer &basic_buffer::operator<<(Color color) { FormatPos f; f.Position = m_string.length(); @@ -379,12 +379,12 @@ template basic_buffer &basic_buffer::operator<<(Color color) return *this; } -template basic_buffer &basic_buffer::operator<<(Format f) +template basic_buffer &basic_buffer::operator<<(Format f) { return operator<<(Color(f)); } -template basic_buffer &basic_buffer::operator<<(const basic_buffer &buf) +template basic_buffer &basic_buffer::operator<<(const basic_buffer &buf) { size_t length = m_string.length(); m_string += buf.m_string;