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

Last change on this file since 261 was 205, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

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