2021-05-09 00:56:48 +12:00
|
|
|
/* Copyright 2021 Aristocratos (jakob@qvantnet.com)
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
indent = tab
|
|
|
|
tab-size = 4
|
|
|
|
*/
|
|
|
|
|
2021-06-20 00:57:27 +12:00
|
|
|
#pragma once
|
2021-05-09 00:56:48 +12:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2021-05-29 12:32:36 +12:00
|
|
|
#include <filesystem>
|
2021-05-09 00:56:48 +12:00
|
|
|
|
2021-06-20 00:57:27 +12:00
|
|
|
using std::string, std::vector;
|
2021-05-09 06:37:36 +12:00
|
|
|
|
2021-05-15 04:54:37 +12:00
|
|
|
//* Functions and variables for reading and writing the btop config file
|
|
|
|
namespace Config {
|
2021-06-12 10:35:15 +12:00
|
|
|
|
2021-06-20 00:57:27 +12:00
|
|
|
extern std::filesystem::path conf_dir;
|
|
|
|
extern std::filesystem::path conf_file;
|
2021-05-15 04:54:37 +12:00
|
|
|
|
2021-06-21 08:07:04 +12:00
|
|
|
extern const vector<string> valid_graph_symbols;
|
2021-05-09 00:56:48 +12:00
|
|
|
|
2021-07-04 11:18:48 +12:00
|
|
|
//* Check if string only contains space seperated valid names for boxes
|
|
|
|
bool check_boxes(string boxes);
|
|
|
|
|
2021-06-21 08:07:04 +12:00
|
|
|
//* Return bool for config key <name>
|
2021-06-20 00:57:27 +12:00
|
|
|
const bool& getB(string name);
|
2021-05-09 00:56:48 +12:00
|
|
|
|
2021-06-21 08:07:04 +12:00
|
|
|
//* Return integer for config key <name>
|
2021-06-20 00:57:27 +12:00
|
|
|
const int& getI(string name);
|
2021-05-09 00:56:48 +12:00
|
|
|
|
2021-06-21 08:07:04 +12:00
|
|
|
//* Return string for config key <name>
|
2021-06-20 00:57:27 +12:00
|
|
|
const string& getS(string name);
|
2021-05-15 04:54:37 +12:00
|
|
|
|
2021-06-21 08:07:04 +12:00
|
|
|
//* Set config key <name> to bool <value>
|
2021-06-20 00:57:27 +12:00
|
|
|
void set(string name, bool value);
|
2021-05-15 04:54:37 +12:00
|
|
|
|
2021-06-21 08:07:04 +12:00
|
|
|
//* Set config key <name> to int <value>
|
2021-06-20 00:57:27 +12:00
|
|
|
void set(string name, int value);
|
2021-05-15 04:54:37 +12:00
|
|
|
|
2021-06-21 08:07:04 +12:00
|
|
|
//* Set config key <name> to string <value>
|
2021-06-20 00:57:27 +12:00
|
|
|
void set(string name, string value);
|
2021-05-15 04:54:37 +12:00
|
|
|
|
2021-06-21 08:07:04 +12:00
|
|
|
//* Flip config key bool <name>
|
2021-06-20 00:57:27 +12:00
|
|
|
void flip(string name);
|
2021-06-06 11:41:36 +12:00
|
|
|
|
|
|
|
//* Wait if locked then lock config and cache changes until unlock
|
2021-06-20 00:57:27 +12:00
|
|
|
void lock();
|
2021-06-06 11:41:36 +12:00
|
|
|
|
|
|
|
//* Unlock config and write any cached values to config
|
2021-06-20 00:57:27 +12:00
|
|
|
void unlock();
|
2021-06-05 11:41:24 +12:00
|
|
|
|
2021-06-12 10:35:15 +12:00
|
|
|
//* Load the config file from disk
|
2021-06-20 00:57:27 +12:00
|
|
|
void load(std::filesystem::path conf_file, vector<string>& load_errors);
|
2021-06-10 05:47:49 +12:00
|
|
|
|
2021-06-12 10:35:15 +12:00
|
|
|
//* Write the config file to disk
|
2021-06-20 00:57:27 +12:00
|
|
|
void write();
|
|
|
|
}
|