Ignore:
Timestamp:
Jun 30, 2015, 3:12:47 PM (4 years ago)
Author:
nmedfort
Message:

Temporary check-in for dynamic unicode class compilation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.cpp

    r4618 r4626  
    1111namespace UCD {
    1212
    13 std::string canonicalize_value_name(const std::string prop_or_val) {
     13std::string canonicalize_value_name(const std::string & prop_or_val) {
    1414    std::locale loc;
    1515    std::stringstream s;
     
    2222}
    2323
    24 
    25 UnicodeSet UnsupportedPropertyObject::GetCodepointSet(const std::string value_spec) {
     24UnicodeSet UnsupportedPropertyObject::GetCodepointSet(const std::string &) {
    2625    throw std::runtime_error("Property " + UCD::property_full_name[the_property] + " unsupported.");
    2726}
    2827
    29 UnicodeSet EnumeratedPropertyObject::GetCodepointSet(const std::string value_spec) {
     28UnicodeSet UnsupportedPropertyObject::GetCodepointSet(const int) {
     29    throw std::runtime_error("Property " + UCD::property_full_name[the_property] + " unsupported.");
     30}
     31
     32UnicodeSet EnumeratedPropertyObject::GetCodepointSet(const std::string & value_spec) {
    3033    int property_enum_val = GetPropertyValueEnumCode(value_spec);
    3134    if (property_enum_val == -1) {
    32             throw std::runtime_error("Enumerated Property " + UCD::property_full_name[the_property] +  ": unknown value: " + value_spec);
     35        throw std::runtime_error("Enumerated Property " + UCD::property_full_name[the_property] +  ": unknown value: " + value_spec);
    3336    }
    34     else {
    35         return property_value_sets[property_enum_val];
    36     }
     37    return GetCodepointSet(property_enum_val);
    3738}
    3839
    39 int EnumeratedPropertyObject::GetPropertyValueEnumCode(const std::string s) {
     40UnicodeSet EnumeratedPropertyObject::GetCodepointSet(const int property_enum_val) const {
     41    assert (property_enum_val >= 0);
     42    return property_value_sets[property_enum_val];
     43}
     44
     45int EnumeratedPropertyObject::GetPropertyValueEnumCode(const std::string & value_spec) {
    4046    // The canonical full names are not stored in the precomputed alias map,
    4147    // to save space in the executable.   Add them if the property is used.
    4248    if (!aliases_initialized) {
    43         for (auto v = 0; v < property_value_full_names.size(); v++) {
    44             property_value_aliases.insert({canonicalize_value_name(property_value_full_names[v]), v});
     49        for (unsigned i = 0; i != property_value_full_names.size(); i++) {
     50            property_value_aliases.insert({canonicalize_value_name(property_value_full_names[i]), i});
    4551        }
    46         for (auto v = 0; v < property_value_enum_names.size(); v++) {
    47             property_value_aliases.insert({canonicalize_value_name(property_value_enum_names[v]), v});
     52        for (unsigned i = 0; i != property_value_enum_names.size(); i++) {
     53            property_value_aliases.insert({canonicalize_value_name(property_value_enum_names[i]), i});
    4854        }
    4955        aliases_initialized = true;
    5056    }
    51     auto valit = property_value_aliases.find(s);
    52     if (valit == property_value_aliases.end()) return -1;
    53     else return valit->second;
     57    const auto valit = property_value_aliases.find(value_spec);
     58    if (valit == property_value_aliases.end())
     59        return -1;
     60    return valit->second;
    5461}
    5562
    56 UnicodeSet BinaryPropertyObject::GetCodepointSet(const std::string value_spec) {
    57     int property_enum_val = Binary_ns::Y; // default value
    58     if (value_spec != "") {
     63UnicodeSet BinaryPropertyObject::GetCodepointSet(const std::string & value_spec) const {
     64    if (value_spec.length() != 0) {
    5965        auto valit = Binary_ns::aliases_only_map.find(value_spec);
    6066        if (valit == Binary_ns::aliases_only_map.end()) {
    61                     throw std::runtime_error("Binary Property " + UCD::property_full_name[the_property] +  ": bad value: " + value_spec);
     67            throw std::runtime_error("Binary Property " + UCD::property_full_name[the_property] +  ": bad value: " + value_spec);
    6268        }
    63         else property_enum_val = valit->second;
    64         if (property_enum_val == Binary_ns::Y) return the_codepoint_set;
    65         else return uset_complement(the_codepoint_set);
     69        if (valit->second == Binary_ns::Y)
     70            return the_codepoint_set;
     71        return ~the_codepoint_set;
    6672    }
    67     else return the_codepoint_set;
     73    return the_codepoint_set;
    6874}
    6975
     76UnicodeSet BinaryPropertyObject::GetCodepointSet(const int property_enum_val) const {
     77    if (property_enum_val == Binary_ns::Y)
     78        return the_codepoint_set;
     79    return ~the_codepoint_set;
     80}
    7081
    7182}
Note: See TracChangeset for help on using the changeset viewer.