10 Commits 83af2d8501 ... 910944d9e8

Author SHA1 Message Date
  __vic 910944d9e8 Merge branch 'generic' into posix 2 years ago
  __vic 9253629d38 Merge branch 'iso' into generic 2 years ago
  __vic e2929f662d fix: readonly_cstring: compare() 2 years ago
  __vic 68cdf170f8 It's enough to override only one throw_errno() function 2 years ago
  __vic 26e0fa59f7 Include <utility> for std::index_sequence 2 years ago
  __vic 40a204cb1b More compact logger 2 years ago
  __vic 9a3c1c4c25 operator<<(string_buffer &&, T) added 2 years ago
  __vic 27f18e4d08 Explicity use unsigned types 2 years ago
  __vic 7860fe31ca Minor doc fix 2 years ago
  __vic f48ecd7445 logger: minor doc fix 2 years ago

+ 12 - 0
ChangeLog

@@ -4,6 +4,18 @@ Legend:
     * Changes
     ! Important
 
+2022-03-02  __vic
+    - readonly_cstring: compare(const char *,readonly_cstring)
+
+2022-02-21  __vic
+    * throw_errno: it's enough to override only one function
+
+2022-02-11  __vic
+    * logger: fields layout reorganized to be more compact
+
+2022-02-09  __vic
+    + string_buffer: operator<<(string_buffer &&, T)
+
 2021-12-07  __vic
     + string_ref: conversion from/to std::string_view
     + string_buffer supports std::string_view (via string_ref)

+ 4 - 4
doc/en/logger.h.xml

@@ -48,7 +48,7 @@ public:
 
     void message(severity_t severity, const char *msg, size_t msg_len);
 #if __cpp_lib_string_view // C++17
-    void message(severity s, std::string_view msg);
+    void message(severity_t severity, std::string_view msg);
 
     void trace(std::string_view msg);
     void debug(std::string_view msg);
@@ -289,9 +289,9 @@ are formed.</p>
 
 <synopsis>
 <prototype>void message(severity_t severity, const char *msg, size_t msg_len)</prototype>
-<prototype>void message(severity sev, std::string_view msg) <sign>C++17</sign></prototype>
-<prototype>void message(severity sev, const char *msg) <sign>until C++17</sign></prototype>
-<prototype>void message(severity sev, const std::string &amp;msg) <sign>until C++17</sign></prototype>
+<prototype>void message(severity_t severity, std::string_view msg) <sign>C++17</sign></prototype>
+<prototype>void message(severity_t severity, const char *msg) <sign>until C++17</sign></prototype>
+<prototype>void message(severity_t severity, const std::string &amp;msg) <sign>until C++17</sign></prototype>
 <p>Writes the message with the specified severity.</p>
 </synopsis>
 

+ 1 - 1
doc/en/memory.h.xml

@@ -41,7 +41,7 @@ void store_unaligned(void *p, T v);
 <code-block lang="C++"><![CDATA[
 void *p = ...;
 // *static_cast<int *>(p) = 123; // potential bus error
-__vic::store_unaligned<int>(p, 123);
+__vic::store_unaligned(p, 123);
 ]]></code-block>
 </section>
 

+ 8 - 16
doc/en/readonly_cstring.h.xml

@@ -25,13 +25,11 @@ public:
     readonly_cstring &assign(const char *begin, const char *end);
     readonly_cstring &assign(const char *chars, size_t n);
 
-    char *reserve(size_t n);
-
-    int compare(const char *str) const;
     bool empty() const;
     const char *c_str() const;
     operator const char*() const;
 
+    char *reserve(size_t n);
     void swap(readonly_cstring &str) noexcept;
 };
 
@@ -129,19 +127,6 @@ for such purposes.</p>
 </synopsis>
 
 <synopsis>
-<prototype>char *reserve(size_t n)</prototype>
-<p>Allocates internal buffer for <tt>n</tt> chars and returns the pointer to
-it. Can be useful in conjunction with functions like <tt>std::sprintf()</tt>.</p>
-<note>Try to avoid this unsafe function!</note>
-</synopsis>
-
-<synopsis>
-<prototype>int compare(const char *str) const</prototype>
-<p>Compares the string with <tt>str</tt>. Return values are similar to
-<tt>std::strcmp</tt>.</p>
-</synopsis>
-
-<synopsis>
 <prototype>bool empty() const</prototype>
 <p>Returns <tt>true</tt> if string is empty.</p>
 </synopsis>
@@ -153,6 +138,13 @@ it. Can be useful in conjunction with functions like <tt>std::sprintf()</tt>.</p
 </synopsis>
 
 <synopsis>
