File: OpencxxConfiguration.h

package info (click to toggle)
openc%2B%2B 2.8-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 5,464 kB
  • ctags: 3,333
  • sloc: cpp: 19,071; sh: 12,793; ansic: 3,549; makefile: 577
file content (227 lines) | stat: -rw-r--r-- 7,459 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#ifndef guard_opencxx_OpencxxConfiguration_h
#define guard_opencxx_OpencxxConfiguration_h
//@beginlicenses@
//@license{Grzegorz Jakacki}{2004}@
//
//  Permission to use, copy, distribute and modify this software and its  
//  documentation for any purpose is hereby granted without fee, provided that
//  the above copyright notice appears in all copies and that both that copyright
//  notice and this permission notice appear in supporting documentation.
// 
//  Grzegorz Jakacki make(s) no representations about the suitability of this
//  software for any purpose. It is provided "as is" without express or implied
//  warranty.
//  
//  Copyright (C) 2004 Grzegorz Jakacki
//
//@endlicenses@

#include <vector>
#include <string>
#include <opencxx/defs.h>
#include <opencxx/MetacompilerConfiguration.h>

namespace Opencxx
{

class ErrorLog;

class OpencxxConfiguration : public MetacompilerConfiguration
{
private:
    class IteratorImpl : public MetacompilerConfiguration::IteratorIface
    {
    public:
        IteratorImpl(std::vector<std::string>::const_iterator begin,
                     std::vector<std::string>::const_iterator end)
          : iter_(begin)
          , end_(end)
        {
        }
        
        std::string Get() const { return *iter_; }
        void Advance() { ++iter_; }
        bool AtEnd() const { return iter_ == end_; }
        std::auto_ptr<MetacompilerConfiguration::IteratorIface> Clone() const
        {
            return std::auto_ptr<MetacompilerConfiguration::IteratorIface>(
                new IteratorImpl(*this)
            );
        }
        
    private:
        IteratorImpl(const IteratorImpl& that)
          : iter_(that.iter_)
          , end_(that.end_)
        {
        }
        
        void operator=(const IteratorImpl&);
        
        std::vector<std::string>::const_iterator iter_;
        std::vector<std::string>::const_iterator end_;
    };
    
public:
    OpencxxConfiguration(Opencxx::ErrorLog& errorLog)
      : errorLog_(errorLog)
      , verboseMode_(false)
      , libtoolPlugins_(false)
      , doPreprocess_(true)
      , preprocessTwice_(false)
      , makeExecutable_(true)
      , makeSharedLibrary_(false)
      , recognizeOccExtensions_(true)
      , wcharSupport_(false)
      , staticInitialization_(true)
      , doCompile_(true)
      , showProgram_(false)
      , externalDriver_(false)
      , doTranslate_(true)
      , showVersion_(false)
      , printMetaclasses_(false)
      , numOfObjectFiles_(0)
      , sharedLibraryName_()
      , compilerCommand_("g++")
      , preprocessorCommand_("g++")
      , linkerCommand_("g++")
    {
    }

    virtual ~OpencxxConfiguration() {}

    void SetVerboseMode(bool v) { verboseMode_ = v; }
    bool VerboseMode() const { return verboseMode_; }
    
    void SetLibtoolPlugins(bool v) { libtoolPlugins_ = v; }
    bool LibtoolPlugins() const { return libtoolPlugins_; }
    void AddCcOption(const std::string& option)
    {
        ccOptions_.push_back(option);
    }
    
    Iterator CcOptions() const
    {
        return Iterator(
            std::auto_ptr<IteratorImpl>(
                new IteratorImpl(ccOptions_.begin(), ccOptions_.end())
            )
        );
    }
    
    void AddCc2Option(const std::string& option)
    {
        cc2Options_.push_back(option);
    }
    void AddCppOption(const std::string& option)
    {
        cc2Options_.push_back(option);
    }
    void SetDoPreprocess(bool v) { doPreprocess_ = v; }
    bool DoPreprocess() const { return doPreprocess_; }
    
    void SetSharedLibraryName(const std::string& name) 
    { 
        sharedLibraryName_ = name;
    }
    std::string SharedLibraryName() const { return sharedLibraryName_; }
    
