Definition in file cstpp.cpp.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <stdlib.h>
#include "clssdf.h"
Include dependency graph for cstpp.cpp:

Go to the source code of this file.
Functions | |
| void | usage () |
| int | main (int argc, const char *argv[]) |
| int main | ( | int | argc, | |
| const char * | argv[] | |||
| ) |
main This is the main function for cstpp.
Definition at line 34 of file cstpp.cpp.
References class_def::comment::_data, class_def::class_definition::_univ, class_def::find_tag(), class_def::get_tag(), class_def::print_stringify(), class_def::attribute::put_allow_custom_classes(), class_def::attribute::put_check_attributes(), class_def::attribute::put_copy_constructor(), class_def::class_definition::set_back_white(), class_def::class_definition::set_domain_error(), class_def::class_definition::set_error_function(), class_def::class_definition::set_output_format(), and usage().
00034 { 00035 class_def::class_definition *_class_definition; 00036 const char *infile, *outfile, *outputformat, *errorfunction, *backwhite, *domain_error, *deffile, *customclasses, *nocopy, 00037 *no_check_attributes; 00038 istream *in, *def; 00039 ostream *out; 00040 ifstream fin; 00041 ofstream fout; 00042 int argmask[10], i, errflag, j, k; 00043 vector<string> deffiles; 00044 00045 argmask[0] = 1; 00046 for (i=1;i<10;i++) { 00047 argmask[i] = 0; 00048 } 00049 00050 bool ask_help = find_tag( argc, argv, argmask, "-?")!=0 || 00051 find_tag( argc, argv, argmask, "?")!=0; 00052 if (argc>10 || ask_help) { 00053 usage(); 00054 return 1; 00055 } 00056 00057 infile = get_tag( argc, argv, argmask, "-i=", NULL); 00058 00059 deffile = get_tag( argc, argv, argmask, "-def=", NULL); 00060 while (deffile!=0) { 00061 deffiles.push_back( deffile); 00062 deffile = get_tag( argc, argv, argmask, "-def=", NULL); 00063 } 00064 00065 outfile = get_tag( argc, argv, argmask, "-o=", NULL); 00066 00067 outputformat = get_tag( argc, argv, argmask, "-f=", NULL); 00068 00069 errorfunction = find_tag( argc, argv, argmask, "-e"); 00070 00071 domain_error = find_tag( argc, argv, argmask, "-domain_error"); 00072 00073 customclasses = find_tag( argc, argv, argmask, "-c"); 00074 00075 nocopy = find_tag( argc, argv, argmask, "-nocopy"); 00076 00077 no_check_attributes = find_tag( argc, argv, argmask, "-no_check_attributes"); 00078 00079 backwhite = find_tag( argc, argv, argmask, "-b"); 00080 00081 if (errorfunction!=NULL) { 00082 class_def::class_definition::set_error_function( 1); 00083 } 00084 00085 if (domain_error!=NULL) { 00086 class_def::class_definition::set_domain_error( 1); 00087 } 00088 00089 if (customclasses!=NULL) { 00090 class_def::attribute::put_allow_custom_classes( 1); 00091 } 00092 00093 if (nocopy != NULL) { 00094 class_def::attribute::put_copy_constructor( 0); 00095 } 00096 00097 if (no_check_attributes != NULL) { 00098 class_def::attribute::put_check_attributes( 0); 00099 } 00100 00101 if (backwhite!=NULL) { 00102 class_def::class_definition::set_back_white( 1); 00103 } 00104 00105 for (errflag=0,i=1;i<argc;i++) { 00106 if (argmask[i]==0) { 00107 cerr << "error argument={" << argv[i] << "} was not recognized" << endl; 00108 errflag = 1; 00109 } 00110 } 00111 if (errflag) { 00112 return 2; 00113 } 00114 00115 // read definition files to get definitions of parent classes 00116 for (i=k=0;k<deffiles.size();k++) { 00117 ifstream fdef( deffiles[k].c_str()); 00118 00119 if (!fdef.is_open()) { 00120 cerr << "can't open " << deffiles[i] << endl; 00121 return 3; 00122 } 00123 def = &fdef; 00124 00125 while (*def) { 00126 try { 00127 _class_definition = new class_def::class_definition(); 00128 *def >> *_class_definition; 00129 class_def::class_definition::_univ.push_back( _class_definition); 00130 i++; 00131 } catch (std::exception& xpt ) { 00132 cerr << xpt.what(); 00133 return 5; 00134 } catch (class_def::end_of_input) { 00135 break; 00136 } catch (class_def::comment cm) { 00137 00138 } catch (...) { 00139 cerr << "unknown exception was thrown" << endl; 00140 break; 00141 } 00142 } 00143 00144 fdef.close(); 00145 def = NULL; 00146 } 00147 00148 if (infile==NULL) { 00149 in = &cin; 00150 } else { 00151 fin.open( infile); 00152 if (!fin.is_open()) { 00153 cerr << "can't open " << infile << endl; 00154 return 3; 00155 } 00156 in = &fin; 00157 } 00158 00159 if (outfile==NULL) { 00160 out = &cout; 00161 } else { 00162 fout.open( outfile, ios::binary); 00163 if (!fout.is_open()) { 00164 cerr << "can't open " << outfile << endl; 00165 return 4; 00166 } 00167 out = &fout; 00168 } 00169 00170 if (outputformat==NULL) 00171 outputformat = "header_output"; 00172 00173 class_def::class_definition::set_output_format( outputformat); 00174 00175 j = 0; 00176 while (*in) { 00177 if (j==0 && domain_error != NULL) { 00178 j = 1; 00179 out->flush(); 00180 *out << class_def::print_stringify() << endl; 00181 } 00182 00183 try { 00184 _class_definition = new class_def::class_definition(); 00185 *in >> *_class_definition; 00186 class_def::class_definition::_univ.push_back( _class_definition); 00187 00188 *out << *(class_def::class_definition::_univ.back()); 00189 //i++; 00190 00191 } catch (std::exception& xpt) { 00192 cerr << xpt.what(); 00193 return 5; 00194 } catch (class_def::end_of_input) { 00195 break; 00196 } catch (class_def::comment cm) { 00197 *out << cm._data << endl; 00198 } catch (...) { 00199 cerr << "unknown exception was thrown" << endl; 00200 break; 00201 } 00202 } 00203 00204 for (j=0;j<i;j++) { 00205 _class_definition = class_def::class_definition::_univ[j]; 00206 delete _class_definition; 00207 } 00208 00209 return 0; 00210 }
Here is the call graph for this function:

1.5.1