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

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

ベースを作成中...

File size: 2.6 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 bool IsBlank( char c )
37 {
38 if( c == ' ' || c == '\t' )
39 {
40 return true;
41 }
42 return false;
43 }
44 static void Text::SlideString(char *buffer, int slide){
45 char *temp;
46 temp=(char *)malloc(lstrlen(buffer)+1);
47 lstrcpy(temp,buffer);
48 lstrcpy(buffer+slide,temp);
49 free(temp);
50 }
51};
52
53class BasicSource : public Text
54{
55 static const string generateDirectiveName;
56
57 void Realloc( int newLength ){
58 buffer = (char *)realloc( buffer, newLength + 255 );
59
60 length = newLength;
61
62 extern char *basbuf;
63 basbuf = buffer + 2;
64 }
65
66 void IncludeFiles();
67
68 void ChangeReturnLineChar();
69
70 void RemoveComments();
71
72 bool ReadFile_InIncludeDirective( const string &filePath );
73 void DirectiveIncludeOrRequire();
74
75 void RemoveReturnLineUnderbar();
76
77public:
78 BasicSource(){}
79 ~BasicSource(){}
80
81 char *GetBuffer(){
82 return buffer+2;
83 }
84 int GetLength(){
85 return length-2;
86 }
87
88 void SetBuffer( const char *buffer );
89
90 bool ReadFile( const string &filePath );
91
92 bool Generate( const string &genName, const char *buffer );
93
94 void Addition( const char *buffer );
95
96 void operator = ( const BasicSource &source ){
97 Realloc( source.length );
98 lstrcpy( buffer, source.buffer );
99 }
100
101 static bool IsCommandDelimitation( char c ){
102 if( c == '\n' || c == ':' || c == '\0' ){
103 return true;
104 }
105
106 return false;
107 }
108
109 static int JumpStringInPare(const char *buffer,int pos){
110 int PareNum;
111 for(PareNum=1;;pos++){
112 if(buffer[pos]=='\"'){
113 for(pos++;;pos++){
114 if(buffer[pos]=='\"') break;
115 }
116 continue;
117 }
118 else if(buffer[pos]=='(') PareNum++;
119 else if(buffer[pos]==')'){
120 PareNum--;
121 if(PareNum==0) return pos;
122 }
123 else if(buffer[pos]=='\0') break;
124 }
125 return 0;
126 }
127 static int JumpStringInBracket(const char *buffer,int pos){
128 int PareNum;
129 for(PareNum=1;;pos++){
130 if(buffer[pos]=='\"'){
131 for(pos++;;pos++){
132 if(buffer[pos]=='\"') break;
133 }
134 continue;
135 }
136 else if(buffer[pos]=='[') PareNum++;
137 else if(buffer[pos]==']'){
138 PareNum--;
139 if(PareNum==0) return pos;
140 }
141 else if(buffer[pos]=='\0') break;
142 }
143 return 0;
144 }
145};
Note: See TracBrowser for help on using the repository browser.