Пример #1
0
const decimal_field_instruction *
decimal_field_instruction::default_instruction() {
  static const decimal_field_instruction inst(operator_none, presence_mandatory,
                                              0, "", "", nullptr,
                                              decimal_value_storage());
  return &inst;
}
Пример #2
0
field_op::field_op(const decimal_field_instruction *inst,
                   const XMLElement *element, arena_allocator &alloc)
    : op_(inst->field_operator()), context_(inst->op_context()),
      initial_value_(inst->initial_value()), alloc_(&alloc) {
  if (element) {
    const XMLElement *field_op_element = find_field_op_element(*element);
    if (field_op_element) {
      parse_field_op(*field_op_element, alloc);
      const char *init_value_str =
          get_optional_attr(*field_op_element, "value", nullptr);

      if (init_value_str) {
        if (strcmp(element->Name(), "exponent") != 0)
          initial_value_.set(boost::lexical_cast<int64_t>(init_value_str));
        else {
          short exp = 128;
          try {
            exp = boost::lexical_cast<short>(init_value_str);
          } catch (...) {
          }

          if (exp > 63 || exp < -63) {
            BOOST_THROW_EXCEPTION(
                fast_dynamic_error("D11")
                << reason_info(std::string("Invalid exponent initial value: ") +
                               init_value_str));
          }
          initial_value_ =
              decimal_value_storage(0, static_cast<uint16_t>(exp)).storage_;
        }
      }
    }
  }
}