20#ifndef ORES_TRADING_DOMAIN_PRODUCT_TYPE_HPP
21#define ORES_TRADING_DOMAIN_PRODUCT_TYPE_HPP
30namespace ores::trading::domain {
50enum class product_type : std::uint8_t {
69[[nodiscard]]
inline std::string_view to_string(product_type pt) {
71 case product_type::unknown:
return "";
72 case product_type::swap:
return "swap";
73 case product_type::fx:
return "fx";
74 case product_type::bond:
return "bond";
75 case product_type::credit:
return "credit";
76 case product_type::equity:
return "equity";
77 case product_type::commodity:
return "commodity";
78 case product_type::composite:
return "composite";
79 case product_type::scripted:
return "scripted";
81 throw std::invalid_argument(
"Out-of-range product_type");
91[[nodiscard]]
inline std::optional<product_type>
92product_type_from_string(std::string_view sv) {
93 if (sv.empty())
return product_type::unknown;
94 if (sv ==
"swap")
return product_type::swap;
95 if (sv ==
"fx")
return product_type::fx;
96 if (sv ==
"bond")
return product_type::bond;
97 if (sv ==
"credit")
return product_type::credit;
98 if (sv ==
"equity")
return product_type::equity;
99 if (sv ==
"commodity")
return product_type::commodity;
100 if (sv ==
"composite")
return product_type::composite;
101 if (sv ==
"scripted")
return product_type::scripted;
117struct Reflector<
ores::trading::domain::product_type> {
118 using ReflType = std::string;
120 static ores::trading::domain::product_type to(
const ReflType& s) {
121 auto parsed = ores::trading::domain::product_type_from_string(s);
123 throw std::invalid_argument(
"Invalid product_type: '" + s +
"'");
128 static ReflType from(
const ores::trading::domain::product_type& v) {
129 return std::string(ores::trading::domain::to_string(v));
ORE Studio - Graphical interface and data management for Open Source Risk Engine.
Definition pricing_engine_type.hpp:27