hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SphinxMatchInfo.hpp
Go to the documentation of this file.
1 
14 #ifndef SPHINX_MATCH_INFO_HPP
15 #define SPHINX_MATCH_INFO_HPP
16 
17 #include <vector>
18 
19 #include "SphinxResultDataItem.hpp"
20 
21 namespace HCE
22 {
23 namespace sphinx
24 {
25 //-----------------------------------------------------------------------------
26 struct AttrInfo
27 {
28  AttrInfo(void) : name(""), value("") {}
29  AttrInfo(const std::string& name_, const std::string& value_) : name(name_), value(value_) {}
30  AttrInfo(const AttrInfo& rhs);
31  AttrInfo(AttrInfo&& rhs);
32 
33  AttrInfo& operator=(const AttrInfo& rhs);
34  AttrInfo& operator=(AttrInfo&& rhs);
35 
36  std::string name;
37  std::string value;
38 };
39 //-----------------------------------------------------------------------------
41 {
42  enum {STRING_LENGTH=20};
43 public:
44  SphinxMatchInfo(void);
45  explicit SphinxMatchInfo(size_t attributesCount);
46  SphinxMatchInfo(const SphinxMatchInfo& rhs);
49 
52 
53  void setDocId(unsigned long long docId_) {docId = docId_;}
54  unsigned long long getDocId(void) const {return docId;}
55 private:
56  void setWeight(const std::string& weight_) {weight = weight_;}
57 public:
58  std::string getWeight(void) const {return weight;}
59  void setWeightFromNumeric(unsigned long long weight, unsigned long long length= STRING_LENGTH);
60  void setWeightFromHexString(const std::string& weight);
61  void setWeightFromDecString(const std::string& weight, unsigned long long length=STRING_LENGTH);
62 
63  void addAttrInfo(const AttrInfo& attrInfo);
64  void addAttrInfo(AttrInfo&& attrInfo);
65  void addAttrInfo(const std::string& name, const std::string& value);
66 
67  const std::vector<SphinxResultDataItem<AttrInfo> >& getAttributes(void) const {return attributes;}
68  const AttrInfo getFieldByName(const std::string& attrName) const;
69 
70  size_t getAttributesCount(void) const;
71  const AttrInfo& getAttrItem(size_t index) const;
72  void setAttrItem(size_t index, const AttrInfo& attr);
73  void setAttrItem(size_t index, AttrInfo&& attr);
74 
75  void clear(void);
76  void reset(void);
77  void resize(size_t sz);
78 private:
79  unsigned long long docId;
80  std::string weight;
81  std::vector<SphinxResultDataItem<AttrInfo> > attributes;
82 
86 };
87 //-----------------------------------------------------------------------------
88 //-----------------------------------------------------------------------------
89 } // namespace sphinx
90 } // namespace HCE
91 
92 #endif // SPHINX_MATCH_INFO_HPP