Rev | Line | |
---|
[170] | 1 | #pragma once
|
---|
| 2 |
|
---|
| 3 | #include <vector>
|
---|
| 4 | #include <string>
|
---|
| 5 |
|
---|
| 6 | #include <windows.h>
|
---|
| 7 | #include <stdlib.h>
|
---|
| 8 |
|
---|
| 9 | #include "BasicFixed.h"
|
---|
| 10 |
|
---|
| 11 | using namespace std;
|
---|
| 12 |
|
---|
| 13 | struct INCLUDEFILEINFO{
|
---|
| 14 | char **ppFileNames;
|
---|
| 15 | int FilesNum;
|
---|
| 16 | int LineOfFile[MAX_LEN];
|
---|
| 17 | };
|
---|
| 18 |
|
---|
| 19 | class Text{
|
---|
| 20 | protected:
|
---|
| 21 | char *buffer;
|
---|
| 22 | int length;
|
---|
| 23 |
|
---|
| 24 | public:
|
---|
| 25 |
|
---|
| 26 | Text(){
|
---|
| 27 | buffer = (char *)calloc( 1, 1 );
|
---|
| 28 | length = 0;
|
---|
| 29 | }
|
---|
| 30 | ~Text(){
|
---|
| 31 | free( buffer );
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | bool ReadFile( const string &filePath );
|
---|
| 35 |
|
---|
| 36 | static void Text::SlideString(char *buffer, int slide){
|
---|
| 37 | char *temp;
|
---|
| 38 | temp=(char *)malloc(lstrlen(buffer)+1);
|
---|
| 39 | lstrcpy(temp,buffer);
|
---|
| 40 | lstrcpy(buffer+slide,temp);
|
---|
| 41 | free(temp);
|
---|
| 42 | }
|
---|
| 43 | };
|
---|
| 44 |
|
---|
| 45 | class BasicSource : public Text
|
---|
| 46 | {
|
---|
| 47 | static const string generateDirectiveName;
|
---|
| 48 |
|
---|
| 49 | void Realloc( int newLength ){
|
---|
| 50 | buffer = (char *)realloc( buffer, newLength + 255 );
|
---|
| 51 |
|
---|
| 52 | length = newLength;
|
---|
| 53 |
|
---|
| 54 | extern char *basbuf;
|
---|
| 55 | basbuf = buffer + 2;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | void IncludeFiles();
|
---|
| 59 |
|
---|
| 60 | void ChangeReturnLineChar();
|
---|
| 61 |
|
---|
| 62 | void RemoveComments();
|
---|
| 63 |
|
---|
| 64 | bool ReadFile_InIncludeDirective( const string &filePath );
|
---|
| 65 | void DirectiveIncludeOrRequire();
|
---|
| 66 |
|
---|
| 67 | void RemoveReturnLineUnderbar();
|
---|
| 68 |
|
---|
| 69 | public:
|
---|
| 70 | BasicSource(){}
|
---|
| 71 | ~BasicSource(){}
|
---|
| 72 |
|
---|
| 73 | char *GetBuffer(){
|
---|
| 74 | return buffer+2;
|
---|
| 75 | }
|
---|
[173] | 76 | const char *GetBuffer() const
|
---|
| 77 | {
|
---|
| 78 | return buffer+2;
|
---|
| 79 | }
|
---|
| 80 | int GetLength() const
|
---|
| 81 | {
|
---|
[170] | 82 | return length-2;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | void SetBuffer( const char *buffer );
|
---|
| 86 |
|
---|
| 87 | bool ReadFile( const string &filePath );
|
---|
| 88 |
|
---|
| 89 | bool Generate( const string &genName, const char *buffer );
|
---|
| 90 |
|
---|
| 91 | void Addition( const char *buffer );
|
---|
| 92 |
|
---|
| 93 | void operator = ( const BasicSource &source ){
|
---|
| 94 | Realloc( source.length );
|
---|
| 95 | lstrcpy( buffer, source.buffer );
|
---|
| 96 | }
|
---|
| 97 |
|
---|
[173] | 98 | char operator[]( int index ) const
|
---|
| 99 | {
|
---|
| 100 | if( index>GetLength() )
|
---|
| 101 | {
|
---|
| 102 | throw "bad access";
|
---|
[170] | 103 | }
|
---|
[173] | 104 | return buffer[2+index];
|
---|
[170] | 105 | }
|
---|
| 106 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.