00001 /******************************************************************************* 00002 00003 Copyright (C) 2007 by Brendon Costa 00004 00005 This library is free software; you can redistribute it and/or modify 00006 it under the terms of the "LGPL Like" License defined in the file COPYING 00007 that should have been distributed along with this source. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 You should have received a copy of the "LGPL Like" License 00014 along with this library; see the file COPYING. if not, it can be 00015 obtained from the EDoc++ website: 00016 http://edoc.sourceforge.net/license.html 00017 00018 *******************************************************************************/ 00019 #ifndef EDOC_FILE_H 00020 #define EDOC_FILE_H 00021 00022 #include "EDoc/StringIdentifiedObject.h" 00023 00024 #include <string> 00025 #include <ostream> 00026 #include <sstream> 00027 #include <list> 00028 00029 namespace EDoc 00030 { 00031 class PersistenceIFace; 00032 class IndexedDictionary; 00033 class Dictionary; 00034 class PStack; 00035 00036 //=========================================================================== 00037 /** \brief Represents a source file used during compilation. 00038 * 00039 * This is the simplest of the StringIdentifiedObject implementations. It 00040 * represents a source file used in compilation and as its data only contains 00041 * a string with that files name. This data type was created in order to 00042 * reduce the size of the .edc files by storing a refrenced file for location 00043 * objects etc as an integer index instead of the string with the full files 00044 * name. 00045 */ 00046 class File : public StringIdentifiedObject 00047 { 00048 public: 00049 00050 //------------------------------------------------------------------------ 00051 /** \brief See StringIdentifiedObject::(Dictionary& dict_in, 00052 * std::string key_name_in, bool populated_in=false) 00053 */ 00054 File(Dictionary& dict_in, std::string key_name_in); 00055 00056 //------------------------------------------------------------------------ 00057 /** \brief See StringIdentifiedObject(Dictionary& dict_in, 00058 * int32_t index_in, bool populated_in=false) 00059 */ 00060 File(Dictionary& dict_in, int32_t index_in); 00061 00062 //------------------------------------------------------------------------ 00063 /** \brief Copies data from another object into this one. 00064 * 00065 * This can be used across different dictionaries and will only copy 00066 * object data but not identification information used in the 00067 * StringIdentifiedObject such as the key name. 00068 */ 00069 File& operator=(const File& right); 00070 00071 00072 00073 00074 //------------------------------------------------------------------------ 00075 /** \brief See StringIdentifiedObject::Read() 00076 */ 00077 void Read(PersistenceIFace& file, IndexedDictionary& idict); 00078 00079 //------------------------------------------------------------------------ 00080 /** \brief See StringIdentifiedObject::Write() 00081 */ 00082 void Write(PersistenceIFace& file) const; 00083 00084 //------------------------------------------------------------------------ 00085 /** \brief See StringIdentifiedObject::Merge() 00086 * 00087 * Merge will fail if the file names are not the same. 00088 */ 00089 virtual void Merge(const StringIdentifiedObject& right); 00090 00091 //------------------------------------------------------------------------ 00092 /** \brief See DictionarySpecific::ReplaceReferences() 00093 */ 00094 virtual size_t ReplaceReferences(PStack& stack, 00095 void* remove, void* replace); 00096 00097 //------------------------------------------------------------------------ 00098 /** \brief See DictionarySpecific::Print() 00099 */ 00100 virtual std::ostream& Print(std::ostream& out, 00101 std::string prefix="") const; 00102 00103 //------------------------------------------------------------------------ 00104 /** \brief See DictionarySpecific::Validate() 00105 */ 00106 virtual void Validate(PStack& stack, const Dictionary& dict_in) const; 00107 00108 //------------------------------------------------------------------------ 00109 /** \brief See StringIdentifiedObject::GetRecordType() 00110 */ 00111 virtual uint8_t GetRecordType() const; 00112 00113 //------------------------------------------------------------------------ 00114 /** \brief Returns the file name for the source file this represents. 00115 */ 00116 inline std::string GetName() const 00117 { 00118 return name; 00119 } 00120 00121 //------------------------------------------------------------------------ 00122 00123 00124 00125 00126 // @@@Brendon Seems a bit silly having GetName() and a public data 00127 // attribute. Trying to be consistent with other objects where the data is 00128 // public 00129 //------------------------------------------------------------------------ 00130 /** \brief Name of source file this object represents. 00131 */ 00132 std::string name; 00133 00134 //------------------------------------------------------------------------ 00135 00136 }; 00137 //=========================================================================== 00138 typedef std::list<File*> FilePList; 00139 00140 //--------------------------------------------------------------------------- 00141 } 00142 00143 #endif // EDOC_FILE_H