~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/client.cc

  • Committer: Mark Atwood
  • Date: 2011-10-27 05:08:12 UTC
  • mfrom: (2445.1.11 rf)
  • Revision ID: me@mark.atwood.name-20111027050812-1icvs72lb0u4xdc4
mergeĀ lp:~olafvdspek/drizzle/refactor8

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
 
21
 
21
22
#include <cstdio>
22
 
#include "drizzled/plugin/client.h"
23
 
 
24
 
namespace drizzled
25
 
{
26
 
 
27
 
bool plugin::Client::store(const DRIZZLE_TIME *from)
 
23
 
 
24
#include <drizzled/plugin/client.h>
 
25
#include <drizzled/type/time.h>
 
26
 
 
27
namespace drizzled {
 
28
 
 
29
void plugin::Client::store(const type::Time *from)
28
30
{
29
31
  const size_t buff_len= 40;
30
32
  char buff[buff_len];
33
35
 
34
36
  switch (from->time_type)
35
37
  {
36
 
  case DRIZZLE_TIMESTAMP_DATETIME:
 
38
  case type::DRIZZLE_TIMESTAMP_DATETIME:
37
39
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
38
40
                    (int) from->year,
39
41
                    (int) from->month,
45
47
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
46
48
    break;
47
49
 
48
 
  case DRIZZLE_TIMESTAMP_DATE:
 
50
  case type::DRIZZLE_TIMESTAMP_DATE:
49
51
    length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
50
52
                    (int) from->year,
51
53
                    (int) from->month,
52
54
                    (int) from->day);
53
55
    break;
54
56
 
55
 
  case DRIZZLE_TIMESTAMP_TIME:
 
57
  case type::DRIZZLE_TIMESTAMP_TIME:
56
58
    day= (from->year || from->month) ? 0 : from->day;
57
59
    length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
58
60
                    from->neg ? "-" : "",
63
65
      length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
64
66
    break;
65
67
 
66
 
  case DRIZZLE_TIMESTAMP_NONE:
67
 
  case DRIZZLE_TIMESTAMP_ERROR:
 
68
  case type::DRIZZLE_TIMESTAMP_NONE:
 
69
  case type::DRIZZLE_TIMESTAMP_ERROR:
68
70
  default:
69
 
    assert(0);
70
 
    return false;
 
71
    assert(false);
 
72
    return;
71
73
  }
72
74
 
73
75
  return store(buff);
74
76
}
75
77
 
76
 
bool plugin::Client::store(const char *from)
 
78
void plugin::Client::store(const char *from)
77
79
{
78
 
  if (from == NULL)
79
 
    return store();
80
 
  return store(from, strlen(from));
 
80
  return from ? store(from, strlen(from)) : store();
81
81
}
82
82
 
83
83