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 chevidence[TREEID_MAX];
92 std::string userlanguage;
94 size_t uajsontreewalk;
97 HttpHeaders(
const char *userAgent,
const char *acceptLanguage = 0);
98 HttpHeaders(
const HeaderMap & headers,
const char ***priorities = defaultHeaderPriorities);
106 using TaggedRegexMap = std::map<LangID, std::vector<REInfo *> >;
107 using ResetWalkMap = std::unordered_map<size_t, std::string>;
111 friend class ReplacementStringParser;
124 const std::vector<REInfo *> *languageReplacementStrings;
126 std::shared_ptr<CPR> cpr;
132 TaggedRegexMap replacementStrings;
133 ResetWalkMap resetWalkStrings;
135 vector<string> stockUaFromTree;
137 void initAtlas(std::istream &,
const char *[]);
139 void resetPriorities();
142 const Property *getpropId()
const {
return propid; }
143 const Property *getpropOname()
const {
return proponame; }
144 const Property *getpropOversion()
const {
return propoversion; }
145 const Property *getpropOversionNm()
const {
return propoversionnm; }
146 const Property *getpropIsbw()
const {
return propisbw; }
148 Node *roots[TREEID_MAX];
152 std::shared_ptr<UAR> uar;
155 void doReplacements(
const std::vector<size_t> *,
char *,
size_t)
const;
162 size_t _user_agent_matched;
163 size_t _user_agent_unmatched;
165 size_t _language_locale;
169 void setConfig(
DaConfig &_dcfg) { dcfg = _dcfg; }
170 bool hasUAProps()
const {
return dcfg.include_ua_props ==
true; }
171 bool hasLangProps()
const {
return dcfg.include_lang_props ==
true; }
172 bool hasMatchedProps()
const {
return dcfg.include_matched_props ==
true; }
174 const std::shared_ptr<UAR> getUAR()
const {
return uar; }
175 const std::shared_ptr<CPR> getCPR()
const {
return cpr; }
184 static const char *treeUA[];
185 static const char *treeAll[];
186 static const char **getTreeUA();
187 static const char **getTreeAll();
192 , OverwriteUnconflicted = 1 << 2
195 DeviceAtlas(DaConfig &_dcfg) : CommonDeviceAtlas(), propid(0), dcfg(_dcfg) { resetRoots(); }
203 DeviceAtlas(std::istream &,
const char *treeFields[] = getTreeUA(),
unsigned long flags = 0);
209 void loadDataFromFile(
const char *,
const char *treeFields[] = getTreeUA(),
unsigned long flags = 0);
214 void loadDataFromStream(std::istream &,
const char *treeFields[] = getTreeUA(),
unsigned long flags = 0);
215 const Value *getValue(
size_t)
const;
216 const std::string &getResetWalkString(
size_t)
const;
221 int getTreeRevision()
const;
222 time_t getTreeGeneration()
const;
223 int getDataRevision()
const {
return getTreeRevision(); }
224 time_t getDataGeneration()
const {
return getTreeGeneration(); }
227 class LocalProperties;
235 Value user_agent_matched;
236 Value user_agent_unmatched;
259 unsigned conflictCount;
264 void getRulesetWithProps(
const char *&uastrng);
265 void getRuleset(
const char *&uastrng);
266 void runRules(
const char *txt,
const RuleSet &rules);
275 std::vector<size_t> *rfskp;
277 const Property &getPropertyDescr(
const char *propname, PropertyType *addAs);
278 const Property &getPropertyDescr(
size_t idx)
const;
280 void setProperty(
size_t,
const Value *);
282 const Value *findProperty(
size_t)
const;
287 void refine(
const std::vector<const Value *> &clientprops);
290 void refine(
const char *cookieprops);
291 const Value *findGlobalProperty(
size_t)
const;
292 const Value *findLocalProperty(
size_t)
const;
298 typedef std::pair<const Property *, const Value *> PVPair;
307 const PVPair operator * ()
const;
308 const PVPair *operator -> ();
315 bool operator()(
const Node &cur,
char *str,
size_t offset);
322 size_t totalsize()
const;
325 const Value *operator[](
const char *propname)
const;
Definition: dajson.cpp:597
Definition: devatlas.h:108
Definition: devatlas.h:56
Definition: dajson.cpp:244
Definition: devatlas.h:296
Definition: dajson.cpp:613
Definition: devatlas_priv.h:85
Definition: dajson.cpp:629
Definition: dajson.cpp:463
Definition: dajson.cpp:342
Definition: devatlas_priv.h:16
Definition: dajson.cpp:566
Definition: dajson.cpp:174
Definition: devatlas_priv.h:261
Definition: dajson.cpp:198
Definition: devatlas.h:229
Definition: devatlas_priv.h:269
Definition: devatlas.h:65
Definition: dajson.cpp:499
Definition: dajson.cpp:538