2016-02-22 05:21:15 +08:00
|
|
|
#pragma once
|
|
|
|
|
2016-07-18 01:32:35 +08:00
|
|
|
#include <iostream>
|
2016-02-22 05:21:15 +08:00
|
|
|
#include <string>
|
|
|
|
|
2016-08-08 16:32:34 +08:00
|
|
|
#include "fmt/format.h"
|
2016-07-18 01:32:35 +08:00
|
|
|
#include "storage/model/properties/properties.hpp"
|
2016-08-02 22:41:53 +08:00
|
|
|
#include "storage/model/properties/traversers/consolewriter.hpp"
|
2016-08-08 16:32:34 +08:00
|
|
|
#include "storage/model/properties/traversers/jsonwriter.hpp"
|
2016-07-18 01:32:35 +08:00
|
|
|
|
|
|
|
using std::cout;
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
void print_props(const Properties &properties)
|
|
|
|
{
|
|
|
|
StringBuffer buffer;
|
|
|
|
JsonWriter<StringBuffer> writer(buffer);
|
|
|
|
properties.accept(writer);
|
|
|
|
cout << buffer.str() << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define PRINT_PROPS(_PROPS_) print_props(_PROPS_);
|
|
|
|
#else
|
|
|
|
#define PRINT_PROPS(_)
|
|
|
|
#endif
|
2016-08-02 22:41:53 +08:00
|
|
|
|
|
|
|
void cout_properties(const Properties &properties)
|
|
|
|
{
|
|
|
|
ConsoleWriter writer;
|
|
|
|
properties.accept(writer);
|
|
|
|
cout << "----" << endl;
|
|
|
|
}
|
|
|
|
|
2016-08-08 16:32:34 +08:00
|
|
|
void cout_property(const std::string &key, const Property &property)
|
2016-08-02 22:41:53 +08:00
|
|
|
{
|
|
|
|
ConsoleWriter writer;
|
|
|
|
writer.handle(key, property);
|
|
|
|
cout << "----" << endl;
|
|
|
|
}
|
2016-08-08 16:32:34 +08:00
|
|
|
|
|
|
|
// wrapper for fmt format
|
|
|
|
template <typename... Args>
|
|
|
|
std::string format(const std::string &format_str, const Args &... args)
|
|
|
|
{
|
|
|
|
return fmt::format(format_str, args...);
|
|
|
|
}
|
|
|
|
|
|
|
|
// wrapper for single code line
|
|
|
|
template <typename... Args>
|
|
|
|
std::string code_line(const std::string &format_str, const Args &... args)
|
|
|
|
{
|
|
|
|
return "\t" + format(format_str, args...) + "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|