+<prototype>char *reserve(size_t n)</prototype>
+<p>Allocates internal buffer for <tt>n</tt> chars and returns the pointer to
+it. Can be useful in conjunction with functions like <tt>std::sprintf()</tt>.</p>
+<note>Try to avoid this unsafe function!</note>
+</synopsis>
+
+<synopsis>
 <prototype>void swap(readonly_cstring &amp;str) noexcept</prototype>
 <p>Swaps the value with <tt>str</tt>.</p>
 </synopsis>

+ 9 - 0
doc/en/string_buffer.h.xml

@@ -79,6 +79,9 @@ string_buffer operator+(const char *s1, const string_buffer &s2);
 string_buffer operator+(const string_buffer &s, char ch);
 string_buffer operator+(char ch, const string_buffer &s);
 
+template<class T>
+string_buffer &operator<<(string_buffer &&s, const T &v); // C++11
+
 using msg = string_buffer;
 ]]></code-block>
 
@@ -280,6 +283,12 @@ C++98.</p>
 <p>Concatenation of strings and characters.</p>
 </synopsis>
 
+<synopsis>
+<prototype><![CDATA[template<class T>
+string_buffer &operator<<(string_buffer &&s, const T &v)]]> <sign>C++11</sign></prototype>
+<p>Calls <tt>operator&lt;&lt;(string_buffer &amp;s, const T &amp;v)</tt>.</p>
+</synopsis>
+
 </section>
 
 </chapter>

+ 4 - 11
doc/en/throw_errno.h.xml

@@ -18,27 +18,20 @@ used. Just create cpp-file with the following content in your project:</p>
 <code-block lang="C++"><![CDATA[
 #include<__vic/throw_errno.h>
 #include<system_error>
-#include<cerrno>
-
-namespace __vic {
 
 //----------------------------------------------------------------------------
 // Override library functions to throw std::system_error
 //----------------------------------------------------------------------------
-void throw_errno(const char *prompt, int err_no)
+void __vic::throw_errno(const char *prompt, int err_no)
 {
     throw std::system_error(err_no, std::system_category(), prompt);
 }
 //----------------------------------------------------------------------------
-void throw_errno(const char *prompt)
-{
-    throw_errno(prompt, errno);
-}
-//----------------------------------------------------------------------------
-
-} // namespace
 ]]></code-block>
 
+<p>It's enough to override only one functions because the second one just calls
+<tt>throw_errno(prompt, errno)</tt>.</p>
+
 <section><title>Example</title>
 <code-block lang="C++"><![CDATA[
 ssize_t written = ::write(fd, buf, buf_size);

+ 1 - 1
doc/en/to_text.h.xml

@@ -14,7 +14,7 @@ void to_text_append(int n, std::string &str);
 void to_text_append(short n, std::string &str);
 void to_text_append(signed char n, std::string &str);
 
-void to_text_append(unsigned long long , std::string &str);
+void to_text_append(unsigned long long n, std::string &str);
 void to_text_append(unsigned long n, std::string &str);
 void to_text_append(unsigned n, std::string &str);
 void to_text_append(unsigned short n, std::string &str);

+ 4 - 4
doc/ru/logger.h.xml

@@ -48,7 +48,7 @@ public:
 
     void message(severity_t severity, const char *msg, size_t msg_len);
 #if __cpp_lib_string_view // C++17
-    void message(severity s, std::string_view msg);
+    void message(severity_t severity, std::string_view msg);
 
     void trace(std::string_view msg);
     void debug(std::string_view msg);
@@ -291,9 +291,9 @@ C++98. Начиная с C++11 это просто синоним <tt>severity</
 
 <synopsis>
 <prototype>void message(severity_t severity, const char *msg, size_t msg_len)</prototype>
-<prototype>void message(severity sev, std::string_view msg) <sign>C++17</sign></prototype>
-<prototype>void message(severity sev, const char *msg) <sign>until C++17</sign></prototype>
-<prototype>void message(severity sev, const std::string &amp;msg) <sign>until C++17</sign></prototype>
+<prototype>void message(severity_t severity, std::string_view msg) <sign>C++17</sign></prototype>
+<prototype>void message(severity_t severity, const char *msg) <sign>until C++17</sign></prototype>
+<prototype>void message(severity_t severity, const std::string &amp;msg) <sign>until C++17</sign></prototype>
 <p>Выводит сообщение с заданным приоритетом.</p>
 </synopsis>
 

+ 1 - 1
doc/ru/memory.h.xml

@@ -41,7 +41,7 @@ void store_unaligned(void *p, T v);
 <code-block lang="C++"><![CDATA[
 void *p = ...;
 // *static_cast<int *>(p) = 123; // потенциальная ошибка шины
-__vic::store_unaligned<int>(p, 123);
+__vic::store_unaligned(p, 123);
 ]]></code-block>
 </section>
 

+ 0 - 0
doc/ru/readonly_cstring.h.xml


Some files were not shown because too many files changed in this diff