casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
casacore::Copy_global_functions_throw Struct Reference

Copy objects from one C-style array to another. More...

#include <Copy.h>

Public Member Functions

void objthrowmv1 (const void *to, const void *from, const size_t n)
 Throw the various AipsErrors when incorrect arguments used. More...
 
void objthrowmv2 (const void *to, const void *from, const size_t n, const size_t toStride, const size_t fromStride)
 
void objthrowcp1 (const void *to, const void *from, const size_t n)
 
void objthrowcp2 (const void *to, const void *from, const size_t n, const size_t toStride, const size_t fromStride)
 
void objthrowfl1 (const void *to, const size_t n)
 
void objthrowfl2 (const void *to, const size_t n, const size_t toStride)
 

Detailed Description

Copy objects from one C-style array to another.

Intended use:

Public interface

Review Status

Reviewed By:
Friso Olnon
Date Reviewed:
1995/03/14
Test programs:
tCopy

Synopsis

Objset is used to fill a C-style array of objects.

Objcopy and objmove are used to copy objects from one place to another. Optionally a stride can be supplied.

The functions are equivalent to C's memcpy and memmove. When possible C++ standard library functions are used to implement them

Similar to memcpy and memmove, the difference between objcopy and objmove is that objmove takes account of an overlap of source and destination. In general, objcopy is slighty (but only slighty) faster.

Example

Setting and copying arrays of built-in types:

// Create int array of 4 elements
size_t size=4;
int* ia = new int[size];
// Initialize all elements to value 99
objset(ia, 99, size);
// Change all odd elements to 66 -> [99 66 99 66]
objset(ia+1, 66, 5, 2);
// Create another 4-element int array
int* ia2 = new int[size];
// Copy array ia into array ia2 -> [99 66 99 66]
objmove(ia2, ia, size);
// Copy the even elements of ia to the odd elements of ia2
// -> [99 99 99 99]
objcopy(ia2+1, ia, size/2, 2, 2);

Setting and copying arrays of a randomly chosen type:

// Create 4-element array of 3-element Block<int> objects
size_t size=4;
Block<int>* ta = new Block<int>[size];
Block<int> set(3);
// Initialize the array -> [[123][123][123][123]]
set[0] = 1; set[1] = 2; set[2] = 3;
objset(ta, set, size);
// Change odd Blocks to [777]-> [[123][777][123][777]]
set[0] = set[1] = set[2] = 7;
objset(ta + 1, set, size/2, 2);
// Create another Block<int> array
Block<int>* ta2 = new Block<int>[size];
// Copy the even elements of ta to the first elements of ta2
// -> [[123][123]...]
objcopy(ta2, ta, size/2, 1, 2);

Definition at line 105 of file Copy.h.

Member Function Documentation

void casacore::Copy_global_functions_throw::objthrowcp1 ( const void *  to,
const void *  from,
const size_t  n 
)
void casacore::Copy_global_functions_throw::objthrowcp2 ( const void *  to,
const void *  from,
const size_t  n,
const size_t  toStride,
const size_t  fromStride 
)
void casacore::Copy_global_functions_throw::objthrowfl1 ( const void *  to,
const size_t  n 
)
void casacore::Copy_global_functions_throw::objthrowfl2 ( const void *  to,
const size_t  n,
const size_t  toStride 
)
void casacore::Copy_global_functions_throw::objthrowmv1 ( const void *  to,
const void *  from,
const size_t  n 
)

Throw the various AipsErrors when incorrect arguments used.

void casacore::Copy_global_functions_throw::objthrowmv2 ( const void *  to,
const void *  from,
const size_t  n,
const size_t  toStride,
const size_t  fromStride 
)

The documentation for this struct was generated from the following file: