本文整理汇总了C++中TRY函数的典型用法代码示例。如果您正苦于以下问题:C++ TRY函数的具体用法?C++ TRY怎么用?C++ TRY使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TRY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_free
static void do_free(void)
{
TRY(ef_vi_filter_del(&vi, driver_handle, &filter_cookie));
TRY(ef_vi_flush(&vi, driver_handle));
TRY(ef_memreg_free(&memreg, driver_handle));
free(pkt_buf_mem);
TRY(ef_vi_free(&vi, driver_handle));
TRY(ef_pd_free(&pd, driver_handle));
TRY(ef_driver_close(driver_handle));
}
示例2: computeLabel
static status
computeLabel(Label lb)
{ if ( notNil(lb->request_compute) )
{ int w, h, b;
TRY(obtainClassVariablesObject(lb));
b = valInt(lb->border);
if ( notNil(lb->elevation) )
b += abs(valInt(lb->elevation->height));
if ( instanceOfObject(lb->selection, ClassCharArray) )
{ String s = &((CharArray)lb->selection)->data;
int minw;
int ex = valInt(getExFont(lb->font));
if ( lb->wrap == NAME_clip )
{ LocalString(buf, s->iswide, s->size+1);
str_one_line(buf, s);
s = buf;
}
str_size(s, lb->font, &w, &h);
w += ex;
if ( notDefault(lb->width) )
minw = valInt(lb->width) - 2*b;
else
minw = (valInt(lb->length)+1) * ex;
w = max(w, minw);
} else /*if ( instanceOfObject(lb->selection, ClassImage) )*/
{ Image image = (Image) lb->selection;
w = valInt(image->size->w);
h = valInt(image->size->h);
}
w += 2*b;
h += 2*b;
CHANGING_GRAPHICAL(lb,
assign(lb->area, w, toInt(w));
assign(lb->area, h, toInt(h));
changedEntireImageGraphical(lb));
assign(lb, request_compute, NIL);
}
示例3: TestExceptionsSupport
void TestExceptionsSupport()
{
REMARK (__FUNCTION__);
size_t test_vector[NUMBER_OF_ELEMENTS + 1];
for (size_t i = 0; i < NUMBER_OF_ELEMENTS; i++) {
test_vector[i] = i;
}
Iterator begin(&test_vector[0]);
Iterator end(&test_vector[NUMBER_OF_ELEMENTS]);
TRY();
tbb::parallel_for_each(begin, end, (TestFunctionType)test_function_with_exception);
CATCH_AND_ASSERT();
}
示例4: add_udp
/* Option: --proto udp (default), also --port nnn (default 9000) */
static int add_udp(struct configuration* cfg)
{
int s;
struct sockaddr_in host_address;
make_address(cfg->cfg_host, cfg->cfg_port, &host_address);
s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
TEST(s >= 0);
TRY(bind(s, (struct sockaddr*)&host_address, sizeof(host_address)) );
printf("UDP socket created, listening on port %d\n", cfg->cfg_port);
return s;
}
示例5: GetBounded
error_t
Utils::
GetBounded(char const * & input, char const * & output, char start, char end, size_t * len)
{
Utils::SkipWhitespace(input);
if (*input++ != start) return ERROR_EXPECTED_A_GOT_B_1;
Utils::SkipWhitespace(input);
output = input;
char const *
ep = input;
cell
ch;
int
depth = 1;
size_t
posLen = 0,
truLen = 0;
while (*input)
{
if (*input == end)
{
if (--depth == 0) break;
ep = ++input;
truLen = ++posLen;
}
else if ((unsigned char)*input > ' ')
{
// Allow nested start/end pairs. Note that if "start" and "end" are
// the same, then the earlier branch will have been hit already.
if (*input == start) ++depth, ++input;
else TRY(Utils::ReadChar(input, ch));
ep = input;
truLen = ++posLen;
}
else
{
++input;
++posLen;
}
}
if (*input != end) return ERROR_EXPECTED_A_GOT_B_2;
*const_cast<char *>(ep) = '\0';
if (len) *len = truLen;
++input;
Utils::SkipWhitespace(input);
return OK;
}
示例6: computeButton
static status
computeButton(Button b)
{ if ( notNil(b->request_compute) )
{ int w, h, isimage;
TRY(obtainClassVariablesObject(b));
dia_label_size(b, &w, &h, &isimage);
if ( b->look == NAME_winMenuBar ||
b->look == NAME_gtkMenuBar )
{ if ( !isimage )
{ w += valInt(getExFont(b->label_font)) * 2;
if ( b->look == NAME_gtkMenuBar )
h += 4;
} else
{ w += 4;
h += 4;
}
} else
{ if ( isimage )
{ w += 4;
h += 4;
} else
{ Size size = getClassVariableValueObject(b, NAME_size);
h += 6; w += 10 + valInt(b->radius);
if ( notNil(b->popup) )
{ if ( notNil(b->popup->popup_image) )
w += valInt(b->popup->popup_image->size->w) + 5;
else if ( b->look == NAME_motif || b->look == NAME_gtk )
w += 12 + 5;
else
w += 9 + 5;
}
w = max(valInt(size->w), w);
h = max(valInt(size->h), h);
}
}
CHANGING_GRAPHICAL(b,
assign(b->area, w, toInt(w));
assign(b->area, h, toInt(h)));
assign(b, request_compute, NIL);
}
示例7: FUNC
void FUNC ( LALStatus *status, STYPE **aseq )
{
/*
* Initialize status
*/
INITSTATUS(status);
ATTATCHSTATUSPTR( status );
/*
* Check aseq: is it non-NULL?
*/
ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR);
/*
* Check aseq: does it point to non-NULL?
*/
ASSERT (*aseq != NULL,status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR);
/*
* Check dimLength in aseq: does it point to non-NULL?
*/
ASSERT ((*aseq)->dimLength != NULL, status,
SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
/*
* Check data in aseq: does it point to non-NULL?
*/
ASSERT ((*aseq)->data != NULL, status,
SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR);
/* Ok, now let's free allocated storage */
TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ),
status );
LALFree ( (*aseq)->data ); /* free allocated data */
LALFree ( *aseq ); /* free aseq struct itself */
*aseq = NULL; /* make sure we don't point to freed struct */
DETATCHSTATUSPTR( status );
RETURN (status);
}
示例8: HG_
Bool HG_(recognised_suppression) ( Char* name, Supp *su )
{
# define TRY(_name,_xskind) \
if (0 == VG_(strcmp)(name, (_name))) { \
VG_(set_supp_kind)(su, (_xskind)); \
return True; \
}
TRY("Race", XS_Race);
TRY("FreeMemLock", XS_FreeMemLock);
TRY("UnlockUnlocked", XS_UnlockUnlocked);
TRY("UnlockForeign", XS_UnlockForeign);
TRY("UnlockBogus", XS_UnlockBogus);
TRY("PthAPIerror", XS_PthAPIerror);
TRY("LockOrder", XS_LockOrder);
TRY("Misc", XS_Misc);
return False;
# undef TRY
}
示例9: decode_USM_parameters
static s8t decode_USM_parameters(u8t* const input, const u16t input_len, u16t* pos, message_v3_t* request)
{
u8t type;
u16t length;
/* encoded as a string value */
TRY(ber_decode_type_length(input, input_len, pos, &type, &length));
if (type != BER_TYPE_OCTET_STRING) {
snmp_log("bad type, expected string: type %02X length %d\n", type, length);
return FAILURE;
}
/* sequence */
TRY(ber_decode_sequence_length(input, input_len, pos, &length));
/* msgAuthoritativeEngineID */
TRY(ber_decode_string((u8t*)input, input_len, pos, &request->msgAuthoritativeEngineID.ptr, &request->msgAuthoritativeEngineID.len));
/* msgAuthoritativeEngineBoots */
TRY(ber_decode_integer(input, input_len, pos, (s32t*)&request->msgAuthoritativeEngineBoots));
/* msgAuthoritativeEngineTime */
TRY(ber_decode_integer(input, input_len, pos, (s32t*)&request->msgAuthoritativeEngineTime));
/* msgUserName */
TRY(ber_decode_string((u8t*)input, input_len, pos, &request->msgUserName.ptr, &request->msgUserName.len));
/* msgAuthenticationParameters */
TRY(ber_decode_string((u8t*)input, input_len, pos, &request->msgAuthenticationParameters.ptr, &request->msgAuthenticationParameters.len));
/* msgPrivacyParameters */
TRY(ber_decode_string((u8t*)input, input_len, pos, &request->msgPrivacyParameters.ptr, &request->msgPrivacyParameters.len));
if (request->msgFlags & FLAG_PRIV) {
TRY(ber_decode_type_length((u8t*)input, input_len, pos, &type, &length));
if (type != BER_TYPE_OCTET_STRING || length != input_len - *pos) {
return FAILURE;
}
}
return 0;
}
示例10: XDR
PRBool
XDR(XPTArena *arena, XPTCursor *cursor, struct TestData *str)
{
TRY("Do32", XPT_Do32(cursor, &str->bit32));
TRY("Do16", XPT_Do16(cursor, &str->bit16));
TRY("Do8", XPT_Do8 (cursor, &str->bit8[0]));
TRY("Do8", XPT_Do8 (cursor, &str->bit8[1]));
TRY("DoCString", XPT_DoCString(arena, cursor, &str->cstr));
TRY("DoString", XPT_DoString(arena, cursor, &str->str));
return 0;
}
示例11: processIncomingMsg_USM
s8t processIncomingMsg_USM(u8t* const input, const u16t input_len, u16t* pos, message_v3_t* request)
{
/* If the value of the msgAuthoritativeEngineID field in the securityParameters is unknown, return usmStatsUnknownEngineIDs */
TRY(decode_USM_parameters(input, input_len, pos, request));
if (request->msgAuthoritativeEngineID.len != getEngineID()->len ||
memcmp(request->msgAuthoritativeEngineID.ptr, getEngineID()->ptr, getEngineID()->len)) {
TRY(report(request, &usmStatsUnknownEngineIDs, &usmStatsUnknownEngineIDCounter));
return ERR_USM;
}
/* check user name */
if (request->msgUserName.len != strlen((char*)getUserName()) || memcmp(request->msgUserName.ptr, getUserName(), request->msgUserName.len) != 0) {
TRY(report(request, &usmStatsUnknownUserNames, &usmStatsUnknownUserNamesCounter));
return ERR_USM;
}
if (request->msgFlags & FLAG_AUTH) {
#if ENABLE_AUTH
/* The timeliness check is only performed if authentication is applied to the message */
if (request->msgAuthenticationParameters.len != 12 || isBadHMAC(input, input_len, request) != ERR_NO_ERROR) {
TRY(report(request, &usmStatsWrongDigests, &usmStatsWrongDigestsCounter));
return ERR_USM;
}
#else
return FAILURE;
#endif
}
if (request->msgAuthoritativeEngineBoots != getMsgAuthoritativeEngineBoots() ||
abs(request->msgAuthoritativeEngineTime - getSysUpTime()) < TIME_WINDOW) {
TRY(report(request, &usmStatsNotInTimeWindows, &usmStatsNotInTimeWindowsCounter));
return ERR_USM;
}
if (request->msgFlags & FLAG_PRIV) {
#if ENABLE_PRIVACY
if (request->msgPrivacyParameters.len != 8) {
TRY(report(request, &usmStatsDecryptionErrors, &usmStatsDecryptionErrorsCounter));
return ERR_USM;
}
/* init IV */
u8t iv[16];
convert_2_octets(iv, request->msgAuthoritativeEngineBoots);
convert_2_octets(iv + 4, request->msgAuthoritativeEngineTime);
memcpy(iv + 8, request->msgPrivacyParameters.ptr, 8);
/* decode the Scoped PDU */
aes_process(getPrivKul(), iv, input + *pos, input + *pos, input_len - *pos, AES_DECRYPT);
#else
return FAILURE;
#endif
}
return 0;
}
示例12: main
int main(void)
{
plan_tests(9);
MEMREF act, x = strref("hello, world");
# define S(s) ((s) ? (s) : "(null)")
# define TRY(p, l, exp) \
if (!ok(!refcmp(act = subref(x,p,l), strref(exp)), "(%d, %d): %s", p, l, S(exp))) \
fprintf(stderr, "act[%"FSIZE"d]: %.*s\n", act.len, (int)act.len, S(act.ptr))
TRY( 0, 5, "hello");
TRY( 2, 3, "llo");
TRY( -5, 2, "wo");
TRY( -5, 99, "world");
TRY(-12, 2, "he");
TRY( 0, -1, x.ptr); // (len) is unsigned, so (-1) is just a very big positive number.
TRY( 0, 0, NULL);
TRY( 1, 0, NULL);
TRY(-13, 2, NULL);
return exit_status();
}
示例13: h5t_map_global_vertex_indices2local
h5_err_t
h5t_map_global_vertex_indices2local (
h5t_mesh_t* const m,
const h5_glb_idx_t* const glb_indices,
const h5_size_t size,
h5_loc_idx_t* const loc_indices
) {
H5_CORE_API_ENTER (h5_err_t,
"m=%p, glb_indices=%p, size=%llu, loc_indices=%p",
m, glb_indices, (long long unsigned)size, loc_indices);
h5_size_t i;
for (i = 0; i < size; i++) {
TRY (loc_indices[i] =
h5t_map_global_vertex_idx2local (m, glb_indices[i]));
}
H5_CORE_API_RETURN (H5_SUCCESS);
}
示例14: computeSampleFrequency
void NationalInstrumentsDAQ::setupAOChannels( float64 nrecords,
float64 record_frequency_Hz,
float64 vmin,
float64 vmax,
IDAQPhysicalChannel **channels,
int nchannels )
{ TaskHandle ao = 0;
int32 N = _config->ao_samples_per_waveform();
char terms[MAX_CHAN_STRING]= {0};
const char *dev = _config->name().c_str(),
*trig = _config->trigger().c_str();
char clk[MAX_CHAN_STRING] = {0};
float64 hz = computeSampleFrequency(nrecords,record_frequency_Hz),
lvl = _config->level_volts();
strcat(clk,_config->ctr().c_str());
strcat(clk,"InternalOutput");
// terminal names
TRY(nchannels<countof(terms));
{ const char* names[8]={0};
for(int i=0;i<nchannels;++i)
names[i]=channels[i]->name();
cat_terminal_names(terms,sizeof(terms),dev,names,nchannels);
}
// voltage range
{ f64 v[4];
DAQERR(DAQmxGetDevAOVoltageRngs(_config->name().c_str(),v,4));
vmin = MAX(vmin,v[2]);
vmax = MIN(vmax,v[3]);
}
ao=_ao.daqtask;
DAQERR(DAQmxCreateAOVoltageChan (ao,terms,NULL,vmin,vmax,DAQmx_Val_Volts,NULL));
DAQERR(DAQmxCfgSampClkTiming (ao,clk,hz,DAQmx_Val_Rising,DAQmx_Val_ContSamps,N));
DAQERR(DAQmxCfgOutputBuffer (ao,10*N));
DAQERR(DAQmxSetWriteRegenMode (ao,DAQmx_Val_DoNotAllowRegen));
DAQERR(DAQmxSetWriteRelativeTo (ao,DAQmx_Val_CurrWritePos));
DAQERR(DAQmxSetAODataXferMech (ao,terms,DAQmx_Val_DMA));
DAQERR(DAQmxSetAODataXferReqCond(ao,terms,DAQmx_Val_OnBrdMemNotFull));
DAQERR(DAQmxCfgAnlgEdgeStartTrig(ao,trig,DAQmx_Val_Rising,lvl));
return;
Error:
UNREACHABLE;
}
示例15: get_or_create_methodspace_selector_slice
value_t get_or_create_methodspace_selector_slice(runtime_t *runtime, value_t self,
value_t selector) {
value_t cache_ptr = get_methodspace_cache_ptr(self);
value_t cache = get_freeze_cheat_value(cache_ptr);
// Create the cache if it doesn't exist.
if (is_nothing(cache)) {
TRY_SET(cache, new_heap_id_hash_map(runtime, 128));
set_freeze_cheat_value(cache_ptr, cache);
}
// Create the selector-specific cache if it doesn't exits.
value_t slice = get_id_hash_map_at(cache, selector);
if (in_condition_cause(ccNotFound, slice)) {
TRY_SET(slice, create_methodspace_selector_slice(runtime, self, selector));
TRY(set_id_hash_map_at(runtime, cache, selector, slice));
}
return slice;
}