00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <cstddef>
00023 #include <drizzled/util/data_ref.h>
00024
00025 namespace drizzled {
00026
00027
00028
00029
00030
00031
00032 struct lex_string_t
00033 {
00034 const char* begin() const
00035 {
00036 return data();
00037 }
00038
00039 const char* end() const
00040 {
00041 return data() + size();
00042 }
00043
00044 const char* data() const
00045 {
00046 return str_;
00047 }
00048
00049 size_t size() const
00050 {
00051 return length_;
00052 }
00053
00054 void assign(const char* d, size_t s)
00055 {
00056 str_= const_cast<char*>(d);
00057 length_ = s;
00058 }
00059
00060 void operator=(str_ref v)
00061 {
00062 assign(v.data(), v.size());
00063 }
00064
00065 char* str_;
00066 size_t length_;
00067 };
00068
00069 inline const lex_string_t &null_lex_string()
00070 {
00071 static lex_string_t tmp= { NULL, 0 };
00072 return tmp;
00073 }
00074
00075 struct execute_string_t : public lex_string_t
00076 {
00077 private:
00078 bool is_variable;
00079 public:
00080
00081 bool isVariable() const
00082 {
00083 return is_variable;
00084 }
00085
00086 void set(const lex_string_t& s, bool is_variable_arg= false)
00087 {
00088 is_variable= is_variable_arg;
00089 static_cast<lex_string_t&>(*this) = s;
00090 }
00091
00092 };
00093
00094 #define STRING_WITH_LEN(X) (X), (sizeof(X) - 1)
00095 #define C_STRING_WITH_LEN(X) const_cast<char*>(X), (sizeof(X) - 1)
00096
00097 }
00098