1 /* 2 Copyright (C) 2010-2014 Kristian Duske 3 4 This file is part of TrenchBroom. 5 6 TrenchBroom is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 TrenchBroom is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef TrenchBroom_MapStreamSerializer 21 #define TrenchBroom_MapStreamSerializer 22 23 #include "IO/NodeSerializer.h" 24 #include "Model/MapFormat.h" 25 26 #include <iostream> 27 28 namespace TrenchBroom { 29 namespace IO { 30 class MapStreamSerializer : public NodeSerializer { 31 private: 32 std::ostream& m_stream; 33 public: 34 static Ptr create(Model::MapFormat::Type format, std::ostream& stream); 35 protected: 36 MapStreamSerializer(std::ostream& stream); 37 public: 38 virtual ~MapStreamSerializer(); 39 private: 40 void doBeginEntity(const Model::Node* node); 41 void doEndEntity(Model::Node* node); 42 void doEntityAttribute(const Model::EntityAttribute& attribute); 43 void doBeginBrush(const Model::Brush* brush); 44 void doEndBrush(Model::Brush* brush); 45 void doBrushFace(Model::BrushFace* face); 46 private: 47 virtual void doWriteBrushFace(std::ostream& stream, Model::BrushFace* face) = 0; 48 }; 49 } 50 } 51 52 #endif /* defined(TrenchBroom_MapStreamSerializer) */ 53