Electroneum
epee::serialization::convert_to_integral< std::string, uint64_t, false > Struct Template Reference

#include <portable_storage_val_converters.h>

Static Public Member Functions

static void convert (const std::string &from, uint64_t &to)
 

Detailed Description

template<>
struct epee::serialization::convert_to_integral< std::string, uint64_t, false >

Definition at line 141 of file portable_storage_val_converters.h.

Member Function Documentation

◆ convert()

static void epee::serialization::convert_to_integral< std::string, uint64_t, false >::convert ( const std::string &  from,
uint64_t to 
)
inlinestatic

Definition at line 143 of file portable_storage_val_converters.h.

144  {
145  MTRACE("Converting std::string to uint64_t. Source: " << from);
146  // String only contains digits
147  if(std::all_of(from.begin(), from.end(), epee::misc_utils::parse::isdigit))
148  to = boost::lexical_cast<uint64_t>(from);
149  // MyMonero ISO 8061 timestamp (2017-05-06T16:27:06Z)
150  else if (boost::regex_match (from, boost::regex("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\dZ")))
151  {
152  // Convert to unix timestamp
153 #ifdef HAVE_STRPTIME
154  struct tm tm;
155  if (strptime(from.c_str(), "%Y-%m-%dT%H:%M:%S", &tm))
156 #else
157  std::tm tm = {};
158  std::istringstream ss(from);
159  if (ss >> std::get_time(&tm, "%Y-%m-%dT%H:%M:%S"))
160 #endif
161  to = std::mktime(&tm);
162  } else
164  }
#define ASSERT_AND_THROW_WRONG_CONVERSION()
#define MTRACE(x)
Definition: misc_log_ex.h:77
unsigned __int64 uint64_t
Definition: stdint.h:136
Here is the call graph for this function:

The documentation for this struct was generated from the following file: