File: resource-file.h

package info (click to toggle)
ecasound 2.9.1-7
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 5,652 kB
  • ctags: 6,128
  • sloc: cpp: 39,403; sh: 10,512; ansic: 2,040; lisp: 1,918; makefile: 909; python: 611; ruby: 202
file content (79 lines) | stat: -rw-r--r-- 1,667 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef INCLUDED_RESOURCE_FILE_H
#define INCLUDED_RESOURCE_FILE_H

#include <vector>
#include <map>
#include <string>

/**
 * Generic resource file class
 */
class RESOURCE_FILE {

  std::string resfile_rep;
  mutable std::map<std::string,std::string> resmap_rep;
  std::vector<std::string> lines_rep;
  bool modified_rep;

 public:

  /**
   * Returns a vector of registered presets
   */
  std::vector<std::string> keywords(void) const;

  /**
   * Returns current resource file name.
   */
  const std::string& resource_file(void) const { return resfile_rep; }

  /**
   * Set resource file name.
   */
  void resource_file(const std::string& v) { resfile_rep = v; }

  /**
   * Returns value of resource 'tag'.
   */
  std::string resource(const std::string& tag) const;

  /**
   * Set resource 'tag' value to 'value'. If value wasn't 
   * previously defined, it's added.
   */
  void resource(const std::string& tag, const std::string& value);

  /**
   * Returns true if resource 'tag' is 'true', otherwise false
   */
  bool boolean_resource(const std::string& tag) const;
  
  /**
   * Whether resource 'tag' is specified in the resource file
   */
  bool has(const std::string& tag) const;

  /** 
   * Has any resource value been added, removed or modified?
   */
  bool is_modified(void) const { return modified_rep; }

  /**
   * Load/restore resources from file
   */
  void load(void);

  /**
   * Save/store resources to file saving
   */
  void save(void);

  /**
   * Constructor. Resource values are read, if
   * filename argument is given.
   */
  RESOURCE_FILE(const std::string& resource_file = "");
  virtual ~RESOURCE_FILE(void);
};

#endif