---
name: "WordContext"
section: "3"
platform: "linux"
package: "libmifluz0-dev"
version: "0.24.0-9"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/WordContext"
---

# WordContext(3)

read configuration and setup mifluz context.

## NAME

WordContext - read configuration and setup mifluz context.

## SYNOPSIS

```
#include <mifluz.h>
WordContext context;
```

## DESCRIPTION

The WordContext object must be the first object created. All other objects (WordList, WordReference, WordKey and WordRecord) are allocated via the corresponding methods of WordContext (List, Word, Key and Record respectively).

The WordContext object contains a **Configuration** object  that holds the configuration parameters used by the instance.  If a configuration parameter is changed, the *ReInitialize* method should be called to take them in account.

## CONFIGURATION

For more information on the configuration attributes and a complete list of attributes, see the [mifluz(3)](/mifluz/3.md) manual page.

- **wordlist\_monitor {true\|false} (default false)**

  If true create a *WordMonitor* instance to gather statistics and  build reports.

## METHODS

- **WordContext()**

  Constructor. Read the configuration parameters from the environment.  If the environment variable **MIFLUZ\_CONFIG** is set to a pathname, read it as a configuration file. If **MIFLUZ\_CONFIG** is not set, try to read the *~/.mifluz* configuration file or */usr/etc/mifluz.conf* manual page for a complete list of the configuration attributes.

- **WordContext(const Configuration &config)**

  Constructor. The **config** argument must contain all the configuration parameters, no configuration file is loaded from the environment.

- **WordContext(const ConfigDefaults \*array)**

  Constructor. The **array** argument holds configuration parameters that will override their equivalent in the configuration file read  from the environment.

- **void Initialize(const Configuration &config)**

  Initialize the WordContext object. This method is called by  every constructor.

  When calling **Initialize** a second time, one must ensure that all WordList and WordCursor objects have been destroyed. WordList and WordCursor internal state depends on the current WordContext that will be lost by a second call.

  For those interested by the internals, the **Initialize** function maintains a Berkeley DB environment (DB\_ENV) in the following way:

  First invocation:

  ```
  Initialize -> new DB_ENV (thru WordDBInfo)
  ```

  Second invocation:

  ```
  Initialize -> delete DB_ENV -> new DB_ENV (thru WordDBInfo)
  ```

- **int Initialize(const ConfigDefaults\* config\_defaults = 0)**

  Initialize the WordContext object. Build a *Configuration* object from the file pointed to by the  MIFLUZ\_CONFIG environment variable or ~/.mifluz or /usr/etc/mifluz.conf. The **config\_defaults** argument, if provided, is passed to the *Configuration* object using the **Defaults** method. The **Initialize(const Configuration &)** method is then called with the *Configuration* object. Return OK if success, NOTOK otherwise. Refer to the *Configuration* description for more information.

- **int ReInitialize()**

  Destroy internal state except the *Configuration* object and rebuild it. May be used when the configuration is changed to take these changes in account. Return OK if success, NOTOK otherwise.

- **const WordType& GetType() const**

  Return the **WordType** data member of the current object as a const.

- **WordType& GetType()**

  Return the **WordType** data member of the current object.

- **const WordKeyInfo& GetKeyInfo() const**

  Return the **WordKeyInfo** data member of the current object as a const.

- **WordKeyInfo& GetKeyInfo()**

  Return the **WordKeyInfo** data member of the current object.

- **const WordRecordInfo& GetRecordInfo() const**

  Return the **WordRecordInfo** data member of the current object as a const.

- **WordRecordInfo& GetRecordInfo()**

  Return the **WordRecordInfo** data member of the current object.

- **const WordDBInfo& GetDBInfo() const**

  Return the **WordDBInfo** data member of the current object as a const.

- **WordDBInfo& GetDBInfo()**

  Return the **WordDBInfo** data member of the current object.

- **const WordMonitor\* GetMonitor() const**

  Return the **WordMonitor** data member of the current object as a const.  The pointer may be NULL if the word\_monitor attribute is false.

