本文整理汇总了C++中PFC_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ PFC_ASSERT函数的具体用法?C++ PFC_ASSERT怎么用?C++ PFC_ASSERT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PFC_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ListView_GetColumnCount
int ListView_GetColumnCount(HWND listView) {
if (!ProbeColumn(listView, 0)) return 0;
int hi = 1;
for (;;) {
if (!ProbeColumn(listView, hi)) break;
hi <<= 1;
if (hi <= 0) {
PFC_ASSERT(!"Shouldn't get here!");
return -1;
}
}
int lo = hi >> 1;
//lo is the highest known valid column, hi is the lowest known invalid, let's bsearch thru
while(lo + 1 < hi) {
PFC_ASSERT( lo < hi );
const int mid = lo + (hi - lo) / 2;
PFC_ASSERT( lo < mid && mid < hi );
if (ProbeColumn(listView, mid)) {
lo = mid;
} else {
hi = mid;
}
}
return hi;
}
示例2: PFC_ASSERT
bool dsp_entry_v2::show_config_popup(dsp_preset & p_data,HWND p_parent) {
PFC_ASSERT(p_data.get_owner() == get_guid());
dsp_preset_impl temp(p_data);
show_config_popup_v2(p_data,p_parent,dsp_preset_edit_callback_impl(temp));
PFC_ASSERT(temp.get_owner() == get_guid());
if (temp == p_data) return false;
p_data = temp;
return true;
}
示例3: PFC_ASSERT
bool bit_array_flatIndexList::_findNearestDown( size_t val, size_t & outIdx ) const {
size_t idx;
if (_find( val, idx )) { outIdx = idx; return true; }
// we have a valid outIdx at where the bsearch gave up
PFC_ASSERT ( idx == 0 || m_content [ idx - 1 ] < val );
PFC_ASSERT ( idx == m_content.get_size() || m_content[ idx ] > val );
if (idx == 0) return false;
outIdx = idx - 1;
return true;
}
示例4: PFC_ASSERT
t_size CTableEditHelperV2::ColumnToPosition(t_size col) const {
PFC_ASSERT( TableEdit_IsColumnEditable(col) );
pfc::array_t<t_size> colOrder; GrabColumnOrder(colOrder);
t_size skipped = 0;
for(t_size walk = 0; walk < colOrder.get_size(); ++walk) {
const t_size curCol = colOrder[walk];
if (TableEdit_IsColumnEditable(curCol)) {
if (curCol == col) return skipped;
++skipped;
}
}
PFC_ASSERT( !"Should not get here." );
return ~0;
}
示例5: create_move_item_permutation
void create_move_item_permutation( size_t * order, size_t count, size_t from, size_t to ) {
PFC_ASSERT( from < count );
PFC_ASSERT( to < count );
for ( size_t w = 0; w < count; ++w ) {
size_t i = w;
if ( w == to ) i = from;
else if ( w < to && w >= from ) {
++i;
} else if ( w > to && w <= from ) {
--i;
}
order[w] = i;
}
}
示例6: PFC_ASSERT
void file_info::info_set_float(const char * name,double value,unsigned precision,bool force_sign,const char * unit)
{
PFC_ASSERT(pfc::is_valid_utf8(name));
PFC_ASSERT(unit==0 || strlen(unit) <= 64);
char temp[128];
pfc::float_to_string(temp,64,value,precision,force_sign);
temp[63] = 0;
if (unit)
{
strcat_s(temp," ");
strcat_s(temp,unit);
}
info_set(name,temp);
}
示例7: dmconf_order_gettree
/*
* static inline pfc_rbtree_t PFC_FATTR_ALWAYS_INLINE *
* dmconf_order_gettree(lnc_ordtype_t type, int index)
* Determine the Red-Black tree which keeps daemon order.
*
* The target tree is determined by the order type `type' and
* type index `index'. `index' is always ignored if `type' is
* either LNC_ORDTYPE_START or LNC_ORDTYPE_STOP.
*/
static inline pfc_rbtree_t PFC_FATTR_ALWAYS_INLINE *
dmconf_order_gettree(lnc_ordtype_t type, int index)
{
uint32_t idx = (uint32_t)type;
if (LNC_ORDTYPE_HASINDEX(type)) {
PFC_ASSERT(index >= 0);
idx += index;
}
PFC_ASSERT(idx < PFC_ARRAY_CAPACITY(dmconf_order_tree));
return &dmconf_order_tree[idx];
}
示例8: uncd_stop
/*
* int
* uncd_stop(void)
* Stop the UNC daemon.
*
* Calling/Exit State:
* Upon successful completion, zero is returned.
* Otherwise error number which indicates the cause of error is returned.
*/
int
uncd_stop(void)
{
pfc_extcmd_t ecmd;
int err, status;
err = pfc_extcmd_create(&ecmd, UNC_CONTROL_PATH, UNC_CONTROL);
if (PFC_EXPECT_FALSE(err != 0)) {
error("Failed to create command context for %s: %s",
UNC_CONTROL, strerror(err));
return err;
}
err = pfc_extcmd_add_arguments(ecmd, "stop", "-q", NULL);
if (PFC_EXPECT_FALSE(err != 0)) {
error("Failed to append arguments for %s: %s",
UNC_CONTROL, strerror(err));
goto out;
}
err = pfc_extcmd_execute(ecmd);
if (PFC_EXPECT_FALSE(err != 0)) {
error("Failed to execute %s: %s", UNC_CONTROL, strerror(err));
goto out;
}
status = pfc_extcmd_get_status(ecmd);
if (PFC_EXPECT_FALSE(status != 0)) {
if (status == PFC_EXTCMD_ERR_UNSPEC) {
int sig = pfc_extcmd_get_signal(ecmd);
PFC_ASSERT(sig > 0);
error("%s was killed by signal %d.", UNC_CONTROL, sig);
}
else {
PFC_ASSERT(status > 0);
error("%s exited with status %d.", UNC_CONTROL,
status);
err = EIO;
}
}
out:
PFC_ASSERT_INT(pfc_extcmd_destroy(ecmd), 0);
return err;
}
示例9: g_write_tags_ex
static void g_write_tags_ex(tag_write_callback & p_callback,unsigned p_flags,const service_ptr_t<file> & p_file,const file_info * p_info,abort_callback & p_abort) {
PFC_ASSERT( p_flags == 0 || p_info != 0 );
if (p_flags & (g_flag_id3v1 | g_flag_apev2)) {
switch(p_flags & (g_flag_id3v1 | g_flag_apev2)) {
case g_flag_id3v1 | g_flag_apev2:
static_api_ptr_t<tag_processor_trailing>()->write_apev2_id3v1(p_file,*p_info,p_abort);
break;
case g_flag_id3v1:
static_api_ptr_t<tag_processor_trailing>()->write_id3v1(p_file,*p_info,p_abort);
break;
case g_flag_apev2:
static_api_ptr_t<tag_processor_trailing>()->write_apev2(p_file,*p_info,p_abort);
break;
default:
throw exception_io_data();
}
} else {
static_api_ptr_t<tag_processor_trailing>()->remove(p_file,p_abort);
}
if (p_flags & g_flag_id3v2)
{
static_api_ptr_t<tag_processor_id3v2>()->write_ex(p_callback,p_file,*p_info,p_abort);
}
else
{
t_uint64 dummy;
tag_processor_id3v2::g_remove_ex(p_callback,p_file,dummy,p_abort);
}
}
示例10: cred_loadconf
/*
* static int
* cred_loadconf(void)
* Load the system configuration file for the given daemon process.
*
* Calling/Exit State:
* Upon successful completion, zero is returned.
* Otherwise error number which indicates the cause of error is returned.
*/
static int
cred_loadconf(void)
{
pfc_refptr_t *rpath;
char *path;
int err;
/* Ensure that the configuration file is safe. */
path = strdup(PFC_PFCD_CONF_PATH);
if (PFC_EXPECT_FALSE(path == NULL)) {
return ENOMEM;
}
err = pfc_is_safepath(path);
free(path);
if (PFC_EXPECT_FALSE(err != 0)) {
return err;
}
rpath = pfc_refptr_string_create(PFC_PFCD_CONF_PATH);
if (PFC_EXPECT_FALSE(rpath == NULL)) {
return ENOMEM;
}
err = pfc_sysconf_init(rpath);
pfc_refptr_put(rpath);
PFC_ASSERT(err != 0 || pfc_sysconf_open() != PFC_CONF_INVALID);
return err;
}
示例11: MultiWaitAbortable_MsgLoop
t_size MultiWaitAbortable_MsgLoop(const HANDLE * ev, t_size evCount, abort_callback & abort) {
pfc::array_t<HANDLE> handles; handles.set_size(evCount + 1);
handles[0] = abort.get_abort_event();
pfc::memcpy_t(handles.get_ptr() + 1, ev, evCount);
for(;;) {
SetLastError(0);
const DWORD status = MsgWaitForMultipleObjects(handles.get_count(), handles.get_ptr(), FALSE, INFINITE, QS_ALLINPUT);
switch(status) {
case WAIT_TIMEOUT:
PFC_ASSERT(!"How did we get here?");
uBugCheck();
case WAIT_OBJECT_0:
throw exception_aborted();
case WAIT_FAILED:
WIN32_OP_FAIL();
default:
{
t_size index = (t_size)(status - (WAIT_OBJECT_0 + 1));
if (index == evCount) {
ProcessPendingMessages();
} else if (index < evCount) {
return index;
} else {
uBugCheck();
}
}
}
}
}
示例12: proc_buf_append
/*
* static int
* proc_buf_append(proc_buf_t *pbufp, char c)
* Append the specified character to the proc_buf_t.
*
* Calling/Exit State:
* Upon successful completion, zero is returned.
* ENOMEM is returned if no memory is available.
*/
static int
proc_buf_append(proc_buf_t *pbufp, char c)
{
size_t cursor = pbufp->pb_cursor;
PFC_ASSERT(cursor <= pbufp->pb_size);
if (cursor == pbufp->pb_size) {
char *newbuf;
size_t newsize = pbufp->pb_size + PROC_BUF_BLKSIZE;
/* Buffer must be expanded. */
newbuf = (char *)realloc(pbufp->pb_buffer, newsize);
if (PFC_EXPECT_FALSE(newbuf == NULL)) {
return ENOMEM;
}
pbufp->pb_size = newsize;
pbufp->pb_buffer = newbuf;
}
if (c == '(') {
if (pbufp->pb_firstlparen == (size_t)-1) {
pbufp->pb_firstlparen = cursor;
}
}
else if (c == ')') {
pbufp->pb_lastrparen = cursor;
}
*(pbufp->pb_buffer + cursor) = c;
pbufp->pb_cursor = cursor + 1;
return 0;
}
示例13: PFC_ASSERT
metadb_handle_ptr playlist_manager::playlist_get_item_handle(t_size playlist, t_size item) {
metadb_handle_ptr temp;
if (!playlist_get_item_handle(temp, playlist, item)) throw pfc::exception_invalid_params();
PFC_ASSERT( temp.is_valid() );
return temp;
}
示例14: counter
void metadb_handle_list_helper::sort_by_format_get_order(metadb_handle_list_cref p_list,t_size* order,const service_ptr_t<titleformat_object> & p_script,titleformat_hook * p_hook,int p_direction)
{
// pfc::hires_timer timer; timer.start();
const t_size count = p_list.get_count();
pfc::array_t<custom_sort_data> data; data.set_size(count);
{
pfc::counter counter(0);
pfc::array_t<pfc::rcptr_t<tfthread> > threads; threads.set_size(pfc::getOptimalWorkerThreadCountEx(p_list.get_count() / 128));
PFC_ASSERT( threads.get_size() > 0 );
for(t_size walk = 0; walk < threads.get_size(); ++walk) {
threads[walk].new_t(&counter,p_list,data.get_ptr(),p_script,p_hook);
}
for(t_size walk = 1; walk < threads.get_size(); ++walk) threads[walk]->start();
threads[0]->threadProc();
for(t_size walk = 1; walk < threads.get_size(); ++walk) threads[walk]->waitTillDone();
}
// console::formatter() << "metadb_handle sort: prepared in " << pfc::format_time_ex(timer.query(),6);
pfc::sort_t(data, p_direction > 0 ? custom_sort_compare<1> : custom_sort_compare<-1>,count);
//qsort(data.get_ptr(),count,sizeof(custom_sort_data),p_direction > 0 ? _custom_sort_compare<1> : _custom_sort_compare<-1>);
// console::formatter() << "metadb_handle sort: sorted in " << pfc::format_time_ex(timer.query(),6);
for(t_size n=0;n<count;n++)
{
order[n]=data[n].index;
delete[] data[n].text;
}
// console::formatter() << "metadb_handle sort: finished in " << pfc::format_time_ex(timer.query(),6);
}
示例15: WaitAbortable_MsgLoop
bool WaitAbortable_MsgLoop(HANDLE ev, abort_callback & abort, DWORD timeout /*must not be INFINITE*/) {
PFC_ASSERT( timeout != INFINITE );
const DWORD entry = GetTickCount();
const HANDLE handles[2] = {ev, abort.get_abort_event()};
for(;;) {
const DWORD done = GetTickCount() - entry;
if (done >= timeout) return false;
SetLastError(0);
const DWORD status = MsgWaitForMultipleObjects(2, handles, FALSE, timeout - done, QS_ALLINPUT);
switch(status) {
case WAIT_TIMEOUT:
return false;
case WAIT_OBJECT_0:
return true;
case WAIT_OBJECT_0 + 1:
throw exception_aborted();
case WAIT_OBJECT_0 + 2:
ProcessPendingMessages();
break;
case WAIT_FAILED:
WIN32_OP_FAIL();
default:
uBugCheck();
}
}
}