#include <array.hxx>

Public Member Functions

 ~Array ()
 

Static Public Member Functions

static OstreamBuild (Ostream &os, const String &name, const String &beginName, const IT &begin, const String &endName, const IT &end)
 
static WriterBuild (Writer &writer, const String &name, const String &beginName, const IT &begin, const String &endName, const IT &end)
 

Private Member Functions

 Array (Ostream &os)
 
Array operator= (Array &)
 
bool Write (const String &name, const String &beginName, const IT &begin, const String &endName, const IT &end)
 

Static Private Member Functions

static bool Write (Writer &writer, const String &name, const String &beginName, const IT &begin, const String &endName, const IT &end)
 

Private Attributes

std::unique_ptr< Streamstream
 
std::unique_ptr< Writerwriter
 

Detailed Description

template<typename IT>
class SHA_Logger::Array< IT >

used to write array parameter.

Definition at line 32 of file array.hxx.

Constructor & Destructor Documentation

template<typename IT >
SHA_Logger::Array< IT >::~Array ( )
inline

Definition at line 35 of file array.hxx.

35 { assert(this->writer->IsComplete()); }
std::unique_ptr< Writer > writer
Definition: array.hxx:123
template<typename IT >
SHA_Logger::Array< IT >::Array ( Ostream os)
inlineprivate

Definition at line 66 of file array.hxx.

66  : stream(std::unique_ptr<Stream>(new Stream(os))),
67  writer(std::unique_ptr<Writer>(new Writer(*this->stream))) {}
std::unique_ptr< Stream > stream
Definition: array.hxx:122
rapidjson::OStreamWrapper Stream
Definition: typedef.hxx:32
rapidjson::PrettyWriter< Stream > Writer
Definition: typedef.hxx:33
std::unique_ptr< Writer > writer
Definition: array.hxx:123

Member Function Documentation

template<typename IT >
static Ostream& SHA_Logger::Array< IT >::Build ( Ostream os,
const String name,
const String beginName,
const IT &  begin,
const String endName,
const IT &  end 
)
inlinestatic

Instantiate a new json writer using the stream passed as argument and write array information.

Returns
stream reference filled up with Iterator object information, error information in case of failure.

Definition at line 42 of file array.hxx.

45  {
46  std::unique_ptr<Array> builder = std::unique_ptr<Array>(new Array(os));
47  builder->Write(name, beginName, begin, endName, end);
48 
49  return os;
50  }
Array(Ostream &os)
Definition: array.hxx:66
template<typename IT >
static Writer& SHA_Logger::Array< IT >::Build ( Writer writer,
const String name,
const String beginName,
const IT &  begin,
const String endName,
const IT &  end 
)
inlinestatic

Use json writer passed as parameter to write iterator information.

Returns
stream reference filled up with Array object information, error information in case of failure.

Definition at line 56 of file array.hxx.

59  {
60  Write(writer, name, beginName, begin, endName, end);
61 
62  return writer;
63  }
bool Write(const String &name, const String &beginName, const IT &begin, const String &endName, const IT &end)
Definition: array.hxx:70
std::unique_ptr< Writer > writer
Definition: array.hxx:123
template<typename IT >
Array SHA_Logger::Array< IT >::operator= ( Array< IT > &  )
inlineprivate

Definition at line 68 of file array.hxx.

68 {} // Not Implemented
template<typename IT >
bool SHA_Logger::Array< IT >::Write ( const String name,
const String beginName,
const IT &  begin,
const String endName,
const IT &  end 
)
inlineprivate

Definition at line 70 of file array.hxx.

73  { return Write(*this->writer, name, beginName, begin, endName, end); }
bool Write(const String &name, const String &beginName, const IT &begin, const String &endName, const IT &end)
Definition: array.hxx:70
std::unique_ptr< Writer > writer
Definition: array.hxx:123
template<typename IT >
static bool SHA_Logger::Array< IT >::Write ( Writer writer,
const String name,
const String beginName,
const IT &  begin,
const String endName,
const IT &  end 
)
inlinestaticprivate

Definition at line 75 of file array.hxx.

78  {
79  // Add Error Object log in case of failure
80  if (name.empty() || beginName.empty() || endName.empty())
81  {
82  Error::Build(writer, __FILE__, __LINE__,
83  "Missing parameter: " +
84  (name.empty()) ? "+ name " : "" +
85  (beginName.empty()) ? "+ beginName " : "" +
86  (endName.empty()) ? "+ endName " : "");
87  return false;
88  }
89 
90  // 2*N for non random accessible iterator
91  const int kdataSize = static_cast<int>(std::distance(begin, end));
92  if (kdataSize < 1)
93  {
94  Error::Build(writer, __FILE__, __LINE__, "empty/invalid sequence detected.");
95  return false;
96  }
97 
98  // StartBuild - Main information
99  writer.StartObject();
100  writer.Key("type");
101  writer.String("array");
102  writer.Key("name");
103  writer.String(name);
104 
105  // Add data
106  writer.Key("data");
107  ValueType::BuildArray<IT>(writer, begin, end);
108 
109  // Add Iterators
110  writer.Key("iterators");
111  writer.StartArray();
112  Iterator::Build(writer, name, beginName, 0);
113  Iterator::Build(writer, name, endName, static_cast<int>(kdataSize));
114  writer.EndArray();
115 
116  // Finish object
117  writer.EndObject();
118 
119  return true;
120  }
static Ostream & Build(Ostream &os, const String &file, int line, const String &message)
Definition: error.hxx:41
static Ostream & Build(Ostream &os, const String &parentId, const String &name, int index, const String &comment="")
Definition: iterator.hxx:43
std::unique_ptr< Writer > writer
Definition: array.hxx:123

Member Data Documentation

template<typename IT >
std::unique_ptr<Stream> SHA_Logger::Array< IT >::stream
private

Definition at line 122 of file array.hxx.

template<typename IT >
std::unique_ptr<Writer> SHA_Logger::Array< IT >::writer
private

Definition at line 123 of file array.hxx.


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