#pragma once int ChangeReturnCodeImpl(char *buffer); class IncludedFilesRelation { std::vector filePaths; std::vector lineFileNumbers; // XMLシリアライズ用 private: friend class boost::serialization::access; template void serialize(Archive& ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP( filePaths ); ar & BOOST_SERIALIZATION_NVP( lineFileNumbers ); } public: IncludedFilesRelation() { } IncludedFilesRelation(IncludedFilesRelation const& y) : filePaths(y.filePaths) , lineFileNumbers(y.lineFileNumbers) { } IncludedFilesRelation(IncludedFilesRelation&& y) : filePaths(std::move(y.filePaths)) , lineFileNumbers(std::move(y.lineFileNumbers)) { } ~IncludedFilesRelation() { } IncludedFilesRelation& operator =(IncludedFilesRelation&& y) { filePaths = std::move(y.filePaths); lineFileNumbers = std::move(y.lineFileNumbers); return *this; } IncludedFilesRelation& operator =(IncludedFilesRelation const& y) { return *this = std::move(IncludedFilesRelation(y)); } const int GetFileNumber( int lineNumber ) const { return lineFileNumbers[lineNumber]; } const std::string &GetFilePath( int lineNumber ) const { return filePaths[GetFileNumber( lineNumber )]; } const std::string &GetFilePathFromFileNumber( int fileNumber ) const { return filePaths[fileNumber]; } int GetFileCounts() const { return (int)filePaths.size(); } int AddFile( const std::string &filePath ) { filePaths.push_back( filePath ); return (int)filePaths.size()-1; } void AddLine( int fileNumber ) { lineFileNumbers.push_back( fileNumber ); } int GetLineCounts() const { return (int)lineFileNumbers.size(); } }; class Text{ protected: char *buffer; int length; public: Text(){ buffer = (char *)calloc( 1, 1 ); length = 0; } Text( const Text &text ) : length( text.length ) { buffer = (char *)malloc( length + 1 ); memcpy( buffer, text.buffer, length ); buffer[length] = 0; } Text(Text&& text) : length( text.length ) { buffer = text.buffer; text.buffer = static_cast(calloc(1, 1)); text.length = 0; } Text& operator =(Text&& y) { SwapImpl(*this, y); return *this; } Text& operator =(Text const& y) { return *this = std::move(Text(y)); } ~Text(){ free( buffer ); } void Clear() { length = 0; } void Add( const std::string &str ) { buffer = (char *)realloc( buffer, length + str.size() + 1 ); strcpy( buffer + length, str.c_str() ); length += (int)str.size(); } void Add( const std::vector &str ) { buffer = (char *)realloc( buffer, length + str.size() + 1 ); strcpy( buffer + length, &str[0] ); length += (int)str.size(); } bool ReadFile( const std::string &filePath ); static void SlideString(char *buffer, int slide){ memmove(buffer+slide, buffer, strlen(buffer)+1); } protected: static void SwapImpl(Text& lhs, Text& rhs) { std::swap(lhs.buffer, rhs.buffer); std::swap(lhs.length, rhs.length); } }; class BasicSource : public Text { static const std::string generateDirectiveName; IncludedFilesRelation includedFilesRelation; // XMLシリアライズ用 private: friend class boost::serialization::access; BOOST_SERIALIZATION_SPLIT_MEMBER(); template void load(Archive& ar, const unsigned int version) { std::string _buffer; ar & BOOST_SERIALIZATION_NVP( _buffer ); ar & BOOST_SERIALIZATION_NVP( length ); ar & BOOST_SERIALIZATION_NVP( includedFilesRelation ); // 読み込み後の処理 Realloc( length ); for( int i=0; i= 'a' ) ? ( _buffer[i*3] - 'a' + 0x0a ) : ( _buffer[i*3] - '0' ) ) * 0x10; ULONG_PTR l2 = ( _buffer[i*3+1] >= 'a' ) ? ( _buffer[i*3+1] - 'a' + 0x0a ) : ( _buffer[i*3+1] - '0' ); ULONG_PTR l = l1 + l2; buffer[i] = static_cast(l); } buffer[length] = 0; } template void save(Archive& ar, const unsigned int version) const { // 保存準備 char *tempCode = (char *)calloc( (length+1) * 3, 1 ); for( int i=0; i(strlen( buffer )); } // 指定したインデックスが何行目かを取得 bool GetLineFromIndex( int index, int &result ) const; const IncludedFilesRelation &GetIncludedFilesRelation() const { return includedFilesRelation; } void SetBuffer( const char *buffer ); bool ReadFile( const std::string &filePath, bool isDebug, bool isDll, bool isUnicode, int majorVer, const std::string &mainSourceFilePath, const std::string &includeDirPath ); void Addition( const char *buffer ); bool GetLineInfo( int sourceCodePos, int &line, std::string &fileName ) const; BasicSource& operator =(const BasicSource &source) { Realloc( source.length ); strcpy( buffer, source.buffer ); return *this; } BasicSource& operator =(BasicSource&& source) { Text::SwapImpl(*this, source); return *this; } char operator[]( int index ) const { if( index>GetLength() ) { Jenga::Throw( "BasicSource bad access" ); } return buffer[2+index]; } std::string cannotIncludePath; int cannotIncludeSourcePos; }; class BasicSources : public std::vector , public Jenga::Common::BoostSerializationSupport { // XMLシリアライズ用 private: virtual const char *RootTagName() const { return "basicSources"; } friend class boost::serialization::access; template void serialize(Archive& ar, const unsigned int version) { ar & boost::serialization::make_nvp("vector_BasicSource", boost::serialization::base_object>(*this)); } public: BasicSources() {} BasicSources(BasicSources&& y) : std::vector(std::move(y)) {} BasicSources(BasicSources const& y) : std::vector(y) {} BasicSources operator =(BasicSources&& y) { std::vector::operator =(std::move(y)); return *this; } BasicSources operator =(BasicSources const& y) { return *this = std::move(BasicSources(y)); } }; class SourceCodePosition { int relationalObjectModuleIndex; int pos; // XMLシリアライズ用 private: friend class boost::serialization::access; template void serialize(Archive& ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP( relationalObjectModuleIndex ); ar & BOOST_SERIALIZATION_NVP( pos ); } public: SourceCodePosition( int relationalObjectModuleIndex, int pos ) : relationalObjectModuleIndex( relationalObjectModuleIndex ) , pos( pos ) { } SourceCodePosition() : relationalObjectModuleIndex( -1 ) , pos( -1 ) { } SourceCodePosition(SourceCodePosition const& y) : relationalObjectModuleIndex(y.relationalObjectModuleIndex) , pos(y.pos) { } SourceCodePosition& operator =(SourceCodePosition const& y) { relationalObjectModuleIndex = y.relationalObjectModuleIndex; pos = y.pos; return *this; } int GetRelationalObjectModuleIndex() const; void SetRelationalObjectModuleIndex( int relationalObjectModuleIndex ) { this->relationalObjectModuleIndex = relationalObjectModuleIndex; } int GetPos() const { return pos; } void SetPos( int pos ) { this->pos = pos; } bool IsNothing() const; };