~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.h

  • Committer: Brian Aker
  • Date: 2010-12-19 06:20:54 UTC
  • mfrom: (2005.1.1 bug673105)
  • Revision ID: brian@tangent.org-20101219062054-1kt0l3dxs4z2z8md
Merge Dave.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
/* This file is originally from the mysql distribution. Coded by monty */
24
24
 
25
25
#include <drizzled/common.h>
26
 
 
27
26
#include <cassert>
28
27
#include <cstdlib>
29
28
#include <cstring>
30
29
#include <string>
31
30
 
32
 
#include "drizzled/visibility.h"
33
 
 
34
31
#ifndef NOT_FIXED_DEC
35
32
#define NOT_FIXED_DEC                   (uint8_t)31
36
33
#endif
40
37
 
41
38
class String;
42
39
 
43
 
extern DRIZZLED_API String my_empty_string;
 
40
extern String my_empty_string;
44
41
extern const String my_null_string;
45
42
namespace memory { class Root; }
46
43
typedef struct charset_info_st CHARSET_INFO;
47
44
 
48
 
DRIZZLED_API std::string String_to_std_string(String const& s);
49
 
DRIZZLED_API String* set_String_from_std_string(String* s, std::string const& cs);
 
45
std::string String_to_std_string(String const& s);
 
46
String* set_String_from_std_string(String* s, std::string const& cs);
50
47
 
51
48
int sortcmp(const String *a,const String *b, const CHARSET_INFO * const cs);
52
49
int stringcmp(const String *a,const String *b);
61
58
                                 const char **from_end_pos);
62
59
 
63
60
 
64
 
class DRIZZLED_API String
 
61
class String
65
62
{
66
63
  char *Ptr;
67
64
  size_t str_length,Alloced_length;
220
217
      char *new_ptr;
221
218
      if (!(new_ptr= reinterpret_cast<char*>(::realloc(Ptr,arg_length))))
222
219
      {
223
 
        Alloced_length = 0;
224
 
        real_alloc(arg_length);
 
220
        Alloced_length = 0;
 
221
        real_alloc(arg_length);
225
222
      }
226
223
      else
227
224
      {
228
 
        Ptr=new_ptr;
229
 
        Alloced_length=arg_length;
 
225
        Ptr=new_ptr;
 
226
        Alloced_length=arg_length;
230
227
      }
231
228
    }
232
229
  }
249
246
 
250
247
  bool copy();                                  // Alloc string if not alloced
251
248
  bool copy(const String &s);                   // Allocate new string
252
 
  bool copy(const std::string&, const CHARSET_INFO * const cs); // Allocate new string
253
249
  bool copy(const char *s,size_t arg_length, const CHARSET_INFO * const cs);    // Allocate new string
254
250
  static bool needs_conversion(size_t arg_length,
255
251
                               const CHARSET_INFO * const cs_from, const CHARSET_INFO * const cs_to,
256
252
                               size_t *offset);
257
253
  bool set_or_copy_aligned(const char *s, size_t arg_length, const CHARSET_INFO * const cs);
258
254
  bool copy(const char*s,size_t arg_length, const CHARSET_INFO * const csfrom,
259
 
            const CHARSET_INFO * const csto, size_t *errors);
 
255
            const CHARSET_INFO * const csto, size_t *errors);
260
256
  bool append(const String &s);
261
257
  bool append(const char *s);
262
258
  bool append(const char *s,size_t arg_length);
276
272
    else
277
273
    {
278
274
      if (realloc(str_length+1))
279
 
        return 1;
 
275
        return 1;
280
276
      Ptr[str_length++]=chr;
281
277
    }
282
278
    return 0;
343
339
bool check_if_only_end_space(const CHARSET_INFO * const cs, char *str,
344
340
                             char *end);
345
341
 
346
 
std::ostream& operator<<(std::ostream& output, const String &str);
347
 
 
348
342
} /* namespace drizzled */
349
343
 
350
344
bool operator==(const drizzled::String &s1, const drizzled::String &s2);