Electroneum
string.h File Reference
#include <memory>
#include "serialization.h"
Include dependency graph for string.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<template< bool > class Archive>
bool do_serialize (Archive< false > &ar, std::string &str)
 
template<template< bool > class Archive>
bool do_serialize (Archive< true > &ar, std::string &str)
 

Function Documentation

◆ do_serialize() [1/2]

template<template< bool > class Archive>
bool do_serialize ( Archive< false > &  ar,
std::string &  str 
)
inline

Definition at line 37 of file string.h.

38 {
39  size_t size = 0;
40  ar.serialize_varint(size);
41  if (ar.remaining_bytes() < size)
42  {
43  ar.stream().setstate(std::ios::failbit);
44  return false;
45  }
46 
47  std::unique_ptr<std::string::value_type[]> buf(new std::string::value_type[size]);
48  ar.serialize_blob(buf.get(), size);
49  str.erase();
50  str.append(buf.get(), size);
51  return true;
52 }
const char * buf
Definition: slow_memmem.cpp:74

◆ do_serialize() [2/2]

template<template< bool > class Archive>
bool do_serialize ( Archive< true > &  ar,
std::string &  str 
)
inline

Definition at line 56 of file string.h.

57 {
58  size_t size = str.size();
59  ar.serialize_varint(size);
60  ar.serialize_blob(const_cast<std::string::value_type*>(str.c_str()), size);
61  return true;
62 }