| 1 | /* |
| 2 | * File: ConfigFile.h |
| 3 | * |
| 4 | * Author: Jacob Dekel |
| 5 | * Created on: Aug 7, 2009 |
| 6 | * |
| 7 | * Copyright (c) 2009-2013 Jacob Dekel |
| 8 | * $Id$ |
| 9 | * |
| 10 | * This object manages the configuration file |
| 11 | * |
| 12 | * This program is free software: you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation, either version 3 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #ifndef CONFIG_FILE |
| 28 | #define CONFIG_FILEcxx . . $ `HercConfiguration/ConfigFile.h:28:9`! |
| 29 | |
| 30 | #include "SystemConfigLine.h"cxx . . $ `<file>/HercConfiguration/SystemConfigLine.h`/ |
| 31 | #include "DeviceConfigLine.h"cxx . . $ `<file>/HercConfiguration/DeviceConfigLine.h`/ |
| 32 | |
| 33 | #include <QPlainTextEdit> |
| 34 | #include <QTextBlock> |
| 35 | #include <string> |
| 36 | #include <vector> |
| 37 | |
| 38 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<ConfigLinecxx . . $ ConfigLine#> FileArraycxx . . $ FileArray#; |
| 39 | #define MAX_CONFIG_LINEcxx . . $ `HercConfiguration/ConfigFile.h:39:9`! 512 |
| 40 | |
| 41 | struct SynonymTableEntrycxx . . $ SynonymTableEntry# |
| 42 | { |
| 43 | stdcxx . . $ std/::stringcxx . . $ std/string# keyword1cxx . . $ SynonymTableEntry#keyword1.; |
| 44 | stdcxx . . $ std/::stringcxx . . $ std/string# keyword2cxx . . $ SynonymTableEntry#keyword2.; |
| 45 | }; |
| 46 | |
| 47 | class ConfigFilecxx . . $ ConfigFile# |
| 48 | { |
| 49 | public: |
| 50 | ConfigFilecxx . . $ ConfigFile#ConfigFile(9c546c94e5fcce4e).(const stdcxx . . $ std/::stringcxx . . $ std/string#& fileName); |
| 51 | virtual ~cxx . . $ ConfigFile#`~ConfigFile`(49f6e7a06ebc5aa8).ConfigFilecxx . . $ ConfigFile#(); |
| 52 | |
| 53 | void initializecxx . . $ ConfigFile#initialize(49f6e7a06ebc5aa8).(); |
| 54 | void updateEditorcxx . . $ ConfigFile#updateEditor(e4053161e629f27a).(QPlainTextEditcxx . . $ QPlainTextEdit#& document); |
| 55 | const stdcxx . . $ std/::stringcxx . . $ std/string#& getFileNamecxx . . $ ConfigFile#getFileName(f4fff0029955a25f).() const; |
| 56 | SystemConfigLinecxx . . $ SystemConfigLine# * operatorcxx . . $ ConfigFile#`operator[]`(78b98f7fd5f54797).[] (int index) const; |
| 57 | DeviceConfigLinecxx . . $ DeviceConfigLine# * getDevicecxx . . $ ConfigFile#getDevice(449b59f7b7ccf910).(int index) const; |
| 58 | DeviceConfigLinecxx . . $ DeviceConfigLine# * getDevicecxx . . $ ConfigFile#getDevice(73336e9f92c2174d).(const stdcxx . . $ std/::stringcxx . . $ std/string#& devno) const; |
| 59 | DeviceConfigLinecxx . . $ DeviceConfigLine# * findFirstDeviceByTypecxx . . $ ConfigFile#findFirstDeviceByType(a405516eca06dda3).(const char * type) const; |
| 60 | int numberOfDevicescxx . . $ ConfigFile#numberOfDevices(b126dc7c1de90089).(); |
| 61 | bool writecxx . . $ ConfigFile#write(7c222eea44a24d43).(const stdcxx . . $ std/::stringcxx . . $ std/string#& fileName); |
| 62 | bool writecxx . . $ ConfigFile#write(c9857a73d68e59ba).(); |
| 63 | int sizecxx . . $ ConfigFile#size(455f465bc33b4cdf).() const; |
| 64 | void addNonDevcxx . . $ ConfigFile#addNonDev(ad5112fe94425fef).(SystemConfigLinecxx . . $ SystemConfigLine# * configLine); |
| 65 | void addDevcxx . . $ ConfigFile#addDev(7f38ef9bc46b32f0).(DeviceConfigLinecxx . . $ DeviceConfigLine# * configLine); |
| 66 | void appendNewLinescxx . . $ ConfigFile#appendNewLines(49f6e7a06ebc5aa8).(); |
| 67 | const ConfigLinecxx . . $ ConfigLine# * locateLinecxx . . $ ConfigFile#locateLine(1587660f762aabe4).(const stdcxx . . $ std/::stringcxx . . $ std/string#& keyword, bool create=false, bool synonyms=true); |
| 68 | void deleteLinecxx . . $ ConfigFile#deleteLine(d4f767463ce0a6b3).(int index); |
| 69 | inline int getLastSyscxx . . $ ConfigFile#getLastSys(b126dc7c1de90089).() { return mLastSyscxx . . $ ConfigFile#mLastSys.; }; |
| 70 | bool changedcxx . . $ ConfigFile#changed(c9857a73d68e59ba).(); |
| 71 | inline bool isNewcxx . . $ ConfigFile#isNew(50ce9a9e25b4a850).() const {return mNewConfigcxx . . $ ConfigFile#mNewConfig.;}; |
| 72 | void setNewcxx . . $ ConfigFile#setNew(b45ddcbc8423892c).(bool newVal); |
| 73 | |
| 74 | private: |
| 75 | enum BuildTypecxx . . $ ConfigFile#BuildType# |
| 76 | { |
| 77 | Filecxx . . $ ConfigFile#File.=1, |
| 78 | TextEditcxx . . $ ConfigFile#TextEdit. |
| 79 | }; |
| 80 | |
| 81 | stdcxx . . $ std/::stringcxx . . $ std/string# mFileNamecxx . . $ ConfigFile#mFileName.; |
| 82 | FileArraycxx . . $ FileArray# mFileArraycxx . . $ ConfigFile#mFileArray.; |
| 83 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<SystemConfigLinecxx . . $ SystemConfigLine#> mNewLinescxx . . $ ConfigFile#mNewLines.; |
| 84 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<DeviceConfigLinecxx . . $ DeviceConfigLine#> mNewDeviceLinescxx . . $ ConfigFile#mNewDeviceLines.; |
| 85 | static struct SynonymTableEntrycxx . . $ SynonymTableEntry# mSynonymscxx . . $ ConfigFile#mSynonyms.[]; |
| 86 | FILEcxx . . $ FILE# * mFilecxx . . $ ConfigFile#mFile.; |
| 87 | QPlainTextEditcxx . . $ QPlainTextEdit# * mEditorcxx . . $ ConfigFile#mEditor.; |
| 88 | QTextBlockcxx . . $ QTextBlock# mEditorIteratorcxx . . $ ConfigFile#mEditorIterator.; |
| 89 | |
| 90 | int mLastSyscxx . . $ ConfigFile#mLastSys.; // last line before device statements |
| 91 | bool mChangedcxx . . $ ConfigFile#mChanged.; // updates were done to file which were not saved yet |
| 92 | bool mNewConfigcxx . . $ ConfigFile#mNewConfig.; // never saved |
| 93 | static const char *configTemplatecxx . . $ ConfigFile#configTemplate.[]; // template for new config file |
| 94 | int templateCountercxx . . $ ConfigFile#templateCounter.; // line number to read from template |
| 95 | |
| 96 | void openTemplatecxx . . $ ConfigFile#openTemplate(49f6e7a06ebc5aa8).(); |
| 97 | char * getNextLinecxx . . $ ConfigFile#getNextLine(cb6f7f004a0816fd).(char * buff, int len, BuildTypecxx . . $ ConfigFile#BuildType# type); |
| 98 | |
| 99 | void buildConfigcxx . . $ ConfigFile#buildConfig(1b216c63eb944761).(BuildTypecxx . . $ ConfigFile#BuildType#); |
| 100 | }; |
| 101 | |
| 102 | #endif |