00001 /* 00002 * UAP Model Builder 00003 * Universal Accelerator Parser 00004 * Copyright (C) 2005 Andy Wolski, Daniel Bates, David Sagan 00005 * 00006 * This library is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 3 of the License, or (at 00009 * your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, but WITHOUT 00012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 00014 * for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this library; if not, write to the Free Software Foundation, Inc., 00018 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 * Direct questions, comments, etc to: 00021 * Andy Wolski <a.wolski@dl.ac.uk> 00022 * Daniel Bates <dbates@lbl.gov> 00023 * David Sagan <dcs16@cornell.edu> 00024 */ 00025 00026 #ifndef UAPBuilder_hpp 00027 #define UAPBuilder_hpp 1 00028 00029 #include <string> 00030 #include <algorithm> 00031 00032 #include "UAP/UAPNode.hpp" 00033 #include "UAP/UAPException.hpp" 00034 00035 #define ALLOW_REPEATS true 00036 00046 class UAPBuilder { 00047 00048 public: 00049 00056 UAPBuilder(UAPNode* node); 00057 00059 ~UAPBuilder(); 00060 00070 void addChild(enum UAPNode_type type, std::string name); 00071 00084 void addAttribute(std::string name, std::string value, bool allow_repeats=false); 00085 00087 void moveToParent(); 00088 00091 UAPNode* getCurrentNode(); 00092 00099 NodeVec getSubNodesByTagName(const std::string& tagName); 00100 00111 UAPNode* getChildByName(const std::string& _name); 00112 00126 UAPNode* getChildByName(UAPNode* beginPosition, const std::string& _name); 00127 00137 NodeVec getChildrenByName(const std::string& _name); 00138 00150 NodeVec getChildrenByName(UAPNode* beginPosition, const std::string& _name); 00151 00162 UAPNode* getSubNodeByName(const std::string& _name); 00163 00177 UAPNode* getSubNodeByName(UAPNode* beginPosition, const std::string& _name); 00178 00188 NodeVec getSubNodesByName(const std::string& _name); 00189 00201 NodeVec getSubNodesByName(UAPNode* beginPosition, const std::string& _name); 00202 00203 private: 00204 00206 UAPNode* root; 00207 00209 UAPNode* currentNode; 00210 00211 }; 00212 00213 #endif
1.5.7