diff options
Diffstat (limited to 'util/fbautostart/src/value.cc')
-rw-r--r-- | util/fbautostart/src/value.cc | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/util/fbautostart/src/value.cc b/util/fbautostart/src/value.cc new file mode 100644 index 0000000..d96648b --- /dev/null +++ b/util/fbautostart/src/value.cc | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011, Paul Tagliamonte | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
5 | * of this software and associated documentation files (the "Software"), to deal | ||
6 | * in the Software without restriction, including without limitation the rights | ||
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
8 | * copies of the Software, and to permit persons to whom the Software is | ||
9 | * furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
20 | * THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #include <string> | ||
24 | #include <iostream> | ||
25 | |||
26 | #include "key.hh" | ||
27 | #include "value.hh" | ||
28 | #include "entry.hh" | ||
29 | #include "group.hh" | ||
30 | #include "machine.hh" | ||
31 | #include "xdg_model.hh" | ||
32 | |||
33 | value xdg_value; | ||
34 | |||
35 | std::string xdg_state_value_lastparsed; | ||
36 | |||
37 | void value::leave_state() { | ||
38 | |||
39 | std::string group = xdg_state_group_lastparsed; | ||
40 | std::string key = xdg_state_key_lastparsed; | ||
41 | std::string value = xdg_state_value_lastparsed; | ||
42 | |||
43 | xdg_model_entries::iterator iter = xdg_parsed_file.find(group); | ||
44 | |||
45 | if (iter != xdg_parsed_file.end()) { | ||
46 | xdg_model_entry * group_map = &iter->second; | ||
47 | xdg_model_entry_t new_item( key, value ); | ||
48 | group_map->insert(new_item); | ||
49 | } else { | ||
50 | xdg_model_entry group_map; | ||
51 | xdg_model_entry_t new_item( key, value ); | ||
52 | group_map.insert(new_item); | ||
53 | xdg_model_entries_t payload( group, group_map ); | ||
54 | xdg_parsed_file.insert(payload); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | void value::enter_state() { | ||
59 | xdg_state_value_lastparsed = ""; | ||
60 | } | ||
61 | |||
62 | void value::process( char c ) { | ||
63 | switch ( c ) { | ||
64 | case '\n': | ||
65 | xdg_machine_next_state = &xdg_entry; | ||
66 | break; | ||
67 | default: | ||
68 | /* push back char */ | ||
69 | xdg_state_value_lastparsed.append(1, c); | ||
70 | break; | ||
71 | } | ||
72 | } | ||
73 | |||