1
#ifndef BINLOG_ENCODE_H_INCLUDED
2
#define BINLOG_ENCODE_H_INCLUDED
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_SERIALIZE_BINLOG_ENCODING_H
21
#define DRIZZLED_SERIALIZE_BINLOG_ENCODING_H
9
#define LENGTH_ENCODE_MAX_BYTES (sizeof(size_t) + 1)
28
#define LENGTH_ENCODE_MAX_BYTES (sizeof(std::size_t) + 1)
13
30
inline unsigned char *
14
31
length_encode(std::size_t length, unsigned char *buf)
50
67
inline unsigned char *
51
length_decode(unsigned char *buf, size_t *plen)
68
length_decode(unsigned char *buf, std::size_t *plen)
58
size_t bytes= 1 << (*buf + 1);
75
std::size_t bytes= 1 << (*buf + 1);
59
76
unsigned char *ptr= buf + 1;
77
std::size_t length= 0;
61
78
for (unsigned int i = 0 ; i < bytes ; ++i)
62
79
length |= *ptr++ << (8 * i);