diff options
| author | Sergey Petrunya <psergey@askmonty.org> | 2013-10-16 13:38:42 +0400 |
|---|---|---|
| committer | Sergey Petrunya <psergey@askmonty.org> | 2013-10-16 13:38:42 +0400 |
| commit | e5d13c1567cd5600f163aedfc940b3ba6b7703af (patch) | |
| tree | e7ddb60207533508db6f4c509e8921e398769eed /sql/sql_string.h | |
| parent | ce069b1f6b3847309b06e548adf23fa0c7238336 (diff) | |
| parent | e62e1e8a3b82f037cb3c76986327b36647288a2d (diff) | |
| download | mariadb-git-e5d13c1567cd5600f163aedfc940b3ba6b7703af.tar.gz | |
Merge 10.0-base -> 10.0
Diffstat (limited to 'sql/sql_string.h')
| -rw-r--r-- | sql/sql_string.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sql/sql_string.h b/sql/sql_string.h index 14509218ab5..7687490c8aa 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -520,6 +520,38 @@ public: } }; + +// The following class is a backport from MySQL 5.6: +/** + String class wrapper with a preallocated buffer of size buff_sz + + This class allows to replace sequences of: + char buff[12345]; + String str(buff, sizeof(buff)); + str.length(0); + with a simple equivalent declaration: + StringBuffer<12345> str; +*/ + +template<size_t buff_sz> +class StringBuffer : public String +{ + char buff[buff_sz]; + +public: + StringBuffer() : String(buff, buff_sz, &my_charset_bin) { length(0); } + explicit StringBuffer(const CHARSET_INFO *cs) : String(buff, buff_sz, cs) + { + length(0); + } + StringBuffer(const char *str, size_t length, const CHARSET_INFO *cs) + : String(buff, buff_sz, cs) + { + set(str, length, cs); + } +}; + + static inline bool check_if_only_end_space(CHARSET_INFO *cs, const char *str, const char *end) |
