Logo Search packages:      
Sourcecode: qdbm version File versions  Download package

char * Villa::get ( const char *  kbuf,
int  ksiz,
int *  sp = 0 
) throw (Villa_error) [virtual]

Retrieve a record.

Parameters:
kbuf the pointer to the region of a key.
ksiz the size of the region of the key. If it is negative, the size is assigned with `stdstrlen(kbuf)'.
sp the pointer to a variable to which the size of the region of the return value is assigned. If it is 0, it is not used.
Returns:
the pointer to the region of the value of the corresponding record.
Exceptions:
Villa_error if an error occurs or no record corresponds.
Note:
When the key of duplicated records is specified, the value of the first record of the same key is selected. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `stdmalloc' call, it should be released with the `stdfree' call if it is no longer in use.

Definition at line 244 of file xvilla.cc.

References qdbm::mutex, and villa.

                                                                      {
  char* vbuf;
  if(!villa) throw Villa_error();
  if(pthread_mutex_lock(&mutex) != 0) throw Villa_error();
  if(!(vbuf = vlget(villa, kbuf, ksiz, sp))){
    pthread_mutex_unlock(&mutex);
    throw Villa_error(dpecode);
  }
  pthread_mutex_unlock(&mutex);
  return vbuf;
}


Generated by  Doxygen 1.6.0   Back to index