    void SetMakeSharedLibrary(bool v) { makeSharedLibrary_ = v; }
    bool MakeSharedLibrary() const { return makeSharedLibrary_; }
    void SetPreprocessTwice(bool v) { preprocessTwice_ = v;}
    bool PreprocessTwice() const { return preprocessTwice_;}
    void SetMakeExecutable(bool v) { makeExecutable_ = v; }
    bool MakeExecutable() const { return makeExecutable_; }
    void SetRecognizeOccExtensions(bool v) { recognizeOccExtensions_ = v; }
    bool RecognizeOccExtensions() const { return recognizeOccExtensions_; }
    void RecordCmdOption(char*);
    void SetWcharSupport(bool v) { wcharSupport_ = v; }
    bool WcharSupport() const { return wcharSupport_; }
    
    void SetExternalDriver(bool v) { externalDriver_ = v; }
    bool ExternalDriver() const { return externalDriver_; }
    
    void SetStaticInitialization(bool v) { staticInitialization_ = v; }
    bool StaticInitialization() const { return staticInitialization_; }

    void SetDoCompile(bool v) { doCompile_ = v; }
    bool DoCompile() const { return doCompile_; }

    void SetDoTranslate(bool v) { doTranslate_ = v; }
    bool DoTranslate() const { return doTranslate_; }
    
    void SetSourceFileName(const std::string& s) { sourceFileName_ = s; }
    std::string SourceFileName() const { return sourceFileName_; }
    
    void SetOutputFileName(const std::string& s) { outputFileName_ = s; }
    std::string OutputFileName() const { return outputFileName_; }
    
    void SetCompilerCommand(const std::string& s) { compilerCommand_ = s; }
    std::string CompilerCommand() const { return compilerCommand_; }
    
    void SetLinkerCommand(const std::string& s) { linkerCommand_ = s; }
    std::string LinkerCommand() const { return linkerCommand_; }
    
    void SetPreprocessorCommand(const std::string& s) { preprocessorCommand_ = s; }
    std::string PreprocessorCommand() const { return preprocessorCommand_; }
    
    void SetPrintMetaclasses(bool v) { printMetaclasses_ = v; }
    bool PrintMetaclasses() const { return printMetaclasses_; }
    
    void AddObjectFile() { ++numOfObjectFiles_; }
    int NumOfObjectFiles() const { return numOfObjectFiles_; }
    
    void SetShowProgram(bool v) { showProgram_ = v; }
    bool ShowProgram() const { return showProgram_; }
    
    void SetShowVersion(bool v) { showVersion_ = v; }
    bool ShowVersion() const { return showVersion_; }
    
    void AddMetaclass(const std::string& metaclass) { metaclasses_.push_back(metaclass); }
    Iterator Metaclasses() const
    {
        return Iterator(
            std::auto_ptr<IteratorImpl>(
                new IteratorImpl(metaclasses_.begin(), metaclasses_.end())
            )
        );
    }
    
    Opencxx::ErrorLog& ErrorLog() const { return errorLog_; }

private:
    Opencxx::ErrorLog& errorLog_;
    bool verboseMode_;
    bool libtoolPlugins_;
    bool doPreprocess_;
    bool preprocessTwice_;
    bool makeExecutable_;
    bool makeSharedLibrary_;
    bool recognizeOccExtensions_;
    bool wcharSupport_;
    bool staticInitialization_;
    bool doCompile_;
    bool showProgram_;
    bool externalDriver_;
    bool doTranslate_;
    bool showVersion_;
    bool printMetaclasses_;
    int  numOfObjectFiles_;
    std::string sourceFileName_;
    std::string sharedLibraryName_;
    std::string outputFileName_;
    std::string compilerCommand_;
    std::string preprocessorCommand_;
    std::string linkerCommand_;
    
    std::vector<std::string> ccOptions_;
    std::vector<std::string> cc2Options_;
    std::vector<std::string> metaclasses_;
};

void ParseCommandLine(int argc, char** argv, OpencxxConfiguration& config);
    /* throws UnknownCliOptionException */

}

#endif /* ! guard_opencxx_OpencxxConfiguration_h */