Field Regnal::get_jdn( const Field* fields ) const { FieldVec fs = get_base_fields( fields ); if( fs.size() == 0 ) { return f_invalid; } return m_eras[fields[0]].base->get_jdn( &fs[0] ); }
void DocumentGenerator::setup() { typedef FieldVec::const_iterator FI; for (FI i(_fields.begin()), ie(_fields.end()); i != ie; ++i) { (*i)->setup(); } }
bool Regnal::set_fields_as_next_last( Field* fields, const Field* mask ) const { Field e = mask[0]; if( e < 0 || e >= (int) m_eras.size() ) { return false; } if( mask[1] == f_invalid ) { return false; } FieldVec m = get_base_fields( mask ); FieldVec f = get_base_fields( fields ); Record rec( m_eras[e].base, &f[0], f.size() ); if( rec.set_fields_as_next_last( &m[0] ) ) { if( rec.get_jdn() > m_eras[e].end ) { return false; } return make_regnal_fields( fields, e, rec ); } return false; }
void data_test_2(T& foo) { typedef std::vector<typename T::enum_type> FieldVec; FieldVec fields; fields.push_back(example::SHOE_PRICE); fields.push_back(example::GUM_PRICE); fields.push_back(example::CAR_PRICE); for(typename FieldVec::iterator i = fields.begin(); i != fields.end(); ++i) { visitor bar; foo.get_runtime_member(bar, *i); } TEST_ASSERT(val_print::o.str() == "example::SHOE_PRICE 23.2 example::GUM_PRICE 3 example::CAR_PRICE 20 "); val_print::o.str(""); // Separately test with a temporary to make sure that it works // with the type inference. for(typename FieldVec::iterator i = fields.begin(); i != fields.end(); ++i) { foo.get_runtime_member(visitor(), *i); } TEST_ASSERT(val_print::o.str() == "example::SHOE_PRICE 23.2 example::GUM_PRICE 3 example::CAR_PRICE 20 "); val_print::o.str(""); }
void XMLExtServiceHelper::appendExternalSearchDesc( DOMNode* out, DOMDocument* reply, DOMNode* cur, const MC2String& crcIn, const LangType& lang, int indentLevel, bool indent ) { DOMElement* ext_service_list = reply->createElement( X( "ext_services_reply" ) ); out->appendChild( ext_service_list ); DOMNode* transaction_id = cur->getAttributes()->getNamedItem( X("transaction_id") ); // Transaction id should always be there when dtd is on. if ( transaction_id ) { ext_service_list->setAttribute( transaction_id->getNodeName(), transaction_id->getNodeValue() ); } // FIXEME: Move the transacion id // Add CRC bool crcOK = false; { MC2String intCrc = m_thread->getSearchHandler().getSearchHitTypesCRC(lang); ext_service_list->setAttribute( X("crc"), X( intCrc.c_str() ) ); if ( crcIn == intCrc ) { ext_service_list->appendChild( reply->createElement( X( "ext_services_crc_ok" ) ) ); crcOK = true; } } bool newClient; XMLTool::getAttrib<bool>( newClient, "new_client", cur, false ); CompactSearchHitTypeVector availableProviders; CompactSearchHitTypeVector headings = m_thread->getSearchHandler().getSearchHitTypes(lang, newClient); for ( CompactSearchHitTypeVector::iterator it = headings.begin(); it != headings.end(); it++ ) { if( it->m_round == 1 ) { availableProviders.push_back( *it ); } } ext_service_list->setAttribute( X("nbr_services" ), XInt32( availableProviders.size() ) ); if ( crcOK ) { // Now indent if necessary. if ( indent ) { XMLUtility::indentPiece( *ext_service_list, indentLevel ); } return; } for ( CompactSearchHitTypeVector::const_iterator it = availableProviders.begin(); it != availableProviders.end(); ++it ) { // Create ext_service element for each service. DOMElement* ext_service = reply->createElement( X("ext_service" ) ); ext_service_list->appendChild( ext_service ); ext_service->setAttribute( X("type"), X("search") ); DOMElement* name = reply->createElement( X("name") ); ext_service->appendChild( name ); name->appendChild( reply->createTextNode( X( it->m_name ) ) ); ext_service->setAttribute( X("service_id"), XInt32( it->m_serviceID ) ); // Add the background colour as an attribute ext_service->setAttribute( X("background_colour"), XHex32( getColour( it->m_serviceID ) ) ); // Add the help text - currently empty. ext_service->appendChild( reply->createElement( X("ext_service_help" ) ) ); // Add the icons. DOMElement* icons_el = reply->createElement( X( "icons" ) ); uint32 nbrIcons = 0; ext_service->appendChild( icons_el ); // if we dont have any icons we need to add two empty since the client // side cant seem to handle xml correctly if ( ! newClient && nbrIcons < 2 ) { using namespace XMLTool; for ( uint32 i = 0; i < 2 - nbrIcons; ++i ) { DOMElement* icon = addNode( icons_el, "icon" ); addAttrib( icon, "name", MC2String("") ); addAttrib( icon, "xsize", (uint32)0 ); addAttrib( icon, "ysize", (uint32)0 ); addAttrib( icon, "client_type", MC2String("mywf") ); ++nbrIcons; } } XMLTool::addAttrib( icons_el, "nbr_icons", nbrIcons ); FieldVec fields; // country is always required fields.push_back( SearchField( ExternalSearchHelper::getFieldName( ExternalSearchConsts:: country, lang ), ExternalSearchConsts::country, "choice", 0x1 ) ); if ( it->m_providerType == CompactSearchHitType::yellow_pages ) { // Search fields for providers of yellow pages type fields.push_back( SearchField( ExternalSearchHelper::getFieldName( ExternalSearchConsts:: company_or_search_word, lang ), ExternalSearchConsts::company_or_search_word, "string",0x1 ) ); fields.push_back( SearchField( ExternalSearchHelper::getFieldName( ExternalSearchConsts:: city_or_area, lang ), ExternalSearchConsts::city_or_area, "string", 0 ) ); fields.push_back( SearchField( ExternalSearchHelper::getFieldName( ExternalSearchConsts:: category, lang ), ExternalSearchConsts::category, "string", 0 ) ); } else if ( it->m_providerType == CompactSearchHitType::white_pages ) { // Search fields for providers of white pages type fields.push_back( SearchField( ExternalSearchHelper::getFieldName( ExternalSearchConsts:: name_or_phone, lang ), ExternalSearchConsts::name_or_phone, "string",0x1 ) ); fields.push_back( SearchField( ExternalSearchHelper::getFieldName( ExternalSearchConsts:: address_or_city, lang ), ExternalSearchConsts::address_or_city, "string", 0 ) ); } for ( FieldVec::iterator it2 = fields.begin(); it2 != fields.end(); ++it2 ) { DOMElement* field = reply->createElement( X("field") ); ext_service->appendChild( field ); DOMElement* field_name = reply->createElement( X("field_name") ); field->appendChild( field_name ); field_name->appendChild( reply->createTextNode( X( it2->m_name ) ) ); char tmp_str[128]; sprintf( tmp_str, "%u", it2->m_id ); field->setAttribute( X("id"), X( tmp_str) ); sprintf( tmp_str, "%X", it2->m_required ); field->setAttribute( X("req"), X( tmp_str ) ); field->setAttribute( X("type" ), X( it2->m_type ) ); if ( it2->m_id == 1 ) { // Country is choice field. Add the country as choice field->setAttribute( X("nbr_choices"), X( "1" ) ); StringTable::countryCode country = ExternalSearchHelper::topRegionToCountryCode( it->m_topRegionID, lang ); DOMElement* field_option = reply->createElement( X("field_option") ); field->appendChild( field_option ); sprintf( tmp_str, "%u", country ); field_option->setAttribute( X("id"), X(tmp_str) ); DOMElement* field_option_name = reply->createElement( X("field_option_name" ) ); field_option->appendChild( field_option_name ); MC2String strCountry = StringUtility::makeFirstCapital( StringTable::getString( StringTable::getCountryStringCode(country), lang) ) ; field_option_name->appendChild( reply->createTextNode( X( strCountry ) ) ); } } } // for all descs // Now indent if necessary. if ( indent ) { XMLUtility::indentPiece( *ext_service_list, indentLevel ); } }