iFun Engine API  1.0.0-b2821
Great Technology for Great Games
 All Classes Files Functions Variables Typedefs Macros
argument_map.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 iFunFactory Inc. All Rights Reserved.
2 //
3 // This work is confidential and proprietary to iFunFactory Inc. and
4 // must not be used, disclosed, copied, or distributed without the prior
5 // consent of iFunFactory Inc.
6 
9 #ifndef INCLUDE_FUNAPI_FRAMEWORK_ARGUMENT_MAP_H_
10 #define INCLUDE_FUNAPI_FRAMEWORK_ARGUMENT_MAP_H_
11 
12 #include <funapi/common/json.h>
13 #include <funapi/types.h>
14 
15 #include <map>
16 #include <vector>
17 
18 
19 namespace fun {
20 
23 class ArgumentMap {
24  public:
26  typedef std::vector<Json> OverrideHistory;
27 
29  typedef std::map<string, OverrideHistory> Container;
30 
33  static bool IsValidArgumentType(const Json::Type &value_type);
34 
42  bool AddArgument(const string &key, const Json &value);
43 
52  bool OverrideArgument(const string &key, const Json &value);
53 
58  const Json &FindArgument(const string &key) const;
59 
64  const OverrideHistory &FindArgumentOverrideHistory(const string &key) const;
65 
70  string FindStringArgument(const string &key) const;
71 
76  int64_t FindIntegerArgument(const string &key) const;
77 
82  double FindDoubleArgument(const string &key) const;
83 
88  bool FindBooleanArgument(const string &key) const;
89 
94  const Json &FindArrayArgument(const string &key) const;
95 
101  const Json &FindObjectArgument(const string &key) const;
102 
106  const Container &GetArgumentsAll() const;
107 
108  private:
109  Container arguments_;
110 };
111 
112 } // namespace fun
113 
114 #endif // INCLUDE_FUNAPI_FRAMEWORK_ARGUMENT_MAP_H_
std::vector< Json > OverrideHistory
Internal implementation of argument's override history.
Definition: argument_map.h:26
const Container & GetArgumentsAll() const
Retrieves whole argument map.
double FindDoubleArgument(const string &key) const
Retrieves an argument value in double type for the given argument key.
ArgumentMap class manages application-specific run-time arguments.
Definition: argument_map.h:23
const Json & FindObjectArgument(const string &key) const
Retrieves an argument value in json object type for the given argument key.
std::map< string, OverrideHistory > Container
Internal implementation of ArgumentMap class.
Definition: argument_map.h:29
bool OverrideArgument(const string &key, const Json &value)
Overrides argument with the given value if the argument exists, inserts argument otherwise.
const OverrideHistory & FindArgumentOverrideHistory(const string &key) const
Retrieves an argument override history for the given argument key.
string FindStringArgument(const string &key) const
Retrieves an argument value in string type for the given argument key.
const Json & FindArrayArgument(const string &key) const
Retrieves an argument value in json array type for the given argument key.
static bool IsValidArgumentType(const Json::Type &value_type)
Definition: json.h:27
bool AddArgument(const string &key, const Json &value)
Adds an argument.
int64_t FindIntegerArgument(const string &key) const
Retrieves an argument value in integer type for the given argument key.
const Json & FindArgument(const string &key) const
Retrieves an argument value in json type for the given argument key.
bool FindBooleanArgument(const string &key) const
Retrieves an argument value in boolean type for the given argument key.