本文整理汇总了C++中NUM_ELEMENTS函数的典型用法代码示例。如果您正苦于以下问题:C++ NUM_ELEMENTS函数的具体用法?C++ NUM_ELEMENTS怎么用?C++ NUM_ELEMENTS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NUM_ELEMENTS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:sharibshamim,项目名称:onedoc,代码行数:35,代码来源:cache.c
示例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);
}
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:35,代码来源:cache.c
示例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];
}
开发者ID:tkellaway,项目名称:f1gp-utils,代码行数:9,代码来源:LAPUTL.C
示例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];
}
开发者ID:tkellaway,项目名称:f1gp-utils,代码行数:9,代码来源:LAPUTL.C
示例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;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:16,代码来源:cache.c
示例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;
}
开发者ID:opieproject,项目名称:opie,代码行数:16,代码来源:cache.cpp
示例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);
}
开发者ID:tkellaway,项目名称:f1gp-utils,代码行数:33,代码来源:TEAMS.CPP
示例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;
}
开发者ID:RadeonOpenCompute,项目名称:ROCK-Kernel-Driver,代码行数:33,代码来源:logger.c
示例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)
{ }
开发者ID:GerbilSoft,项目名称:mcrecover,代码行数:7,代码来源:SAEventFlags.cpp
示例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 ;
}
开发者ID:HewlettPackard,项目名称:nagios-plugins-hpilo,代码行数:29,代码来源:nagios_hpilo_engine.c
示例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;
}
}
}
开发者ID:RadeonOpenCompute,项目名称:ROCK-Kernel-Driver,代码行数:32,代码来源:logger.c
示例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];
}
开发者ID:tkellaway,项目名称:f1gp-utils,代码行数:9,代码来源:LAPUTL.C
示例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);
}
}
开发者ID:opieproject,项目名称:opie,代码行数:19,代码来源:cache.cpp
示例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;
}
开发者ID:RadeonOpenCompute,项目名称:ROCK-Kernel-Driver,代码行数:45,代码来源:logger.c
示例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;
}
开发者ID:FeMTTU,项目名称:femus,代码行数:43,代码来源:example.cpp.2.cpp
示例16: wcstombs
/**
* Convert a UTF-16 string (WCHAR) to UTF-8.
* Uses tmpchar and tmpwchar buffers. (NOT REENTRANT OR THREAD-SAFE!)
* @param wcs WCHAR string.
* @return UTF-8 string. (STATIC BUFFER; use immediately, DO NOT FREE!)
*/
const char *wchar_to_char(const WCHAR *wcs)
{
static char tmpchar[512];
size_t i;
wchar_t *wcptr = tmpwchar.u32;
// Convert the WCHAR string to wchar_t.
// NOTE: Characters >U+FFFF are not supported.
for (i = 0; i < NUM_ELEMENTS(tmpwchar.u32); i++) {
if (*wcs == 0)
break;
*wcptr++ = *wcs++;
}
// NULL-terminate the string.
*wcptr = 0;
/// Convert from UTF-32 to UTF-8.
wcstombs(tmpchar, tmpwchar.u32, NUM_ELEMENTS(tmpchar));
return tmpchar;
}
开发者ID:DankRank,项目名称:Nintendont,代码行数:27,代码来源:ff_utf8.c
示例17: cache_get_bitmap
/* Retrieve a bitmap from the cache */
RD_HBITMAP
cache_get_bitmap(uint8 id, uint16 idx)
{
if ((id < NUM_ELEMENTS(g_bmpcache)) && (idx < NUM_ELEMENTS(g_bmpcache[0])))
{
if (g_bmpcache[id][idx].bitmap || pstcache_load_bitmap(id, idx))
{
if (IS_PERSISTENT(id))
cache_bump_bitmap(id, idx, BUMP_COUNT);
return g_bmpcache[id][idx].bitmap;
}
}
else if ((id < NUM_ELEMENTS(g_volatile_bc)) && (idx == 0x7fff))
{
return g_volatile_bc[id];
}
error("get bitmap %d:%d\n", id, idx);
return NULL;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:22,代码来源:cache.c
示例18: cache_get_bitmap
/* Retrieve a bitmap from the cache */
HBITMAP
cache_get_bitmap(rdcConnection conn, uint8 id, uint16 idx)
{
if ((id < NUM_ELEMENTS(conn->bmpcache)) && (idx < NUM_ELEMENTS(conn->bmpcache[0])))
{
if (conn->bmpcache[id][idx].bitmap || pstcache_load_bitmap(conn, id, idx))
{
if (IS_PERSISTENT(id))
cache_bump_bitmap(conn, id, idx, BUMP_COUNT);
return conn->bmpcache[id][idx].bitmap;
}
}
else if ((id < NUM_ELEMENTS(conn->volatileBc)) && (idx == 0x7fff))
{
return conn->volatileBc[id];
}
error("get bitmap %d:%d\n", id, idx);
return NULL;
}
开发者ID:sharibshamim,项目名称:onedoc,代码行数:22,代码来源:cache.c
示例19: char_to_wchar
/**
* Convert a UTF-8 string to WCHAR (UTF-16).
* Uses tmpwchar buffer. (NOT REENTRANT OR THREAD-SAFE!)
* @param str UTF-8 string.
* @return True if converted; false if string is empty or invalid.
*/
static inline bool char_to_wchar(const char *str)
{
size_t len, i;
if (!str || *str == 0)
return false;
len = mbstowcs(tmpwchar.u32, str, NUM_ELEMENTS(tmpwchar.u32));
if (len == 0)
return false;
if (len >= NUM_ELEMENTS(tmpwchar.u32))
len = NUM_ELEMENTS(tmpwchar.u32)-1;
// Convert from UTF-32 to UTF-16.
// NOTE: Characters >U+FFFF are not supported.
for (i = 0; i < len; ++i) {
tmpwchar.u16[i] = (WCHAR)(tmpwchar.u32[i] & 0xFFFF);
}
// NULL-terminate the string.
tmpwchar.u16[len] = 0;
return true;
}
开发者ID:DankRank,项目名称:Nintendont,代码行数:28,代码来源:ff_utf8.c
示例20: main
int main(int /* argc */, char ** /*argv*/)
{
/* Simple conversion using encode() and decode(). */
try
{
/* 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, 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));
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);
/* 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;
}
开发者ID:synesissoftware,项目名称:b64,代码行数:38,代码来源:example.cpp.1.cpp
注:本文中的NUM_ELEMENTS函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论