50 return (value >= 0 && static_cast<unsigned long long>(value) <=
DODS_UCHAR_MAX);
54 return (value >= 0 && static_cast<unsigned long long>(value) <=
DODS_USHRT_MAX);
58 return (value >= 0 && static_cast<unsigned long long>(value) <=
DODS_UINT_MAX);
62 return (value >= 0 && static_cast<unsigned long long>(value) <=
DODS_ULLONG_MAX);
71 enum_def_name_eq(
D4EnumDef *d,
const string name)
73 return d->
name() == name;
79 D4EnumDefIter d = find_if(d_enums.begin(), d_enums.end(), bind2nd(ptr_fun(enum_def_name_eq), name));
80 return (d != d_enums.end()) ? *d: 0;
83 void D4EnumDef::print_value(
XMLWriter &xml,
const D4EnumDef::tuple &tuple)
const
85 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar*)
"EnumConst") < 0)
86 throw InternalErr(__FILE__, __LINE__,
"Could not write EnumConst element");
88 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)tuple.label.c_str()) < 0)
89 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
93 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"value", (
const xmlChar*)oss.str().c_str()) < 0)
94 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for value");
96 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
97 throw InternalErr(__FILE__, __LINE__,
"Could not end EnumConst element");
102 vector<D4EnumDef::tuple>::const_iterator i = d_tuples.begin();
103 while(i != d_tuples.end()) {
104 print_value(xml, *i++);
110 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar*)
"Enumeration") < 0)
111 throw InternalErr(__FILE__, __LINE__,
"Could not write Enumeration element");
113 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)e->
name().c_str()) < 0)
114 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
116 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"basetype", (
const xmlChar*)
D4type_name(e->
type()).c_str()) < 0)
117 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
122 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
123 throw InternalErr(__FILE__, __LINE__,
"Could not end Enumeration element");
129 while (i != d_enums.end()) {
131 m_print_enum(xml, *i);
bool is_valid_enum_value(long long value)
xmlTextWriterPtr get_writer()
BaseType * find_first_var_that_uses_enumeration(D4EnumDef *enum_def)
D4EnumDef * find_enum_def(const string &name)
A class for software fault reporting.
vector< D4EnumDef * >::const_iterator D4EnumDefCIter
string D4type_name(Type t)
Returns the type of the class instance as a string. Supports all DAP4 types and not the DAP2-only typ...
vector< D4EnumDef * >::iterator D4EnumDefIter
void print_dap4(XMLWriter &xml, bool constrained=false) const
void print_dap4(XMLWriter &xml) const