- **WordMonitor\* GetMonitor()**

  Return the **WordMonitor** data member of the current object. The pointer may be NULL if the word\_monitor attribute is false.

- **const Configuration& GetConfiguration() const**

  Return the **Configuration** data member of the current object as a const.

- **Configuration& GetConfiguration()**

  Return the **Configuration** data member of the current object.

- **WordList\* List()**

  Return a new **WordList** object, using the  WordList(WordContext\*) constructor. It is the responsibility of the caller to delete this object before the WordContext object is deleted. Refer to the **wordlist\_multi** configuration parameter to know the exact type of the object created.

- **WordReference\* Word()**

  Return a new **WordReference** object, using the WordReference(WordContext\*) constructor. It is the responsibility of the caller to delete this object before the WordContext object is deleted.

- **WordReference\* Word(const String& key0, const String& record0)**

  Return a new **WordReference** object, using the WordReference(WordContext\*, const String&, const& String) constructor. It is the responsibility of the caller to delete this object before the WordContext object is deleted.

- **WordReference\* Word(const String& word)**

  Return a new **WordReference** object, using the WordReference(WordContext\*, const String&) constructor. It is the responsibility of the caller to delete this object before the WordContext object is deleted.

- **WordRecord\* Record()**

  Return a new **WordRecord** object, using the WordRecord(WordContext\*) constructor. It is the responsibility of the caller to delete this object before the WordContext object is deleted.

- **WordKey\* Key()**

  Return a new **WordKey** object, using the WordKey(WordContext\*) constructor. It is the responsibility of the caller to delete this object before the WordContext object is deleted.

- **WordKey\* Key(const String& word)**

  Return a new **WordKey** object, using the WordKey(WordContext\*, const String&) constructor. It is the responsibility of the caller to delete this object before the WordContext object is deleted.

- **WordKey\* Key(const WordKey& other)**

  Return a new **WordKey** object, using the WordKey(WordContext\*, const WordKey&) constructor. It is the responsibility of the caller to delete this object before the WordContext object is deleted.

- **static String ConfigFile()**

  Return the full pathname of the configuration file. The configuration file lookup first searches for the file pointed by the **MIFLUZ\_CONFIG** environment variable then **~/.mifluz** and finally **/usr/etc/mifluz.conf** return the empty string.

## ENVIRONMENT

**MIFLUZ\_CONFIG** file name of configuration file read by [WordContext(3)](/WordContext/3.md). Defaults to **~/.mifluz.** or **/usr/etc/mifluz.conf**

## AUTHORS

Loic Dachary loic@gnu.org

The Ht://Dig group http://dev.htdig.org/

## SEE ALSO

[htdb\_dump(1)](/htdb_dump/1.md), [htdb\_stat(1)](/htdb_stat/1.md), [htdb\_load(1)](/htdb_load/1.md), [mifluzdump(1)](/mifluzdump/1.md), [mifluzload(1)](/mifluzload/1.md), [mifluzsearch(1)](/mifluzsearch/1.md), [mifluzdict(1)](/mifluzdict/1.md), [WordList(3)](/WordList/3.md), [WordDict(3)](/WordDict/3.md), [WordListOne(3)](/WordListOne/3.md), [WordKey(3)](/WordKey/3.md), [WordKeyInfo(3)](/WordKeyInfo/3.md), [WordType(3)](/WordType/3.md), [WordDBInfo(3)](/WordDBInfo/3.md), [WordRecordInfo(3)](/WordRecordInfo/3.md), [WordRecord(3)](/WordRecord/3.md), [WordReference(3)](/WordReference/3.md), [WordCursor(3)](/WordCursor/3.md), [WordCursorOne(3)](/WordCursorOne/3.md), [WordMonitor(3)](/WordMonitor/3.md), [Configuration(3)](/Configuration/3.md), [mifluz(3)](/mifluz/3.md)
