本文整理汇总了C++中NUM_ELEMENTS函数的典型用法代码示例。如果您正苦于以下问题:C++ NUM_ELEMENTS函数的具体用法?C++ NUM_ELEMENTS怎么用?C++ NUM_ELEMENTS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NUM_ELEMENTS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cache_put_bitmap
/* Store a bitmap in the cache */
void
cache_put_bitmap(rdcConnection conn, uint8 id, uint16 idx, HBITMAP bitmap)
{
HBITMAP old;
if ((id < NUM_ELEMENTS(conn->bmpcache)) && (idx < NUM_ELEMENTS(conn->bmpcache[0])))
{
old = conn->bmpcache[id][idx].bitmap;
if (old != NULL)
ui_destroy_bitmap(old);
conn->bmpcache[id][idx].bitmap = bitmap;
if (IS_PERSISTENT(id))
{
if (old == NULL)
conn->bmpcache[id][idx].previous = conn->bmpcache[id][idx].next = NOT_SET;
cache_bump_bitmap(conn, id, idx, TO_TOP);
if (conn->bmpcacheCount[id] > BMPCACHE2_C2_CELLS)
cache_evict_bitmap(conn, id);
}
}
else if ((id < NUM_ELEMENTS(conn->volatileBc)) && (idx == 0x7fff))
{
old = conn->volatileBc[id];
if (old != NULL)
ui_destroy_bitmap(old);
conn->volatileBc[id] = bitmap;
}
else
{
error("put bitmap %d:%d\n", id, idx);
}
}
示例2: cache_put_bitmap
/* Store a bitmap in the cache */
void
cache_put_bitmap(uint8 id, uint16 idx, RD_HBITMAP bitmap)
{
RD_HBITMAP old;
if ((id < NUM_ELEMENTS(g_bmpcache)) && (idx < NUM_ELEMENTS(g_bmpcache[0])))
{
old = g_bmpcache[id][idx].bitmap;
if (old != NULL)
ui_destroy_bitmap(old);
g_bmpcache[id][idx].bitmap = bitmap;
if (IS_PERSISTENT(id))
{
if (old == NULL)
g_bmpcache[id][idx].previous = g_bmpcache[id][idx].next = NOT_SET;
cache_bump_bitmap(id, idx, TO_TOP);
if (g_bmpcache_count[id] > BMPCACHE2_C2_CELLS)
cache_evict_bitmap(id);
}
}
else if ((id < NUM_ELEMENTS(g_volatile_bc)) && (idx == 0x7fff))
{
old = g_volatile_bc[id];
if (old != NULL)
ui_destroy_bitmap(old);
g_volatile_bc[id] = bitmap;
}
else
{
error("put bitmap %d:%d\n", id, idx);
}
}
示例3: LapSkillToAscii
char *
LapSkillToAscii(
uchar skill_level /* In Skill level */
) {
if (skill_level >= NUM_ELEMENTS(skill)) {
skill_level = NUM_ELEMENTS(skill) - 1;
}
return skill[skill_level];
}
示例4: LapCircuitText
char *
LapCircuitText(
int circuit_number /* In Cicruit number */
) {
if (circuit_number >= NUM_ELEMENTS(circuits)) {
circuit_number = NUM_ELEMENTS(circuits) - 1;
}
return circuits[circuit_number];
}
示例5: cache_get_font
/* Retrieve a glyph from the font cache */
FONTGLYPH *
cache_get_font(uint8 font, uint16 character)
{
FONTGLYPH *glyph;
if ((font < NUM_ELEMENTS(g_fontcache)) && (character < NUM_ELEMENTS(g_fontcache[0])))
{
glyph = &g_fontcache[font][character];
if (glyph->pixmap != NULL)
return glyph;
}
error("get font %d:%d\n", font, character);
return NULL;
}
示例6: cache_get_bitmap
/* Retrieve a bitmap from the cache */
HBITMAP
cache_get_bitmap(uint8 cache_id, uint16 cache_idx)
{
HBITMAP bitmap;
if ((cache_id < NUM_ELEMENTS(bmpcache)) && (cache_idx < NUM_ELEMENTS(bmpcache[0])))
{
bitmap = bmpcache[cache_id][cache_idx];
if (bitmap != NULL)
return bitmap;
}
error("get bitmap %d:%d\n", cache_id, cache_idx);
return NULL;
}
示例7: ChildWindow
TeamsWindow::TeamsWindow(
HINSTANCE hInst,
HWND hWndParent,
unsigned short usWidth,
unsigned short usHeight
) : ChildWindow(hInst, TEAMS_CLASS_NAME, GetAppName(), WS_CHILD, CHILD_ID_TEAMS, hWndParent) {
unsigned short i;
fInBitmap = FALSE;
usSelectedTeam = 0;
usClientWidth = usWidth;
usClientHeight = usHeight;
usMiniCarWidth = usClientWidth / TEAMS_NUM_X;
usMiniCarHeight = usClientHeight / TEAMS_NUM_Y;
pClientBitmap = new Bitmap(pF1CarBitmap, usClientWidth, usClientHeight);
ASSERT(pClientBitmap != NULL);
pCursorTeamCar = new Cursor(Instance(), APP_CURSOR_TEAMCAR);
ASSERT(pCursorTeamCar != NULL);
CAR_REGIONS *pCR = car_regions;
for (i = 0; i < NUM_ELEMENTS(car_regions); i++, pCR++) {
pCR->hRgn = CreatePolygonRgn(pCR->points, pCR->usPoints, ALTERNATE);
ASSERT(pCR->hRgn != NULL);
}
UpdateMemoryImage();
DragAcceptFiles(Handle(), TRUE);
}
示例8:
const struct log_minor_info *dal_logger_enum_log_minor_info(
struct dal_logger *logger,
enum log_major major,
unsigned int enum_index)
{
const struct log_minor_info *minor_info = NULL;
uint32_t i;
for (i = 0; i < NUM_ELEMENTS(log_major_mask_info_tbl); i++) {
const struct log_major_mask_info *maj_mask_info =
&log_major_mask_info_tbl[i];
if (maj_mask_info->major_info.major == major) {
if (maj_mask_info->minor_tbl != NULL) {
uint32_t j;
for (j = 0; j < maj_mask_info->tbl_element_cnt; j++) {
minor_info = &maj_mask_info->minor_tbl[j];
if (minor_info->minor == enum_index)
return minor_info;
}
}
break;
}
}
return NULL;
}
示例9: super
SAEventFlags::SAEventFlags(QObject *parent)
: super(512, // Total number of bit flags.
"SADataEvents", // Translation context.
&sa_event_flags_desc[0], // Bit flags with names.
NUM_ELEMENTS(sa_event_flags_desc)-1, // Number of named flags.
parent)
{ }
示例10: print_help
static void
print_help (void)
{
int i, j;
usage();
printf("\n");
for (i=0;i<sizeof(help_string)/sizeof(help_string[0]);i++)
{
printf("%s\n", help_string[i]);
/* Check if the string contains "oid" string. */
if (strstr(help_string[i], "oid"))
{
printf("\n\toid index\tOID info\n");
printf("\t------------------------------------\n");
for (j = 0; j < NUM_ELEMENTS(ilo_old_table); j++)
printf("\t%4d\t\t%s\n", j + 1,
ilo_old_table[j].oid_pool[HLTH_GROUP_OID].oid_name);
printf("\t------------------------------------\n");
}
}
return ;
}
示例11: log_major_minor
static void log_major_minor(struct log_entry *entry)
{
uint32_t i;
enum log_major major = entry->major;
enum log_minor minor = entry->minor;
for (i = 0; i < NUM_ELEMENTS(log_major_mask_info_tbl); i++) {
const struct log_major_mask_info *maj_mask_info =
&log_major_mask_info_tbl[i];
if (maj_mask_info->major_info.major == major) {
dal_logger_append(entry, "[%s_",
maj_mask_info->major_info.major_name);
if (maj_mask_info->minor_tbl != NULL) {
uint32_t j;
for (j = 0; j < maj_mask_info->tbl_element_cnt; j++) {
const struct log_minor_info *min_info = &maj_mask_info->minor_tbl[j];
if (min_info->minor == minor)
dal_logger_append(entry, "%s]\t", min_info->minor_name);
}
}
break;
}
}
}
示例12: LapCircuitLaps
unsigned char
LapCircuitLaps(
int circuit_number /* In Cicruit number */
) {
if (circuit_number >= NUM_ELEMENTS(circuits_laps)) {
circuit_number = 0;
}
return circuits_laps[circuit_number];
}
示例13: cache_put_bitmap
/* Store a bitmap in the cache */
void
cache_put_bitmap(uint8 cache_id, uint16 cache_idx, HBITMAP bitmap)
{
HBITMAP old;
if ((cache_id < NUM_ELEMENTS(bmpcache)) && (cache_idx < NUM_ELEMENTS(bmpcache[0])))
{
old = bmpcache[cache_id][cache_idx];
if (old != NULL)
ui_destroy_bitmap(old);
bmpcache[cache_id][cache_idx] = bitmap;
}
else
{
error("put bitmap %d:%d\n", cache_id, cache_idx);
}
}
示例14: construct
/* ----------- Object init and destruction ----------- */
static bool construct(struct dc_context *ctx, struct dal_logger *logger)
{
uint32_t i;
/* malloc buffer and init offsets */
logger->log_buffer_size = DAL_LOGGER_BUFFER_MAX_SIZE;
logger->log_buffer = (char *)dm_alloc(logger->log_buffer_size *
sizeof(char));
if (!logger->log_buffer)
return false;
/* todo: Fill buffer with \0 if not done by dal_alloc */
/* Initialize both offsets to start of buffer (empty) */
logger->buffer_read_offset = 0;
logger->buffer_write_offset = 0;
logger->write_wrap_count = 0;
logger->read_wrap_count = 0;
logger->open_count = 0;
logger->flags.bits.ENABLE_CONSOLE = 1;
logger->flags.bits.ENABLE_BUFFER = 0;
logger->ctx = ctx;
/* malloc and init minor mask array */
logger->log_enable_mask_minors =
(uint32_t *)dm_alloc(NUM_ELEMENTS(log_major_mask_info_tbl)
* sizeof(uint32_t));
if (!logger->log_enable_mask_minors)
return false;
/* Set default values for mask */
for (i = 0; i < NUM_ELEMENTS(log_major_mask_info_tbl); i++) {
uint32_t dflt_mask = log_major_mask_info_tbl[i].default_mask;
logger->log_enable_mask_minors[i] = dflt_mask;
}
return true;
}
示例15: main
int main(int /* argc */, char ** /*argv*/)
{
/* Conversion using encode() and decode(), with encoding flags. */
try
{
/* Flags that will control the conversions. */
unsigned encodingFlags = b64::B64_F_LINE_LEN_USE_PARAM; /* encode() will use the lineLen parameter to determine line length. */
unsigned decodingFlags = b64::B64_F_STOP_ON_UNKNOWN_CHAR; /* decode() will fail if any non-b64-character / non-white-space character is in the encoded string. */
int encodingLineLen = 4; /* Encoding line length will be 4 characters. */
/* Declare an array of bytes to use as the 'binary' blob to encode. */
unsigned char bytes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
std::cout << "Converting " << NUM_ELEMENTS(bytes) << " bytes:\n";
std::copy( bytes, bytes + NUM_ELEMENTS(bytes)
, stlsoft::FILE_iterator<unsigned char>(stdout, " %d"));
std::cout << std::endl;
/* Perform the encoding, whose results are returned in an instance of
* b64::cpp::string_t.
*/
b64::cpp::string_t enc = b64::cpp::encode(&bytes[0], sizeof(bytes), encodingFlags, encodingLineLen);
std::cout << "Encoded form: [" << enc << "]" << std::endl;
/* Perform the decoding, whose results are returned in an instance of
* b64::cpp::blob_t.
*/
b64::cpp::blob_t dec = b64::cpp::decode(enc, decodingFlags);
/* Verify that the decoding is exactly the same size and contents as
* the encoding.
*/
assert(0 == ::memcmp(&bytes[0], &dec[0], sizeof(bytes)));
}
catch(b64::cpp::coding_exception &x)
{
std::cerr << "Exception: " << x.what() << std::endl;
}
return EXIT_SUCCESS;
}