00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00031
00032 #ifndef _cl_header_string_reference_
00033 #define _cl_header_string_reference_
00034
00035 #if defined(_MSC_VER)
00036 #pragma once
00037 #endif
00038
00039 #include "../api_core.h"
00040 #include "string_data.h"
00041
00046 template<typename CharType, typename StdString>
00047 class CL_API_CORE CL_StringReference : public CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString>
00048 {
00049 public:
00050
00051 #ifndef WIN32
00052
00053
00054
00055
00056 typedef unsigned int size_type;
00057 typedef CharType char_type;
00058 typedef CharType *iterator;
00059 typedef const CharType *const_iterator;
00060
00061
00062 iterator begin() { return CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString>::begin(); }
00063
00067 iterator end() { return CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString>::end(); }
00068
00072 size_type size() const { return CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString>::size(); }
00073
00077 size_type length() const { return CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString>::length(); }
00078
00082 bool empty() const { return CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString>::empty(); }
00083 const CharType *data() const { return CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString>::data(); }
00084
00088 CharType *data() { return CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString>::data(); }
00089
00090 #endif
00091
00092 CL_StringReference();
00093
00097 CL_StringReference(const StdString &source);
00098
00102 CL_StringReference(const CL_StringReference &source);
00103
00109 CL_StringReference(const CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString> &source);
00110
00114 CL_StringReference(const char *c_str);
00115
00121 CL_StringReference(const char *c_str, size_type length, bool null_terminated);
00122
00126 CL_StringReference(const wchar_t *wc_str);
00127
00133 CL_StringReference(const wchar_t *wc_str, size_type length, bool null_terminated);
00134 ~CL_StringReference();
00135
00136 const CharType *c_str() const;
00137
00141 void set_length(size_type length);
00142
00143 CL_StringReference<CharType, StdString> &operator =(const CL_StringReference<CharType, StdString> &source);
00144 CL_StringReference<CharType, StdString> &operator =(const CL_StringData<CharType, CL_StringReference<CharType, StdString>, StdString> &source);
00145 CL_StringReference<CharType, StdString> &operator =(const char *c_str);
00146 CL_StringReference<CharType, StdString> &operator =(const wchar_t *c_str);
00147
00148 protected:
00149
00151 void clear() const;
00152
00157 void create_temp(const CharType *data, size_type length) const;
00158
00159 mutable bool null_terminated;
00160 mutable bool temporary;
00161 };
00162
00163 #endif
00164