aboutsummaryrefslogtreecommitdiff
path: root/UserConfig.hpp
blob: 4d3d6b396b603fae1384127e75367ee06beb54cf (plain)
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
#ifndef USER_CONFIG_HPP
#define USER_CONFIG_HPP 1

#include <iostream>
#include <list>
#include <vector>

using std::string;
using std::list;
using std::vector;

class CUserConfig {
private:
    string mSerialPortName;
    string mSerialSpeed;
    bool mVerboseMode;
    bool mHelp;
    bool mVersion;
    bool mIdent;
    bool mSpeeds;
    float mMcuFrequency;
    bool mPrintProgress;
    // Erase    
    bool mErase;
    list<unsigned int> mEraseBlockList;
    // Read
    bool mRead;
    string mReadOutputFilename;
    int mReadLength;
    // Write
    bool   mWrite;
    bool   mWriteEraseWholeMemory;
    string mWriteInputFilename;
    bool   mWriteCheckByRead;

    string getArgument(vector<char *>::const_iterator args, vector<char *>::const_iterator end);
    void parseEraseArguments(vector<char *>::const_iterator args, vector<char *>::const_iterator end);
    void parseReadArguments(vector<char *>::const_iterator args, vector<char *>::const_iterator end);
    void parseWriteArguments(vector<char *>::const_iterator args, vector<char *>::const_iterator end);
    void parseCommandLine(vector<char *> & args);
    
public:
    CUserConfig(int argc, char **argv);

    const string getHelpMessage(const string & execName) const;

    string & getSerialPortName();
    string & getSerialSpeed();
    bool isSpeedsSet();
    bool isVerboseModeSet();
    bool isPrintProgressSet();
    bool isHelpSet();
    bool isVersionSet();
    bool isIdentSet();
    bool isEraseSet();
    list<unsigned int> getEraseBlockList();
    bool isReadSet();
    string & getReadOutputFname();
    bool isWriteSet();
    string & getWriteInputFname();
    int getReadLength();
    bool getWriteEraseWholeMemory();
    bool getWriteCheckByRead();
    float getMcuFrequency();
};

#endif