source: dev/trunk/jenga/include/smoothie/Source.h@ 197

Last change on this file since 197 was 173, checked in by dai_9181, 17 years ago
File size: 1.7 KB
Line 
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
11using namespace std;
12
13struct INCLUDEFILEINFO{
14 char **ppFileNames;
15 int FilesNum;
16 int LineOfFile[MAX_LEN];
17};
18
19class Text{
20protected:
21 char *buffer;
22 int length;
23
24public:
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
45class 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
69public:
70 BasicSource(){}
71 ~BasicSource(){}
72
73 char *GetBuffer(){
74 return buffer+2;
75 }
76 const char *GetBuffer() const
77 {
78 return buffer+2;
79 }
80 int GetLength() const
81 {
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
98 char operator[]( int index ) const
99 {
100 if( index>GetLength() )
101 {
102 throw "bad access";
103 }
104 return buffer[2+index];
105 }
106};
Note: See TracBrowser for help on using the repository browser.