Bundle

Bundle save data in container (associative array GlValueGlKey).

Container structure: GlKey1 -> GlValue1 GlKey2 -> GlValue2 GlKey3 -> GlValue3 .................. GlKeyN -> GlValueN | |=> Key1 -> Values1 Key2 -> Values2 .............. KeyM -> ValuesM | |=> [DataValue1, DataValue2, ... DataValueP]

Constructors

this
this(string filePath, Parameters pars)

Build Bundle from text file

this
this(string[] lines, Parameters pars)

Build Bundle from string array

this
this(string[int] lines, Parameters pars)

Build Bundle from string array

Members

Functions

glKeys
immutable(GlKey[]) glKeys()

Get global keys present in bundle

glValue
immutable(GlValue) glValue(GlKey glKey)

Get Global value from bundle

isGlKeyPresent
bool isGlKeyPresent(GlKey glKey)

Check is global key present in bundle

isValuePresent
bool isValuePresent(GlKey glKey, Key key, int pos)

Check if value present in bundle (pos value from line)

isValuePresent
bool isValuePresent(GlKey glKey, Key key)

Check is value present in bundle (First value from line)

keys
immutable(Key[]) keys(GlKey glKey)

Get keys present in bundle at one global key

opBinary
immutable(Bundle) opBinary(Bundle rBundle)

Add two bundles (this and rBundle)

subBundle
immutable(Bundle) subBundle(GlKey glKey)

Get from this bundle one global data part

value
immutable(T) value(GlKey glKey, Key key, uint pos)

Get one value from bundle

value
immutable(T) value(GlKey glKey, Key key)

Get one value from bundle

values
immutable(Values) values(GlKey glKey, Key key)

Get Values from bundle

Static functions

dup
GlValue[GlKey] dup(Bundle bundle)

Make muttable copy of bundle container

Examples

1 string[] s =
2     ["[general] 			# GlKey = general",
3      "module_name = Main 	# Key = module_name, Values[0] = Main, keySeparator = EQUALS SIGN",
4      "[DebugLogger]			# GlKey = DebugLogger",
5      "level = debug",
6      "appender = FileAppender",
7      "rolling = SizeBasedRollover",
8      "fileName = ./log/MainDebug.log",
9      "[empty_gl_key]", // Test GlKey with empty GlValue
10      "[data_receive]",
11      "# Key = 0xC000, Values[0] = 0x014B, Values[1] = 0x0B, keySeparator = SPACE",
12      "0xC000 		0x014B		0x0B		Рstation	yes		1		(32*{0xC000}+0)"];
13 
14 auto p = immutable Parameters("[", "]", ["=", " "], "#");
15 
16 auto bundle = new immutable Bundle(s, p);
17 
18 
19 // glValue test
20 {
21     auto glValue = bundle.glValue("general");
22     immutable gv = ["module_name":["Main"]];
23     assert (glValue == gv);
24 }
25 
26 // Emty GlValue test
27 {
28     auto glValue = bundle.glValue("empty_gl_key");
29     assert (glValue == null);
30 }
31 
32 // values test
33 {
34     auto values = bundle.values("DebugLogger", "level");
35     assert (values == ["debug"]);
36 
37 }
38 
39 // Value test (N pos)
40 {
41     auto value = bundle.value("data_receive", "0xC000", 3);
42     assert (value == "yes");
43 }
44 
45 // Value test (0 pos)
46 {
47     auto value = bundle.value("data_receive", "0xC000");
48     assert (value == "0x014B");
49 }
50 
51 // int Value test (0 pos)
52 {
53     auto value = bundle.value!int("data_receive", "0xC000");
54     assert (value == 0x014B);
55 }
56 
57 // isValuePresent test
58 {
59     auto present = bundle.isValuePresent("data_receive", "0xC000", 1);
60     assert (present == true);
61     auto nopresent = bundle.isValuePresent("general", "module_name", 5);
62     assert (nopresent == false);
63 }
64 
65 // isGlKeyPresent
66 {
67     auto present = bundle.isGlKeyPresent("DebugLogger");
68     assert (present == true);
69     auto nopresent = bundle.isGlKeyPresent("superkey");
70     assert (nopresent == false);
71 }

Meta