Pointwise Plugin SDK
Macros
apiUtils.h File Reference

Base plugin utilities. More...

#include <cassert>
#include "site.h"
+ Include dependency graph for apiUtils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ARRAYSIZE(arrname)   (PWP_UINT32)(sizeof(arrname)/sizeof(arrname[0]))
 Calculates the size of a statically declared array. More...
 
#define ASSERT(expr)   ((void)0)
 Run time assert macro. More...
 
#define ASSERT_COMPILE(x)   extern char __dummy[-1 + (2 * (int)(x))]
 Compile time assert macro. More...
 
#define MAKEGUID(usr_id)   MAKEGUID2(PWP_SITE_GROUPID,usr_id)
 Builds a 32-bit Globally Unique Id (GUID). More...
 
#define MAKEGUID2(hi16, low16)
 Builds a 32-bit id value. More...
 
#define PWP_GROUPNAME_DEFAULT   "PWP_SITE_GROUPNAME"
 The default site group name. More...
 
#define PWP_GRPID_USER   (PWP_UINT32)(63000UL)
 The first group id value available for local, internal use. More...
 
#define VERIFY_EXPLICIT_CAST(from, to)   ASSERT_COMPILE(sizeof(from) == sizeof(to))
 Helper macro that verifies the sizes of two objects are the same. More...
 

Detailed Description

Base plugin utilities.

Defines a set of helper/utility macros useful to all plugins.

Definition in file apiUtils.h.

Macro Definition Documentation

◆ ARRAYSIZE

#define ARRAYSIZE (   arrname)    (PWP_UINT32)(sizeof(arrname)/sizeof(arrname[0]))

Calculates the size of a statically declared array.

Note
The array MUST be statically declared in the scope where this macro is used.
Sample GOOD usage:
static int globalArray[22];
void func()
{
// globalArray is still in scope here
// hence, sz == 22
int sz = ARRAYSIZE(globalArray);
}
Sample BAD usage:
void func()
{
int localArray[22];
func2(localArray);
}
void func2(int *array)
{
// localArray is NOT in scope here
// hence, sz != 22
int sz = ARRAYSIZE(array);
}

Definition at line 166 of file apiUtils.h.

◆ ASSERT

#define ASSERT (   expr)    ((void)0)

Run time assert macro.

In debug builds, this macro forces a run time fail if expr is FALSE. In release builds, this macro does nothing.

It works for both C and C++ compilations.

Usage:
int var1 = 11;
int var2 = 22;
ASSERT(var1 == 11); // runtime okay
ASSERT(var1 == var2); // runtime fail
ASSERT(0 == "Prints this message"); // runtime fail
See also
VERIFY_EXPLICIT_CAST, ASSERT_COMPILE

Definition at line 194 of file apiUtils.h.

◆ ASSERT_COMPILE

#define ASSERT_COMPILE (   x)    extern char __dummy[-1 + (2 * (int)(x))]

Compile time assert macro.

This macro forces a compile time fail if const_expr is FALSE.

It only works if const_expr is a constant expression that can be evaluated at compile time.

It works for both C and C++ compilations.

Usage:
int var1 = 11;
int var2 = 22;
char arr1[] = "Hello";
char arr2[] = "Goodbye";
ASSERT_COMPILE(sizeof(var1) == sizeof(var2)); // compile continues
ASSERT_COMPILE(sizeof(arr1) == sizeof(arr2)); // compile fails
See also
C/C++ Compile Time Asserts (http://goo.gl/NAtdMI), ASSERT, VERIFY_EXPLICIT_CAST

Definition at line 236 of file apiUtils.h.

Referenced by pwpFileGetSize().

◆ MAKEGUID

#define MAKEGUID (   usr_id)    MAKEGUID2(PWP_SITE_GROUPID,usr_id)

Builds a 32-bit Globally Unique Id (GUID).

This macro uses the PWP_SITE_GROUPID for the upper, 16-bits of the resulting GUID. See PWP_SITE_GROUPID for important information.

Parameters
usr_idAny locally unique, unsigned 16-bit value. The developer is responsible for the local uniqueness of the usr_id values.
See also
PWP_SITE_GROUPID, MAKEGUID2()

Definition at line 110 of file apiUtils.h.

◆ MAKEGUID2

#define MAKEGUID2 (   hi16,
  low16 
)
Value:
(PWP_UINT32)( (((hi16) & 0x0000FFFFUL) << 16) | \
((low16) & 0x0000FFFFUL))
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:194

Builds a 32-bit id value.

This macro is intended to build GUIDs.

Parameters
hi16Any unsigned 16-bit value from 0 to 65535 (hex FFFF). The lower 16 bits of this value are shifted to the upper 16 bits of the resulting 32-bit GUID value.
low16Any unsigned 16-bit value from 0 to 65535 (hex FFFF). These bits are placed in the lower word of the resulting 32-bit value.
See also
MAKEGUID()

Definition at line 49 of file apiUtils.h.

◆ PWP_GROUPNAME_DEFAULT

#define PWP_GROUPNAME_DEFAULT   "PWP_SITE_GROUPNAME"

The default site group name.

Unless specified in site.h, PWP_SITE_GROUPNAME will default to this value.

See also
PWP_SITE_GROUPNAME

Definition at line 74 of file apiUtils.h.

◆ PWP_GRPID_USER

#define PWP_GRPID_USER   (PWP_UINT32)(63000UL)

The first group id value available for local, internal use.

Group ids issued by Pointwise will always be less than this value. The Maximum allowed group id value is 65535.

Unless specified in site.h, PWP_SITE_GROUPID will default to this value.

See also
PWP_SITE_GROUPID

Definition at line 64 of file apiUtils.h.

◆ VERIFY_EXPLICIT_CAST

#define VERIFY_EXPLICIT_CAST (   from,
  to 
)    ASSERT_COMPILE(sizeof(from) == sizeof(to))

Helper macro that verifies the sizes of two objects are the same.

Usage:
int var1 = 11;
int var2 = 22;
char arr1[] = "Hello";
char arr2[] = "Goodbye";
VERIFY_EXPLICIT_CAST(var1, var2); // compile continues
VERIFY_EXPLICIT_CAST(arr1, arr2); // compile fails

Definition at line 253 of file apiUtils.h.