3 #include <mtld/common.h> 5 #define DA_CONTEXT_HAS_REFINE 1 6 #define API_MAJOR_VERSION 2 7 #define API_MINOR_VERSION 3 8 #define API_REVISION_VERSION 0 14 namespace Mobi {
namespace Mtld {
namespace Da {
66 bool include_ua_props;
67 bool include_lang_props;
68 bool include_matched_props;
70 : include_ua_props(
true)
71 , include_lang_props(
true)
72 , include_matched_props(
false) {}
73 DaConfig(
bool include_ua_props_,
bool include_lang_props_,
74 bool include_matched_props_)
75 : include_ua_props(include_ua_props_)
76 , include_lang_props(include_lang_props_)
77 , include_matched_props(include_matched_props_) {}
80 DA_EXPORT
extern const char *languageHeader;
81 DA_EXPORT
extern const char *defaultHeaderTreePriorities[];
90 std::string evidence[TREEID_MAX];
91 std::string userlanguage;
93 size_t uajsontreewalk;
94 HttpHeaders(
const char *userAgent,
const char *acceptLanguage = 0);
95 HttpHeaders(
const HeaderMap & headers,
const char ***priorities = defaultHeaderPriorities);
103 typedef std::map<LangID, std::vector<REInfo *> > TaggedRegexMap;
104 typedef std::map<size_t, std::string> ResetWalkMap;
108 friend class ReplacementStringParser;
121 const std::vector<REInfo *> *languageReplacementStrings;
125 TaggedRegexMap replacementStrings;
126 ResetWalkMap resetWalkStrings;
128 vector<string> stockUaFromTree;
130 void initAtlas(std::istream &,
const char *[]);
132 void resetPriorities();
135 const Property *getpropId()
const {
return propid; }
137 Node *roots[TREEID_MAX];
144 void doReplacements(
const std::vector<size_t> *,
char *,
size_t)
const;
151 size_t _user_agent_matched;
152 size_t _user_agent_unmatched;
154 size_t _language_locale;
158 void setConfig(
DaConfig &_dcfg) { dcfg = _dcfg; }
159 bool hasUAProps()
const {
return dcfg.include_ua_props ==
true; }
160 bool hasLangProps()
const {
return dcfg.include_lang_props ==
true; }
161 bool hasMatchedProps()
const {
return dcfg.include_matched_props ==
true; }
163 const UAR *getUAR()
const {
return uar; }
164 const CPR *getCPR()
const {
return cpr; }
173 static const char *treeUA[];
174 static const char *treeAll[];
175 static const char **getTreeUA();
176 static const char **getTreeAll();
181 , OverwriteUnconflicted = 1 << 2
184 DeviceAtlas(DaConfig &_dcfg) : CommonDeviceAtlas(), cpr(0), uar(0), dcfg(_dcfg) { resetRoots(); }
192 DeviceAtlas(std::istream &,
const char *treeFields[] = getTreeUA(),
unsigned long flags = 0);
198 void loadDataFromFile(
const char *,
const char *treeFields[] = getTreeUA(),
unsigned long flags = 0);
203 void loadDataFromStream(std::istream &,
const char *treeFields[] = getTreeUA(),
unsigned long flags = 0);
204 const Value *getValue(
size_t)
const;
205 const std::string &getResetWalkString(
size_t)
const;
210 int getTreeRevision()
const;
211 time_t getTreeGeneration()
const;
212 int getDataRevision()
const {
return getTreeRevision(); }
213 time_t getDataGeneration()
const {
return getTreeGeneration(); }
216 class LocalProperties;
224 Value user_agent_matched;
225 Value user_agent_unmatched;
247 unsigned conflictCount;
252 void getRulesetWithProps(
const char *&uastrng);
253 void getRuleset(
const char *&uastrng);
254 void runRules(
const char *txt,
const RuleSet &rules);
262 const Property &getPropertyDescr(
const char *propname, PropertyType *addAs);
263 const Property &getPropertyDescr(
size_t idx)
const;
265 void setProperty(
size_t,
const Value *);
267 const Value *findProperty(
size_t)
const;
272 void refine(
const std::vector<const Value *> &clientprops);
275 void refine(
const char *cookieprops);
276 const Value *findGlobalProperty(
size_t)
const;
277 const Value *findLocalProperty(
size_t)
const;
283 typedef std::pair<const Property *, const Value *> PVPair;
292 const PVPair operator * ()
const;
293 const PVPair *operator -> ();
300 bool operator()(
const Node &cur,
char *str,
size_t offset);
307 size_t totalsize()
const;
310 const Value *operator[](
const char *propname)
const;
Definition: dajson.cpp:595
Definition: devatlas.h:105
Definition: devatlas.h:56
Definition: devatlas_priv.h:531
Definition: dajson.cpp:244
Definition: devatlas.h:281
Definition: dajson.cpp:612
Definition: devatlas_priv.h:85
Definition: dajson.cpp:628
Definition: dajson.cpp:460
Definition: dajson.cpp:339
Definition: devatlas_priv.h:16
Definition: dajson.cpp:564
Definition: dajson.cpp:174
Definition: devatlas_priv.h:254
Definition: dajson.cpp:198
Definition: devatlas_priv.h:273
Definition: devatlas.h:218
Definition: devatlas_priv.h:262
Definition: devatlas.h:65
Definition: dajson.cpp:497
Definition: dajson.cpp:536