1 /******************************************************************************* 2 * Project: libopencad 3 * Purpose: OpenSource CAD formats support library 4 * Author: Alexandr Borzykh, mush3d at gmail.com 5 * Author: Dmitry Baryshnikov, bishop.dev@gmail.com 6 * Language: C++ 7 ******************************************************************************* 8 * The MIT License (MIT) 9 * 10 * Copyright (c) 2016 Alexandr Borzykh 11 * Copyright (c) 2016 NextGIS, <info@nextgis.com> 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining a copy 14 * of this software and associated documentation files (the "Software"), to deal 15 * in the Software without restriction, including without limitation the rights 16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 * copies of the Software, and to permit persons to whom the Software is 18 * furnished to do so, subject to the following conditions: 19 * 20 * The above copyright notice and this permission notice shall be included in all 21 * copies or substantial portions of the Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * SOFTWARE. 30 *******************************************************************************/ 31 #ifndef CADDICTIONARY_H 32 #define CADDICTIONARY_H 33 34 #include "cadobjects.h" 35 #include <memory> 36 37 /* 38 * @brief Base-class for XRecord and Dictionary. 39 */ 40 class OCAD_EXTERN CADDictionaryRecord 41 { 42 public: 43 CADDictionaryRecord(); ~CADDictionaryRecord()44 virtual ~CADDictionaryRecord(){} 45 46 CADObject::ObjectType getType() const; 47 48 protected: 49 CADObject::ObjectType objType; 50 }; 51 52 /* 53 * @brief Class which implements XRecord 54 */ 55 class OCAD_EXTERN CADXRecord : public CADDictionaryRecord 56 { 57 public: 58 CADXRecord(); ~CADXRecord()59 virtual ~CADXRecord(){} 60 61 const std::string getRecordData() const; 62 void setRecordData( const std::string& data ); 63 64 private: 65 std::string sRecordData; 66 }; 67 68 /* 69 * @brief Class which implements Dictionary 70 */ 71 typedef std::pair< std::string, std::shared_ptr<CADDictionaryRecord>> CADDictionaryItem; 72 class OCAD_EXTERN CADDictionary : public CADDictionaryRecord 73 { 74 public: 75 CADDictionary(); 76 virtual ~CADDictionary(); 77 78 size_t getRecordsCount(); 79 void addRecord( CADDictionaryItem ); 80 CADDictionaryItem getRecord( size_t index ); 81 std::string getRecordByName(const std::string& name) const; 82 private: 83 std::vector< CADDictionaryItem > astXRecords; 84 }; 85 86 #endif // CADDICTIONARY_H 87