Goby Underwater Autonomy Project
Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
|
00001 // copyright 2009 t. schneider tes@mit.edu 00002 // 00003 // this file is part of the Queue Library (libqueue), 00004 // the goby-acomms message queue manager. goby-acomms is a collection of 00005 // libraries for acoustic underwater networking 00006 // 00007 // This program is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // This software is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this software. If not, see <http://www.gnu.org/licenses/>. 00019 00020 #include "queue_xml_callbacks.h" 00021 00022 using namespace xercesc; 00023 using namespace goby::acomms::xml; 00024 00025 // this is called when the parser encounters the start tag, e.g. <message> 00026 void goby::acomms::QueueContentHandler::startElement( 00027 const XMLCh *const uri, // namespace URI 00028 const XMLCh *const localname, // tagname w/ out NS prefix 00029 const XMLCh *const qname, // tagname + NS pefix 00030 const Attributes &attrs ) // elements's attributes 00031 { 00032 //const XMLCh* val; 00033 Tag current_tag = tags_map_[toNative(localname)]; 00034 parents_.insert(current_tag); 00035 00036 switch(current_tag) 00037 { 00038 default: 00039 break; 00040 00041 case tag_message: 00042 q_.push_back(protobuf::QueueConfig()); 00043 q_.back().mutable_key()->set_type(protobuf::QUEUE_DCCL); 00044 break; 00045 } 00046 00047 current_text.clear(); 00048 } 00049 00050 void goby::acomms::QueueContentHandler::endElement( 00051 const XMLCh *const uri, // namespace URI 00052 const XMLCh *const localname, // tagname w/ out NS prefix 00053 const XMLCh *const qname ) // tagname + NS pefix 00054 { 00055 std::string trimmed_data = boost::trim_copy(current_text); 00056 00057 Tag current_tag = tags_map_[toNative(localname)]; 00058 parents_.erase(current_tag); 00059 00060 using goby::util::as; 00061 using google::protobuf::uint32; 00062 00063 switch(current_tag) 00064 { 00065 default: 00066 break; 00067 00068 case tag_ack: 00069 q_.back().set_ack(as<bool>(trimmed_data)); 00070 break; 00071 00072 case tag_blackout_time: 00073 q_.back().set_blackout_time(as<uint32>(trimmed_data)); 00074 break; 00075 00076 case tag_max_queue: 00077 q_.back().set_max_queue(as<uint32>(trimmed_data)); 00078 break; 00079 00080 case tag_newest_first: 00081 q_.back().set_newest_first(as<bool>(trimmed_data)); 00082 break; 00083 00084 case tag_id: 00085 q_.back().mutable_key()->set_id(as<uint32>(trimmed_data)); 00086 break; 00087 00088 case tag_priority_base: 00089 case tag_priority_time_const: 00090 // deprecated 00091 break; 00092 00093 case tag_name: 00094 if(!in_message_var() && !in_header_var()) 00095 q_.back().set_name(trimmed_data); 00096 break; 00097 00098 00099 case tag_ttl: 00100 q_.back().set_ttl(as<uint32>(trimmed_data)); 00101 break; 00102 00103 00104 case tag_value_base: 00105 q_.back().set_value_base(as<double>(trimmed_data)); 00106 break; 00107 00108 } 00109 }