1 // XLIFFParser.hxx -- parse an XLIFF 1.2 XML file 2 //// 3 // Copyright (C) 2018 James Turner <james@flightgear.org> 4 // 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License as 7 // published by the Free Software Foundation; either version 2 of the 8 // License, or (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, but 11 // WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 // General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 19 #include <simgear/xml/easyxml.hxx> 20 21 #include <string> 22 23 #include <simgear/props/propsfwd.hxx> 24 25 namespace flightgear 26 { 27 28 class XLIFFParser : public XMLVisitor 29 { 30 public: 31 XLIFFParser(SGPropertyNode_ptr lroot); 32 33 protected: 34 void startXML () override; 35 void endXML () override; 36 void startElement (const char * name, const XMLAttributes &atts) override; 37 void endElement (const char * name) override; 38 void data (const char * s, int len) override; 39 void pi (const char * target, const char * data) override; 40 void warning (const char * message, int line, int column) override; 41 42 private: 43 void finishTransUnit(); 44 45 SGPropertyNode_ptr _localeRoot; 46 SGPropertyNode_ptr _resourceNode; 47 48 std::string _text; 49 std::string _unitId, _resource; 50 std::string _source, _target; 51 bool _approved = false; 52 }; 53 54 } 55