/** * @file mix_cc/sql/value.h * @brief SQL语句中的设置数值 * @author Cat (null.null.null@qq.com) * @version 0.1 * @date 2021-09-17 * * Copyright: Baosight Co. Ltd. * DO NOT COPY/USE WITHOUT PERMISSION * */ #pragma once #include #include #include namespace mix_cc { namespace sql { template struct value_t { using value_type = Tp; private: Name val_name_; value_type value_; public: constexpr value_t(Name val, value_type value) : val_name_(val), value_(value) {} ~value_t() {} constexpr auto get_str() { return std::string(val_name_.c_str()) + "=" + get_value(); } constexpr auto get_col_name() { return std::string(val_name_.c_str()); } constexpr auto get_value() { std::string value_str; if constexpr (std::is_integral_v || std::is_floating_point_v) { value_str = boost::str(boost::format("%1%") % value_); } else { value_str = boost::str(boost::format("%2%%1%%2%") % value_ % '\''); } return value_str; } }; } // namespace sql } // namespace mix_cc