ores.cpp.asset_class.authorities

Table of Contents

The C++ projection of the catalogue's mapping. asset_class_for_authority takes the authority text a datum or an index names.

An authority the mapping leaves empty – correlation and generic – is simply absent from the function, so it answers std::nullopt for it. asset_class_codes carries the taxonomy's own codes, in display order, so a test-data generator that must emit a code the catalogue holds reads it rather than restating the list.

The header is written into ores.marketdata.api, beside the datum model whose authorities it maps. The build already links ores.refdata.api into ores.marketdata.core, so the dependency direction is unchanged.

See the Template variable reference for the complete list of available variables and their semantics.

1. Template

The full template source. Edit here and re-tangle with compass build --direct tangle_codegen_templates to regenerate library/templates/cpp_asset_class_authorities.hpp.mustache.

{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/ores.cpp.asset_class.org. Edit the org source. }}
{{{cpp_license}}}
#ifndef ORES_MARKETDATA_API_DOMAIN_ASSET_CLASS_AUTHORITIES_HPP
#define ORES_MARKETDATA_API_DOMAIN_ASSET_CLASS_AUTHORITIES_HPP

#include <optional>
#include <string_view>

namespace ores::marketdata::domain {

/**
 * @brief The taxonomy's codes, in display order, as the catalogue declares
 * them.
 *
 * A test-data generator that must emit a code the catalogue holds reads this
 * rather than restating the list, so the taxonomy has one author.
 */
inline constexpr std::string_view asset_class_codes[] = {
{{#asset_class_catalogue}}
{{#taxonomy}}
    "{{code}}",
{{/taxonomy}}
{{/asset_class_catalogue}}
};

/**
 * @brief The refdata asset class an oresmd authority names, or nullopt where
 * it names none.
 *
 * Generated from ores.refdata.asset_class_catalogue, which declares the oresmd
 * namespace and the mapping. An authority the catalogue maps to no class, such
 * as a pairwise correlation or the generic wrapper, answers nullopt.
 */
[[nodiscard]] inline std::optional<std::string_view>
asset_class_for_authority(std::string_view authority) {
{{#asset_class_catalogue}}
{{#namespace}}
{{#refdata_code}}
    if (authority == "{{authority}}")
        return std::string_view{"{{refdata_code}}"};
{{/refdata_code}}
{{/namespace}}
{{/asset_class_catalogue}}
    return std::nullopt;
}

}

#endif

2. See also

Emacs 29.3 (Org mode 9.6.15)