#pragma once #include #include #include #include #include #include #include using namespace std; struct INCLUDEFILEINFO{ char **ppFileNames; int FilesNum; int LineOfFile[MAX_LEN]; }; class Text{ protected: char *buffer; int length; public: Text(){ buffer = (char *)calloc( 1, 1 ); length = 0; } ~Text(){ free( buffer ); } void Clear() { length = 0; } void Add( const std::string &str ) { buffer = (char *)realloc( buffer, length + str.size() + 1 ); lstrcpy( buffer + length, str.c_str() ); length += (int)str.size(); } void Add( const std::vector &str ) { buffer = (char *)realloc( buffer, length + str.size() + 1 ); lstrcpy( buffer + length, &str[0] ); length += (int)str.size(); } bool ReadFile( const string &filePath ); static void Text::SlideString(char *buffer, int slide){ char *temp; temp=(char *)malloc(lstrlen(buffer)+1); lstrcpy(temp,buffer); lstrcpy(buffer+slide,temp); free(temp); } }; class BasicSource : public Text { static const string generateDirectiveName; void Realloc( int newLength ){ buffer = (char *)realloc( buffer, newLength + 255 ); length = newLength; extern char *basbuf; basbuf = buffer + 2; } void IncludeFiles(); void ChangeReturnLineChar(); void RemoveComments(); bool ReadFile_InIncludeDirective( const string &filePath ); void DirectiveIncludeOrRequire(); void RemoveReturnLineUnderbar(); public: BasicSource(){} ~BasicSource(){} char *GetBuffer(){ return buffer+2; } const char *GetBuffer() const { return buffer+2; } int GetLength() const { return length-2; } void SetBuffer( const char *buffer ); bool ReadFile( const string &filePath ); bool Generate( const string &genName, const char *buffer ); void Addition( const char *buffer ); void operator = ( const BasicSource &source ){ Realloc( source.length ); lstrcpy( buffer, source.buffer ); } char operator[]( int index ) const { if( index>GetLength() ) { Jenga::Throw( "BasicSource bad access" ); } return buffer[2+index]; } };