Newer
Older
ubixfs-2 / btree_key.cpp
#include "btree_key.h"
#include "btypes.h"
#include <string.h>

int 
compareKeyNull(void *, void *) {
  return 0;
} // compareKeyNull

int 
compareKeyString(void * , void * ) { 
  return 0;
} // compareKeyString

int 
compareKeyPChar(void * key1, void * key2) {
  return strcmp((char *)key1, (char *)key2);
} // compareKeyPChar

int 
compareKeySingle(void * , void * ) {
  return 0;
} // compareKeySingle

int 
compareKeyDouble(void * , void * ) {
  return 0;
} // compareKeyDouble

int 
compareKeyInt32(void * , void * ) {
  return 0;
} // compareKeyInt32

int 
compareKeyInt64(void * , void * ) {
  return 0;
} // compareKeyInt64

/*
 *  CopyKey functions
 */

void 
copyKeyNull(void *, void *) {
  return;
} // copyKeyNull

void 
copyKeyString(void *, void *) {

} // copyKeyString

void 
copyKeyPChar(void *, void *) {
  
} // copyKeyPChar

void 
copyKeySingle(void * srcKey, void * destKey) {
  if ((srcKey == NULL) || (destKey == NULL)) return;
  *(float *)destKey = *(float *)srcKey;
} // copyKeySingle

void 
copyKeyDouble(void * srcKey, void * destKey) {
  if ((srcKey == NULL) || (destKey == NULL)) return;
  *(double *)destKey = *(double *)srcKey;
} // copyKeyDouble

void 
copyKeyInt32(void * srcKey, void * destKey) {
  if ((srcKey == NULL) || (destKey == NULL)) return;
  *(int32 *)destKey = *(int32 *)srcKey;
} // copyKeyInt32

void 
copyKeyInt64(void * srcKey, void * destKey) {
  if ((srcKey == NULL) || (destKey == NULL)) return;
  *(int64 *)destKey = *(int64 *)srcKey;
} // copyKeyInt64

/* 
 *  KeySize functions
 */

int 
keySizeNull(void *) {
  return 0;
} // keySizeNull

int 
keySizeString(void * key) {
  const char * charKey = static_cast<const char *>(key);
  if (charKey == NULL) return 0;
  return ((int)charKey[0]+1);
} // keySizeString

int 
keySizePChar(void * key) {
  const char * charKey = static_cast<const char *>(key);
  if (charKey == NULL) return 0;
  return (strlen(charKey)+1);
} // keySizePChar

int 
keySizeSingle(void *) {
  return sizeof(float);
} // keySizeSingle

int 
keySizeDouble(void *) {
  return sizeof(double);
}

int 
keySizeInt32(void *) {
  return sizeof(int32);
}

int 
keySizeInt64(void *) {
  return sizeof(int64); 
}