Beispiel #1
0
void fxcharheap::replace(
  off_t id,               // input: heap offset
  const char* buf,        // input: string
  uint32_t start_offset,  // input: starting offset
  uint32_t len)           // input: length
{
  // check if we have enough room
  if (strlen(&data[id]) < len) {
    ioexception("insufficient space for replace");
  }
  try {
    memcpy(&data[id], &buf[start_offset], len);
    data[id+len] = 0;
  } catch (...) {
    ioexception("exception in memcpy");
  }
}
void ExceptionTest::testConstructor() {
	std::string mymessage = "the message";
	ims::Exception exception(mymessage);
	CPPUNIT_ASSERT_EQUAL(0, exception.message().compare(mymessage));

	ims::IOException ioexception(mymessage);
	CPPUNIT_ASSERT_EQUAL(0, ioexception.message().compare(mymessage));
}
Beispiel #3
0
void fxcharheap::get(
  off_t id,               // input: heap offset
  char* buf,              // output: buffer
  uint32_t output_offset, // input: output buffer offset
  uint32_t maxlen) const  // input: maximum output size, truncate 
{
  try {
    uint32_t len = (uint32_t)strlen(&data[id]);
    if (maxlen < len+1) len = maxlen-1;
    memcpy(&buf[output_offset], &data[id], len+1);  // include the trailing 0
  } catch (...) {
    ioexception("exception in memcpy"); 
  }
}
Beispiel #4
0
void fxcharheap::get0(
  long  id,               // input: heap offset
  char* buf,              // output: buffer
  uint32_t output_offset, // input: output buffer offset
  uint32_t maxlen) const  // input: maximum output size, truncate 
{
  try {
    uint32_t len = (uint32_t)strlen(&data[id]);
    if (len > (maxlen - 1)) len = maxlen-1;
    memcpy(&buf[output_offset], &data[id], len);
    buf [output_offset + len] = 0;
  } catch (...) {
    ioexception("exception in memcpy"); 
  }
}
Beispiel #5
0
off_t fxcharheap::put(    // return the target offset
  const char* buf,        // input: string
  uint32_t start_offset,  // input: starting offset
  uint32_t len)           // input: length 
{
  off_t id  = *offset_p;

  try {
    while (id+len+1 > fxary_p->get_eofoff()) expand();
    memcpy(&data[id], &buf[start_offset], len);
    data[id+len] = 0;
  } catch (...) {
    ioexception("exception in expanding before put()");
  }

  *offset_p += (len+1);
  return id;
}