/usr/include/log4cpp/FactoryParams.hh is in liblog4cpp5-dev 1.1.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | #if !defined(h_3e645482_ae6a_43e5_8f81_abbc4200212d)
#define h_3e645482_ae6a_43e5_8f81_abbc4200212d
#include <map>
#include <string>
#include <sstream>
#include <stdexcept>
#include "Portability.hh"
namespace log4cpp
{
class FactoryParams;
namespace details
{
class base_validator_data
{
public:
base_validator_data(const char* tag, const FactoryParams* params) : tag_(tag), params_(params){}
protected:
const char* tag_;
const FactoryParams* params_;
template<typename T>
void assign(const std::string& param_value, T& value) const
{
assign_impl(param_value, value);
}
template<typename T>
void assign_impl(const std::string& param_value, T& value) const
{
std::stringstream s;
s << param_value;
s >> value;
}
void assign_impl(const std::string& param_value, std::string& value) const
{
value = param_value;
}
void throw_error(const char* param_name) const
{
std::stringstream s;
s << "Property '" << param_name << "' required to configure " << tag_;
throw std::runtime_error(s.str());
}
};
class parameter_validator;
}
class LOG4CPP_EXPORT FactoryParams
{
typedef std::map<std::string, std::string> storage_t;
storage_t storage_;
public:
typedef storage_t::const_iterator const_iterator;
const std::string& operator[](const std::string& v) const;
std::string& operator[](const std::string& v) { return storage_[v]; }
details::parameter_validator get_for(const char* tag) const;
const_iterator find(const std::string& t) const;
const_iterator begin() const { return storage_.begin(); }
const_iterator end() const { return storage_.end(); }
};
namespace details
{
class optional_params_validator;
class required_params_validator : public base_validator_data
{
public:
required_params_validator(const char* tag, const FactoryParams* params) : base_validator_data(tag, params) {}
#if defined(_MSC_VER) && _MSC_VER < 1300
template<typename T>
optional_params_validator optional(const char* param, T& value) const { optional_params_validator v(tag_, params_); v(param, value); return v; }
#else
template<typename T>
optional_params_validator optional(const char* param, T& value) const;
#endif
template<typename T>
const required_params_validator& operator()(const char* param, T& value) const
{
FactoryParams::const_iterator i = params_->find(param);
if (i != params_->end())
assign(i->second, value);
else
throw_error(param);
return *this;
}
};
class optional_params_validator : public base_validator_data
{
public:
optional_params_validator(const char* tag, const FactoryParams* params) : base_validator_data(tag, params) {}
template<typename T>
required_params_validator required(const char* param, T& value) const { required_params_validator v(tag_, params_); v(param, value); return v; }
template<typename T>
const optional_params_validator& operator()(const char* param, T& value) const
{
FactoryParams::const_iterator i = params_->find(param);
if (i != params_->end())
assign(i->second, value);
return *this;
}
};
class parameter_validator : public base_validator_data
{
public:
parameter_validator(const char* tag, const FactoryParams* params) : base_validator_data(tag, params) {}
template<typename T>
required_params_validator required(const char* param, T& value) const { required_params_validator v(tag_, params_); v(param, value); return v; }
template<typename T>
optional_params_validator optional(const char* param, T& value) const { optional_params_validator v(tag_, params_); v(param, value); return v; }
};
#if !(defined(_MSC_VER) && _MSC_VER < 1300)
template<typename T>
optional_params_validator
required_params_validator::optional(const char* param, T& value) const
{
optional_params_validator v(tag_, params_);
v(param, value);
return v;
}
#endif
}
inline details::parameter_validator FactoryParams::get_for(const char* tag) const
{
return details::parameter_validator(tag, this);
}
}
#endif // h_3e645482_ae6a_43e5_8f81_abbc4200212d
|