Class SimpleZDB::DataBase
In: simplezdb.cpp
Parent: Object

Wrapper of SlZDataBase class.

Usage

  require 'simpleZDB'
  include SimpleZDB
  db = DataBase.new(DataBase::ADDRESSBOOK)
  # ... typically use sort or filter method here ...
  db.each do |card|
     #  write "break if ..." in order to abort the loop
     puts card.card_id
     puts card['FULL']
  end
  db.close

Otherwise,

  require 'simpleZDB'
  include SimpleZDB
  DataBase.open(DataBase::ADDRESSBOOK) do |db|
    # ...
  end

Methods

Included Modules

Enumerable

Attributes

class_of_card  [RW] 
item_info  [R] 

Public Class methods

Document-method: SimpleZDB::DataBase#initialize

Open the database and return the DataBase object. Possible values of database_type are:

  DataBase::ADDRESSBOOK
  DataBase::TODOLIST
  DataBase::DATEBOOK
  DataBase::MAIL_INBOX
  DataBase::MAIL_OUTBOX
  DataBase::MEMO

The third argument, class_of_card is used by DataBase#each method in order to create an object as the block argument. Normally it is SimpleZDB::Card or its subclass. This class is expected that it has a constructor called with two arguments, database and card_id.

Open the database (again). Notice: when DataBase instance is created, database is already opened.

Public Instance methods

(Normally not used directly. Called from Card.) Cancel editing the card.

(Normally not used directly. Called from Card.) Delete the card.

Wrapper of SlZDataManager::disableFilter(bool)

Document-method: SimpleZDB::DataBase#each

the class of the block argument is determined by the instance variable @class_of_card, which can be accessed by database.class_of_card method. Normally it is SimpleZDB::Card.

Wrapper of SlZDataManager::enableFilter(CategoryId).

Wrapper of SlZDataManager::filter(const char*, ulong, const char*, ulong, FilterFor, bool = false). search_exp and sort_exp are undocumented. Possible filter_mode values are:

  DataBase::FOR_CURRENT_INDEX
  DataBase::FOR_MASTER_INDEX
  DataBase::FOR_SUSPENDED_INDEX

Document-method: is_filtered, filtered?

Wrapper of SlZDataManager::isFiltered().

(Normally not used directly. Called from Card.) Finish editing the card. You should call this after writing items. Return the new card_id.

Document-method: is_filtered, filtered?

Wrapper of SlZDataManager::isFiltered().

Document-method: is_opened, opened?

Ask if the database is opened.

Wrapper of SlZDataManager::killIdxResume().

Open the database (again). Notice: when DataBase instance is created, database is already opened.

Document-method: is_opened, opened?

Ask if the database is opened.

(Normally not used directly. Called from DataBase#read_item.) Return the categories of the card card_id.

(Normally not used directly. Called from Card#[]) Return the value specified by key of the card card_id.

(Normally not used directly. Called from DataBase#read_item.) Return the date/time value specified by the field (i.e., return value of ItemInfo#field(name)) of the card card_id.

Wrapper of SlZDataManager::search(CardId*, const char*, bool, uchar, uchar, uchar, const char*) and SlZDataManager::search(CardId*, const char*, bool, const char*). The format of cond is undocumented.

Wrapper of SlZDataBase::searchField(CardId*, QString, int, uchar, bool). Valid search_mode values are undocumented.

Sort cards by key. This method affects the result of each. If key is invalid, do nothing. If key is nil, sort by the default index. If key responds to to_exp, call implicitly sort_exp!(key.to_exp). (see SimpleZDB::SortKey class). Otherwise, sort by the named key. Throw RuntimeError when sort failed.

Wrapper of SlZDataManager::sort(const char*, int, bool). The format of exp is undocumented. If failed, raise runtime error.

(Normally not used directly. Called from Card.) Start editing the card. You should call this before writing items.

Wrapper of SlZDataManager::unfilter(bool = true). If failed, raise runtime error.

(Normally not used directly. Called from Card.) Update the categories off the current card. If any one of the categories does not exist in the CategorySet, add it.

(Normally not used directly. Called from Card#save.) Write the value specified by the key of the current card.

(Normally not used directly. Called from DataBase#write_item) Write the date/time value specified by the field (i.e., return value of the ItemInfo#field(key)) of the current card.

[Validate]