~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.cc

  • Committer: Brian Aker
  • Date: 2010-10-20 20:26:18 UTC
  • mfrom: (1859.2.13 refactor)
  • Revision ID: brian@tangent.org-20101020202618-9222n39lm329urv5
Merge for Brian 

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
  str_length=0;
118
118
  if (Alloced_length < arg_length)
119
119
  {
120
 
    if (Alloced_length > 0)
121
 
      free();
 
120
    free();
122
121
    if (!(Ptr=(char*) malloc(arg_length)))
123
122
      return true;
124
123
    Alloced_length=arg_length;
219
218
  return false;
220
219
}
221
220
 
222
 
bool String::copy(const std::string& arg, const CHARSET_INFO * const cs)        // Allocate new string
223
 
{
224
 
  if (alloc(arg.size()))
225
 
    return true;
226
 
 
227
 
  if ((str_length= arg.size()))
228
 
    memcpy(Ptr, arg.c_str(), arg.size());
229
 
 
230
 
  Ptr[arg.size()]= 0;
231
 
  str_charset= cs;
232
 
 
233
 
  return false;
234
 
}
235
 
 
236
221
bool String::copy(const char *str,size_t arg_length, const CHARSET_INFO * const cs)
237
222
{
238
223
  if (alloc(arg_length))
244
229
  return false;
245
230
}
246
231
 
 
232
 
247
233
/*
248
234
  Checks that the source string can be just copied to the destination string
249
235
  without conversion.
833
819
  return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end;
834
820
}
835
821
 
836
 
std::ostream& operator<<(std::ostream& output, const String &str)
837
 
{
838
 
  output << "String:(";
839
 
  output <<  const_cast<String&>(str).c_str();
840
 
  output << ", ";
841
 
  output << str.length();
842
 
  output << ")";
843
 
 
844
 
  return output;  // for multiple << operators.
845
 
}
846
 
 
847
822
} /* namespace drizzled */
848
823
 
849
824
bool operator==(const drizzled::String &s1, const drizzled::String &s2)