libfoedus-core
FOEDUS Core Library
foedus::externalize Namespace Reference

Object Externalization. More...

Detailed Description

Object Externalization.

Overview
Analogous to java.io.Externalizable. We externalize savepoint and configuration objects. We never use them for main data files, so the code here does not have to be seriously optimized.
tinyxml2 rather than boost::serialize
boost::serialize is not header-only. Rather, we contain tinyxml2, a handy zlib-licensed library with a CMake project file. This gives an added benefit of pretty XML file as the resulting file, which can be hand-editted with text editor. For more details of tinyxml2, see http://www.grinninglizard.com/tinyxml2/
Terminology: Externalization vs Serialization
I just picked the word Externalize because serialization, or serializable, has totally different meanings in DBMS and lock-free algorithm.

Classes

struct  Externalizable
 Represents an object that can be written to and read from files/bytes in XML format. More...
 
struct  TinyxmlGetter
 Functor to help use tinyxml2's Element QueryXxxText(). More...
 
struct  TinyxmlGetter< assorted::FixedString< MAXLEN, CHAR > >
 
struct  TinyxmlGetter< bool >
 
struct  TinyxmlGetter< double >
 
struct  TinyxmlGetter< float >
 
struct  TinyxmlGetter< int16_t >
 
struct  TinyxmlGetter< int32_t >
 
struct  TinyxmlGetter< int64_t >
 
struct  TinyxmlGetter< int8_t >
 
struct  TinyxmlGetter< std::string >
 
struct  TinyxmlGetter< uint16_t >
 
struct  TinyxmlGetter< uint32_t >
 
struct  TinyxmlGetter< uint64_t >
 
struct  TinyxmlGetter< uint8_t >
 
struct  TinyxmlSetter
 Functor to help use tinyxml2's Element SetText(). More...
 
struct  TinyxmlSetter< assorted::FixedString< MAXLEN, CHAR > >
 
struct  TinyxmlSetter< std::string >
 

Functions

template<typename T , typename LARGEST_TYPE , typename LARGEST_GETTER >
tinyxml2::XMLError get_smaller_int (const tinyxml2::XMLElement *element, T *out)
 
ErrorStack insert_comment_impl (tinyxml2::XMLElement *element, const std::string &comment)
 

Function Documentation

template<typename T , typename LARGEST_TYPE , typename LARGEST_GETTER >
tinyxml2::XMLError foedus::externalize::get_smaller_int ( const tinyxml2::XMLElement *  element,
T *  out 
)

Definition at line 57 of file tinyxml_wrapper.hpp.

57  {
58  LARGEST_TYPE tmp;
59  LARGEST_GETTER largest_getter;
60  tinyxml2::XMLError ret = largest_getter(element, &tmp);
61  if (ret != tinyxml2::XML_SUCCESS) {
62  return ret;
63  }
64  *out = static_cast<T>(tmp);
65  if (static_cast<LARGEST_TYPE>(*out) != tmp) {
66  return tinyxml2::XML_CAN_NOT_CONVERT_TEXT;
67  } else {
68  return tinyxml2::XML_SUCCESS;
69  }
70 }
ErrorStack foedus::externalize::insert_comment_impl ( tinyxml2::XMLElement *  element,
const std::string &  comment 
)

Definition at line 159 of file externalizable.cpp.

References CHECK_OUTOFMEMORY, and foedus::kRetOk.

Referenced by foedus::externalize::Externalizable::add_child_element(), foedus::externalize::Externalizable::add_element(), and foedus::externalize::Externalizable::insert_comment().

159  {
160  if (comment.size() > 0) {
161  tinyxml2::XMLComment* cm = element->GetDocument()->NewComment(comment.c_str());
162  CHECK_OUTOFMEMORY(cm);
163  tinyxml2::XMLNode* parent = element->Parent();
164  if (!parent) {
165  element->GetDocument()->InsertFirstChild(cm);
166  } else {
167  tinyxml2::XMLNode* previous = element->PreviousSibling();
168  if (previous) {
169  parent->InsertAfterChild(previous, cm);
170  } else {
171  parent->InsertFirstChild(cm);
172  }
173  }
174  }
175  return kRetOk;
176 }
#define CHECK_OUTOFMEMORY(ptr)
This macro checks if ptr is nullptr, and if so exists with kErrorCodeOutofmemory error stack...
const ErrorStack kRetOk
Normal return value for no-error case.

Here is the caller graph for this function: