00001 /* Copyright (C) 2010 webis.de 00002 * All rights reserved. 00003 */ 00004 #ifndef AITOOLS_INVERTEDINDEX_STRING_STRING_HPP 00005 #define AITOOLS_INVERTEDINDEX_STRING_STRING_HPP 00006 00007 #include "Value.hpp" 00008 #include <iostream> 00009 00010 namespace aitools { 00011 namespace invertedindex { 00012 00020 class StringString : public Value { 00021 00022 private: // nested types 00023 00024 typedef uint16_t string_size; 00025 00026 public: // class data 00027 00028 static const std::string classname; 00029 00030 private: // class data 00031 00032 static const size_t sizeof_string_size = sizeof(string_size); 00033 00034 public: // c'tor / d'tor 00035 00039 StringString(); 00040 00044 StringString(const std::string& e1, const std::string& e2); 00045 00049 StringString(const StringString& pair); 00050 00054 virtual ~StringString(); 00055 00056 public: // member 00057 00058 void clear(); 00059 00060 bool operator==(const StringString& pair) const; 00061 00062 bool operator!=(const StringString& pair) const; 00063 00064 bool operator>(const StringString& pair) const; 00065 00066 bool operator<(const StringString& pair) const; 00067 00068 void parse(std::istream& is); 00069 00070 void print(std::ostream& os) const; 00071 00072 double score() const; 00073 00074 std::string& e1(); 00075 00076 const std::string& e1() const; 00077 00078 std::string& e2(); 00079 00080 const std::string& e2() const; 00081 00082 void to_bytes(ByteBuffer& buffer) const; 00083 00084 void wrap(const char* data, size_t size); 00085 00086 void wrap(const ByteBuffer& buffer); 00087 00088 private: // member 00089 00090 std::string e1_; 00091 std::string e2_; 00092 string_size len_; 00093 00094 }; 00095 00096 } // namespace invertedindex 00097 } // namespace aitools 00098 00099 #endif // AITOOLS_INVERTEDINDEX_STRING_STRING_HPP