NetBurner 3.5.6
PDF Version
config_fs_bulkstore.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
17#ifndef __CONFIG_FS_BULKSTORE_H
18#define __CONFIG_FS_BULKSTORE_H
19
20#include <buffers.h>
21#include <config_obj.h>
22#include <nbstring.h>
23#include <hal_platdefs.h>
24
25class config_fs_bulkstore : public config_string
26{
27public:
28 enum {
29 FLAG_EXPOSE_PATH_TO_CONFIG = 0x1,
30 FLAG_NEED_FS_RELOAD = 0x2,
31 FLAG_IS_SENSITIVE_HIDE_VALUE= 0x4,
32 FLAG_FS_PATH_PENDING = 0x8,
33 FLAG_ON_PATH_CHANGE_KEEP = 0x10,
34 FLAG_PEND_VAL_IS_PATH = 0x80000,
35 };
36
37 enum class OnRename {
38 MOVE = 0,
39 KEEP = 1,
40 NOP = 2,
41 };
42
43private:
44 NBString fs_path;
45 NBString pend_fs_path;
46 uint32_t bulkstore_flags;
47
48 void ReloadFromFile();
49 void SaveToFile();
50 void GetValue(NBString &s, bool raw);
51public:
52 virtual void RawFdPrintTree(int fd, int n, bool pretty, uint32_t mask, bool braw_values,bool valonly) override;
53
54 config_fs_bulkstore(const char *fname, bool exposePathToConfig, const char *name, const char *desc = NULL, bool keepOldFile = false);
55 config_fs_bulkstore(config_obj &owner, const char *fname, bool exposePathToConfig, const char *name, const char *desc = NULL, bool keepOldFile = false );
56 config_fs_bulkstore(config_fs_bulkstore &&e);
57
58 inline void SetBulkstoreFlags(uint32_t flags) { bulkstore_flags |= flags; }
59 inline void ClearBulkstoreFlags(uint32_t flags) { bulkstore_flags &= ~flags; }
60 inline uint32_t GetBulkstoreFlags(uint32_t flags){ return bulkstore_flags; }
61
62 virtual ConfigTestResult TestNewValue(ParsedJsonDataSet &pjs) override;
63 virtual void CommitTestedValue(uint32_t permission_mask) override;
64 void SetFilePath(const char *newFname, OnRename action = OnRename::MOVE);
65 const char * GetFilePath() const { return fs_path.c_str(); }
66 void SetExposeToConfig(bool enable)
67 {
68 if (enable)
69 bulkstore_flags |= FLAG_EXPOSE_PATH_TO_CONFIG;
70 else
71 bulkstore_flags &= ~FLAG_EXPOSE_PATH_TO_CONFIG;
72 }
73
74 virtual void GetRawValue(NBString &s) override;
75 virtual void GetTextValue(NBString &s) override;
76 operator NBString() const { return val; };
77
78 virtual void GetTypeValue(NBString &s) override;
79 virtual void ExtendedSchema(int fd, int indent, bool pretty) override;
80};
81#endif /* ----- #ifndef __CONFIG_FS_BULKSTORE_H ----- */
82
Lightweight alternative to C++ CString class.
Definition nbstring.h:118
const char * c_str() const
Method to pass a NBString as a constant char *.
A class to create, read, and modify a JSON object.
Definition json_lexer.h:535
Base class used to create configuration objects.
Definition config_obj.h:320
String Configuration Variable.
Definition config_obj.h:1127