0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DbtManaged.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef DBTMANAGED_H
23 #define DBTMANAGED_H
24 
25 #include <cstdlib>
26 
27 #include <db_cxx.h>
28 
29 namespace Hyperspace {
30 
31  class DbtManaged : public Dbt {
32  public:
34  clear();
35  set_flags(DB_DBT_REALLOC);
36  }
38  if (get_data() != 0)
39  free(get_data());
40  }
41  void set_str(const std::string &str) {
42  size_t size = str.length() + 1;
43  if (get_data() != 0)
44  free(get_data());
45  char *data = (char *)malloc(size);
46  strcpy(data, str.c_str());
47  set_data((void *)data);
48  set_size(size);
49  }
50  const char *get_str() {
51  return (const char *)get_data();
52  }
53  void clear() {
54  if (get_data() != 0)
55  free(get_data());
56  set_data(0);
57  set_size(0);
58  }
59 
60  };
61 
62 }
63 
64 #endif // DBTMANAGED_H
void set_str(const std::string &str)
Definition: DbtManaged.h:41
Po::typed_value< String > * str(String *v=0)
Definition: Properties.h:166
Hyperspace definitions
const char * get_str()
Definition: DbtManaged.h:50