WordReference3
Inverted index occurrence.
Usage
#include <WordReference.h>WordContext* context;WordReference* word = context->Word("word");WordReference* word = context->Word();WordReference* word = context->Word(WordKey("key 1 2"), WordRecord());WordKey key = word->Key()WordKey record = word->Record()word->Clear();delete word;
Overview
A WordReference object is an agregate of a WordKey object and a WordRecord object.
Although constructors may be used, the prefered way to create a WordReference object is by using the WordContext::Word method.
ASCII format
The ASCII description is a string with fields separated by tabs or white space. It is made of the ASCII description of a WordKey object immediately followed by the ASCII description of a WordRecord object. See the corresponding manual pages for more information.
Methods
- WordReference(WordContext* ncontext) :
-
Constructor. Build an object with empty key and empty record. The
ncontextargument must be a pointer to a valid WordContext object.
- WordReference(WordContext* ncontext, const String& key0, const String& record0) :
-
Constructor. Build an object from disk representation of
keyandrecordThencontextargument must be a pointer to a valid WordContext object.
- WordReference(WordContext* ncontext, const String& word) :
-
Constructor. Build an object with key word set to
wordand otherwise empty and empty record. Thencontextargument must be a pointer to a valid WordContext object.
- void Clear()
-
Reset to empty key and record
- inline WordContext* GetContext()
-
Return a pointer to the WordContext object used to create this instance.
- inline const WordContext* GetContext() const
-
Return a pointer to the WordContext object used to create this instance as a const.
- inline String& GetWord()
-
Return the
worddata member.
- inline const String& GetWord() const
-
Return the
worddata member as a const.
- inline void SetWord(const String& nword)
-
Set the
worddata member from thenwordargument.
- WordKey& Key()
-
Return the key object.
- const WordKey& Key() const
-
Return the key object as const.
- WordRecord& Record()
-
Return the record object.
- const WordRecord& Record() const
-
Return the record object as const.
- void Key(const WordKey& arg)
-
Copy
argin the key part of the object.
- int KeyUnpack(const String& packed)
-
Set key structure from disk storage format as found in
packedstring. Return OK if successfull, NOTOK otherwise.
- String KeyPack() const
-
Convert key object into disk storage format as found in return the resulting string.
- int KeyPack(String& packed) const
-
Convert key object into disk storage format as found in and place the result in
packedstring. Return OK if successfull, NOTOK otherwise.
- void Record(const WordRecord& arg)
-
Copy
argin the record part of the object.
- int RecordUnpack(const String& packed)
-
Set record structure from disk storage format as found in
packedstring. Return OK if successfull, NOTOK otherwise.
- String RecordPack() const
-
Convert record object into disk storage format as found in return the resulting string.
- int RecordPack(String& packed) const
-
Convert record object into disk storage format as found in and place the result in
packedstring. Return OK if successfull, NOTOK otherwise.
- inline int Pack(String& ckey, String& crecord) const
-
Short hand for KeyPack(
ckey) RecordPack(crecord).
- int Unpack(const String& ckey, const String& crecord)
-
Short hand for KeyUnpack(
ckey) RecordUnpack(crecord).
- int Merge(const WordReference& other)
-
Merge key with other.Key() using the WordKey::Merge method: key.Merge(other.Key()). See the corresponding manual page for details. Copy other.record into the record part of the object.
- static WordReference Merge(const WordReference& master, const WordReference& slave)
-
Copy
masterbefore merging withmaster.Merge(slave) and return the copy. Prevents alteration ofmaster
- int Set(const String& bufferin)
-
Set the whole structure from ASCII string in
bufferinSee ASCII FORMAT section. Return OK if successfull, NOTOK otherwise.
- int Get(String& bufferout) const
-
Convert the whole structure to an ASCII string description in
bufferout.See ASCII FORMAT section. Return OK if successfull, NOTOK otherwise.
- String Get() const
-
Convert the whole structure to an ASCII string description and return it. See ASCII FORMAT section.
- int Write(FILE* f) const
-
Print object in ASCII form on
f(uses Get method). See ASCII FORMAT section.
- void Print() const
-
Print object in ASCII form on
stdout(uses Get method). See ASCII FORMAT section.
Releases
2 releases since Debian 3.0 (Woody); the text changed 1 time.