| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //
- // properties.hpp
- // logger
- //
- // Created by Sam Jaffe on 10/3/15.
- //
- //
- #pragma once
- #include <map>
- #include <string>
- #include <vector>
- #include "variant/variant.hpp"
- namespace logging {
- struct properties;
- using object_t = std::map<std::string, properties>;
- using array_t = std::vector<properties>;
- struct properties {
- properties mergedWith(properties const & other) const;
-
- bool contains(std::string const & key) const;
- bool contains(std::size_t idx) const;
-
- object_t const & object() const;
- array_t const & array() const;
- properties const & operator[](std::string const & key) const;
- properties const & operator[](char const * key) const {
- return operator[](std::string(key));
- }
- properties const & operator[](std::size_t idx) const;
- operator std::string const &() const;
- std::string const & str() const;
- operator int() const;
- operator bool() const;
- variant<object_t, array_t, std::string, int, bool> data;
- };
-
- namespace property {
- inline properties _obj(object_t const& m) { return {m}; }
- inline properties _arr(array_t const& l) { return {l}; }
- inline properties _v(std::string const & t) { return {t}; }
- // [char const *] will cast to [int] over [std::string const &]
- inline properties _v(char const * t) { return {std::string(t)}; }
- inline properties _v(int t) { return {t}; }
- inline properties _v(bool t) { return {t}; }
- }
-
- extern properties const DEFAULT_APPENDER_SCHEMA;
- extern properties const DEFAULT_LOGGER_SCHEMA;
- }
|