// ------------------------------------------------------------------ // ciTypeArray::char_at // // Implementation of the char_at method. jchar ciTypeArray::char_at(int index) { VM_ENTRY_MARK; assert(index >= 0 && index < length(), "out of range"); jchar c = get_typeArrayOop()->char_at(index); #ifdef ASSERT jchar d = element_value(index).as_char(); assert(c == d, ""); #endif //ASSERT return c; }
/* Parse cell attributes */ static vector<McObject*> aceAttrib(TiXmlElement* pElement) { /* Initialize XML attribute checker */ static const string required[4] = {"id","density","units","fraction"}; static XmlParser::XmlAttributes matAttrib(vector<string>(required, required + 4), vector<string>()); /* Check flags */ XmlParser::AttributeValue<string> units_flag("units","",initUnits()); XmlParser::AttributeValue<string> fraction_flag("fraction","",initFraction()); XmlParser::AttribMap mapAttrib = dump_attribs(pElement); /* Check user input */ matAttrib.checkAttributes(mapAttrib, "material"); /* Get attributes */ MaterialId id = fromString<MaterialId>(mapAttrib["id"]); double density = fromString<double>(mapAttrib["density"]); std::string units = units_flag.getValue(mapAttrib); std::string fraction = fraction_flag.getValue(mapAttrib); /* Push all the ACE objects (including the isotopes) */ vector<McObject*> ace_objects; /* Get isotopes */ TiXmlElement* pChild; map<string,double> isotopes; for (pChild = pElement->FirstChildElement(); pChild != 0; pChild = pChild->NextSiblingElement()) { string element_value(pChild->Value()); pair<string,double> pair_value = isoAttrib(pChild); string isotope = pair_value.first; /* Check if the user is not duplicating the isotope name */ map<string,double>::iterator it = isotopes.find(isotope); if(it == isotopes.end()) { /* Push isotope */ isotopes.insert(pair_value); ace_objects.push_back(new AceObject(pair_value.first)); } else { /* Duplicated name of isotope */ std::vector<std::string> keywords; XmlParser::AttribMap::const_iterator it_att = mapAttrib.begin(); for(; it_att != mapAttrib.end() ; ++it_att) { keywords.push_back((*it_att).first); keywords.push_back((*it_att).second); } throw Parser::KeywordParserError("Duplicated isotope with name " + isotope,keywords); } } /* Return surface definition */ ace_objects.push_back(new AceMaterialObject(id, density, units, fraction, isotopes)); return ace_objects; }
void XmlParser::srcNode(TiXmlNode* pParent) { TiXmlNode* pChild; for (pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) { int t = pChild->Type(); if (t == TiXmlNode::ELEMENT) { string element_value(pChild->Value()); if (element_value == "dist") objects.push_back(distAttrib(pChild->ToElement())); else if (element_value == "sampler") objects.push_back(samplerAttrib(pChild->ToElement())); else if (element_value == "source") objects.push_back(sourceAttrib(pChild->ToElement())); else { vector<string> keywords; keywords.push_back(element_value); throw KeywordParserError("Unrecognized source keyword <" + element_value + ">",keywords); } } } }
void XmlParser::matNode(TiXmlNode* pParent) { TiXmlNode* pChild; for (pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) { int t = pChild->Type(); if (t == TiXmlNode::ELEMENT) { string element_value(pChild->Value()); if (element_value == "macro-xs") objects.push_back(macroAttrib(pChild->ToElement())); else if (element_value == "material") { vector<McObject*> ace_objects = aceAttrib(pChild->ToElement()); objects.insert(objects.end(), ace_objects.begin(), ace_objects.end()); } else { vector<string> keywords; keywords.push_back(element_value); throw KeywordParserError("Unrecognized material keyword <" + element_value + ">",keywords); } } } }