diff --git a/include/sexpp/sexp.h b/include/sexpp/sexp.h index 2a69083..d50d046 100644 --- a/include/sexpp/sexp.h +++ b/include/sexpp/sexp.h @@ -99,24 +99,28 @@ class sexp_input_stream_t; * SEXP simple string */ -//typedef uint8_t octet_t; using octet_t = uint8_t; -struct octet_traits : std::char_traits { - static void assign(char_type& r, const char_type& a) { +struct octet_traits : std::char_traits +{ + static void assign(char_type& r, const char_type& a) + { r = a; } - static bool eq(const char_type& c1, const char_type& c2) { + static bool eq(const char_type& c1, const char_type& c2) + { return c1 == c2; } - static bool lt(const char_type& c1, const char_type& c2) { + static bool lt(const char_type& c1, const char_type& c2) + { return c1 < c2; } - static int compare(const char_type* s1, const char_type* s2, std::size_t n) { + static int compare(const char_type* s1, const char_type* s2, std::size_t n) + { while ( n-- != 0 ) { if ( *s1 < *s2 ) return -1; if ( *s2++ < *s1++ ) return 1; @@ -124,43 +128,53 @@ struct octet_traits : std::char_traits { return 0; } - static const char_type* find(const char_type* s, std::size_t n, const char_type& a) { - while ( n-- != 0 ) { + static const char_type* find(const char_type* s, std::size_t n, const char_type& a) + { + while ( n-- != 0 ) + { if ( *s == a ) return s; s++; } return nullptr; } - static char_type* move(char_type* s1, const char_type* s2, std::size_t n) { + static char_type* move(char_type* s1, const char_type* s2, std::size_t n) + { return (char_type*)std::memmove(s1, s2, n); } - static char_type* copy(char_type* s1, const char_type* s2, std::size_t n) { + static char_type* copy(char_type* s1, const char_type* s2, std::size_t n) + { return (char_type*)std::memcpy(s1, s2, n); } - static char_type* assign(char_type* s, std::size_t n, char_type a) { + static char_type* assign(char_type* s, std::size_t n, char_type a) + { return (char_type*)std::memset(s, a, n); } - static char_type to_char_type(const int_type& c) { + static char_type to_char_type(const int_type& c) + { return char_type(c); } - static int_type to_int_type(const char_type& c) { + static int_type to_int_type(const char_type& c) + { return int_type(c); } - static bool eq_int_type(const int_type& c1, const int_type& c2) { + static bool eq_int_type(const int_type& c1, const int_type& c2) + { return c1 == c2; } - static int_type eof() { + static int_type eof() + { return static_cast(EOF); } - static int_type not_eof(const int_type& c) { + static int_type not_eof(const int_type& c) + { return eq_int_type(c, eof()) ? 0 : c; } };