Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JsonLine Class Reference

Detailed Description

JsonLine is an object used to aggregate a set of key:value pairs for output into a JSON log.

Definition at line 119 of file json_logger.hpp.

+ Collaboration diagram for JsonLine:

#include <json_logger.hpp>

Classes

struct  ArrayTag
 
struct  DictionaryTag
 

Public Member Functions

 JsonLine (JsonLogger *logger, std::ostream &os)
 ctor: bind output More...
 
 JsonLine (const JsonLine &)=delete
 non-copyable: delete copy-constructor More...
 
 JsonLine (JsonLine &&o)
 move-constructor: unlink pointer More...
 
 ~JsonLine ()
 destructor: deliver to output More...
 
template<typename Key >
JsonLine arr (const Key &key)
 return JsonLine has sub-dictionary of this one More...
 
void Close ()
 close the line More...
 
size_t items () const
 number of items already put More...
 
JsonLine obj ()
 return JsonLine has sub-dictionary of this one More...
 
template<typename Type >
JsonLineoperator<< (Type const &t)
 output any type More...
 
JsonLineoperator<< (const JsonBeginObj &t)
 
JsonLineoperator<< (const JsonEndObj &)
 
JsonLineoperator= (const JsonLine &)=delete
 non-copyable: delete assignment operator More...
 
void PutEscapedChar (char ch)
 
void PutSeparator ()
 put an items separator (either ',' or ':') and increment counter. More...
 
template<typename Key >
JsonLine sub (const Key &key)
 return JsonLine has sub-dictionary of this one More...
 

Public Attributes

size_t items_ = 0
 items counter for output stream More...
 
std::ostream & os_
 reference to output stream More...
 
bool sub_array_ = false
 indicator for sub-array. More...
 
bool sub_dict_ = false
 indicator for sub-dictionaries. More...
 

Private Member Functions

 JsonLine (struct DictionaryTag, JsonLine &parent)
 construct sub-dictionary More...
 
 JsonLine (struct ArrayTag, JsonLine &parent)
 construct sub-dictionary More...
 

Private Attributes

std::unique_lock< std::mutex > lock_
 lock on the logger output stream More...
 
JsonLoggerlogger_ = nullptr
 when destructed this object is delivered to the output. More...
 

Constructor & Destructor Documentation

JsonLine ( JsonLogger logger,
std::ostream &  os 
)
inline

ctor: bind output

Definition at line 123 of file json_logger.hpp.

References JsonLine::lock_, JsonLine::logger_, and JsonLogger::mutex_.

Referenced by JsonLine::arr(), JsonLine::obj(), and JsonLine::sub().

JsonLine ( const JsonLine )
delete

non-copyable: delete copy-constructor

JsonLine ( JsonLine &&  o)
inline

move-constructor: unlink pointer

Definition at line 134 of file json_logger.hpp.

~JsonLine ( )
inline

destructor: deliver to output

Definition at line 161 of file json_logger.hpp.

References JsonLine::Close().

JsonLine ( struct DictionaryTag  ,
JsonLine parent 
)
inlineprivate

construct sub-dictionary

Definition at line 254 of file json_logger.hpp.

JsonLine ( struct ArrayTag  ,
JsonLine parent 
)
inlineprivate

construct sub-dictionary

Definition at line 258 of file json_logger.hpp.

Member Function Documentation

JsonLine arr ( const Key &  key)
inline

return JsonLine has sub-dictionary of this one

Definition at line 197 of file json_logger.hpp.

References thrill::api::ArrayTag, JsonLine::JsonLine(), JsonLine::operator<<(), JsonLine::os_, and JsonLine::PutSeparator().

void Close ( )
inline

close the line

Definition at line 166 of file json_logger.hpp.

References JsonLine::items_, JsonLine::logger_, JsonLine::os_, JsonLine::sub_array_, and JsonLine::sub_dict_.

Referenced by JsonLine::~JsonLine().

size_t items ( ) const
inline

number of items already put

Definition at line 183 of file json_logger.hpp.

References JsonLine::items_.

JsonLine obj ( )
inline

return JsonLine has sub-dictionary of this one

Definition at line 206 of file json_logger.hpp.

References JsonLine::items_, JsonLine::JsonLine(), and JsonLine::os_.

JsonLine & operator<< ( Type const &  t)
inline

output any type

template << forwards to Put for ADL type switching

Definition at line 407 of file json_logger.hpp.

References thrill::common::Put(), and JsonLine::PutSeparator().

Referenced by JsonLine::arr(), JsonLine::operator<<(), and JsonLine::sub().

JsonLine& operator<< ( const JsonBeginObj t)
inline
JsonLine& operator<< ( const JsonEndObj )
inline

Definition at line 155 of file json_logger.hpp.

References JsonLine::os_.

JsonLine& operator= ( const JsonLine )
delete

non-copyable: delete assignment operator

void PutEscapedChar ( char  ch)
inline

Definition at line 222 of file json_logger.hpp.

References JsonLine::os_.

Referenced by thrill::common::Put().

void PutSeparator ( )
inline

put an items separator (either ',' or ':') and increment counter.

Definition at line 215 of file json_logger.hpp.

References JsonLine::items_, and JsonLine::os_.

Referenced by JsonLine::arr(), JsonLine::operator<<(), and JsonLine::sub().

JsonLine sub ( const Key &  key)
inline

return JsonLine has sub-dictionary of this one

Definition at line 187 of file json_logger.hpp.

References JsonLine::JsonLine(), JsonLine::operator<<(), JsonLine::os_, and JsonLine::PutSeparator().

Referenced by Manager::RunTask().

Member Data Documentation

size_t items_ = 0

items counter for output stream

Definition at line 266 of file json_logger.hpp.

Referenced by JsonLine::Close(), JsonLine::items(), JsonLine::obj(), JsonLine::operator<<(), thrill::common::Put(), and JsonLine::PutSeparator().

std::unique_lock<std::mutex> lock_
private

lock on the logger output stream

Definition at line 251 of file json_logger.hpp.

Referenced by JsonLine::JsonLine().

JsonLogger* logger_ = nullptr
private

when destructed this object is delivered to the output.

Definition at line 248 of file json_logger.hpp.

Referenced by JsonLine::Close(), and JsonLine::JsonLine().

bool sub_array_ = false

indicator for sub-array.

Definition at line 272 of file json_logger.hpp.

Referenced by JsonLine::Close().

bool sub_dict_ = false

indicator for sub-dictionaries.

Definition at line 269 of file json_logger.hpp.

Referenced by JsonLine::Close().


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