这篇教程C++ CATCH函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CATCH函数的典型用法代码示例。如果您正苦于以下问题:C++ CATCH函数的具体用法?C++ CATCH怎么用?C++ CATCH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CATCH函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: test_app_arguments_validate_ordinal_required_discontinuitybool test_app_arguments_validate_ordinal_required_discontinuity (Test *test){ char *argv[] = { "./app", "--argument" }; int value_1; int value_2; AppArgument arguments[] = { ARGUMENT_ORDINAL_INTEGER (1, false, &value_1, "test"), ARGUMENT_ORDINAL_INTEGER (1, true, &value_2, "test"), ARGUMENT_END }; TITLE (); CATCH (app_arguments (2, argv, arguments)) CATCH (error_count () < 2); CATCH (error_at (1).error != ErrorAppArgumentOrdinalRequiredDiscontinuity); PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:18,
示例2: confuga_lookupCONFUGA_API int confuga_lookup (confuga *C, const char *path, confuga_fid_t *fid, confuga_off_t *size){ int rc; enum CONFUGA_FILE_TYPE type; RESOLVE(path) debug(D_CONFUGA, "lookup(`%s')", unresolved_path); CATCH(lookup(C, path, fid, size, &type)); PROLOGUE}
开发者ID:NeilB879,项目名称:cctools,代码行数:9,
示例3: MailboxState_getAclint MailboxState_getAcl(T M, uint64_t userid, struct ACLMap *map){ int i; volatile int t = DM_SUCCESS; gboolean gotrow = FALSE; uint64_t anyone; Connection_T c; ResultSet_T r; PreparedStatement_T s; g_return_val_if_fail(MailboxState_getId(M),DM_EGENERAL); if (! (auth_user_exists(DBMAIL_ACL_ANYONE_USER, &anyone))) return DM_EQUERY; c = db_con_get(); TRY s = db_stmt_prepare(c, "SELECT lookup_flag,read_flag,seen_flag," "write_flag,insert_flag,post_flag," "create_flag,delete_flag,deleted_flag,expunge_flag,administer_flag " "FROM %sacl " "WHERE mailbox_id = ? AND user_id = ?",DBPFX); db_stmt_set_u64(s, 1, MailboxState_getId(M)); db_stmt_set_u64(s, 2, userid); r = db_stmt_query(s); if (! db_result_next(r)) { /* else check the 'anyone' user */ db_stmt_set_u64(s, 2, anyone); r = db_stmt_query(s); if (db_result_next(r)) gotrow = TRUE; } else { gotrow = TRUE; } if (gotrow) { i = 0; map->lookup_flag = db_result_get_bool(r,i++); map->read_flag = db_result_get_bool(r,i++); map->seen_flag = db_result_get_bool(r,i++); map->write_flag = db_result_get_bool(r,i++); map->insert_flag = db_result_get_bool(r,i++); map->post_flag = db_result_get_bool(r,i++); map->create_flag = db_result_get_bool(r,i++); map->delete_flag = db_result_get_bool(r,i++); map->deleted_flag = db_result_get_bool(r,i++); map->expunge_flag = db_result_get_bool(r,i++); map->administer_flag = db_result_get_bool(r,i++); } CATCH(SQLException) LOG_SQLERROR; t = DM_EQUERY; FINALLY db_con_close(c); END_TRY; return t;}
开发者ID:Alexander-KI,项目名称:dbmail,代码行数:56,
示例4: test_file_path_size_1bool test_file_path_size_1 (Test *test){ char *path; TITLE (); file_path_size (0); CATCH (!(path = directory_current_path ())); memory_destroy (path); PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:10,
示例5: test_pattern_search_createbool test_pattern_search_create (Test *test){ PatternSearch *search; const char *memory = "a"; TITLE (); CATCH (!(search = pattern_search_create ((const unsigned char *)memory, string_length (memory) + 1, "a", true))); pattern_search_destroy (search); PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:10,
示例6: test_ascii_is_white_spacebool test_ascii_is_white_space (Test *test){ int i; TITLE (); for (i = SCHAR_MIN; i <= SCHAR_MAX; i++) { if ((char)i == ' ' || (char)i == '/f' || (char)i == '/n' || (char)i == '/r' || (char)i == '/t' || (char)i == '/v') { CATCH (!ascii_is_white_space ((char)i)); } else { CATCH (ascii_is_white_space ((char)i)); } } PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:20,
示例7: test_file_closebool test_file_close (Test *test){ Directory *directory; File *file; char *path; TITLE (); CATCH (!(path = directory_current_path ())); CATCH (!string_append (&path, "/stage/open")); /* d stage/open f f1 */ CATCH (!(directory = directory_open (path))); string_destroy (path); CATCH (!directory_read (directory)); CATCH (!(file = directory_find_file (directory, "f1"))); file_close (file); directory_close (directory); PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:21,
示例8: test_big_int_add_function_call_1bool test_big_int_add_function_call_1 (Test *test){ BigInt *a, *b, *to; int i; TITLE (); CATCH (!(a = big_int_create (0))); CATCH (!(b = big_int_create (0))); CATCH (!(to = big_int_create (0))); a->memory[0] = 5U; b->memory[0] = 5U; for (i = 1; i < 32; i++) { a->memory[i] = 0U; b->memory[i] = 0U; } a->digits = 32; b->digits = 32; memory_commit_limit (memory_commit_size ()); CATCH (big_int_add (a, b, to)); CATCH (error_at (0).error != ErrorFunctionCall); CATCH (error_at (0).code != 1); big_int_destroy (a); big_int_destroy (b); big_int_destroy (to); PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:26,
示例9: test_file_readline_f2bool test_file_readline_f2 (Test *test){ Directory *directory; File *file; char *path; char *line; size_t bytes_read; TITLE (); CATCH (!(path = directory_current_path ())); CATCH (!string_append (&path, "/stage/readline")); /* d stage/readline f f2 f f3 / / 0 / AB / 012 / ABCD / 01234 / ABCD / 012 / AB / 0 f f1 */ CATCH (!(directory = directory_open (path))); string_destroy (path); CATCH (!directory_read (directory)); CATCH (!(file = directory_find_file (directory, "f2"))); CATCH (!file_open (file)); CATCH (!(line = string_create_with_size (1))); CATCH (!file_readline (file, line, &bytes_read)); CATCH (bytes_read != 0); CATCH (memory_size (line) != 1); directory_close (directory); string_destroy (line); PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:40,
示例10: test_unsigned_long_long_private_maxbool test_unsigned_long_long_private_max (Test *test){ unsigned int a, b, max; unsigned long long computed; TITLE (); for (max = 1; max < 9; max++) { a = 0; b = 0; unsigned_long_long_private_max (max - 1); do { if (a > max - 1 || b > max - 1 || a + b > max - 1) { CATCH (unsigned_long_long_add (a, b, &computed)); } else { CATCH (!unsigned_long_long_add (a, b, &computed)); CATCH (computed != a + b); } if (a > max - 1 || b > max - 1 || a * b > max - 1) { CATCH (unsigned_long_long_mul (a, b, &computed)); } else { CATCH (!unsigned_long_long_mul (a, b, &computed)); CATCH (computed != a * b); } } while (combinations_a_b (&a, &b, max, max)); } PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:33,
示例11: ccnet_db_statement_set_intintccnet_db_statement_set_int (CcnetDBStatement *p, int idx, int x){ TRY PreparedStatement_setInt (p->p, idx, x); RETURN (0); CATCH (SQLException) g_warning ("Error set int in prep stmt: %s./n", Exception_frame.message); return -1; END_TRY; return -1;}
开发者ID:ezhangle,项目名称:ccnet,代码行数:13,
示例12: test_ascii_is_digit_octalbool test_ascii_is_digit_octal (Test *test){ int i; TITLE (); for (i = SCHAR_MIN; i <= SCHAR_MAX; i++) { if ((char)i == '0' || (char)i == '1' || (char)i == '2' || (char)i == '3' || (char)i == '4' || (char)i == '5' || (char)i == '6' || (char)i == '7') { CATCH (!ascii_is_digit_octal ((char)i)); } else { CATCH (ascii_is_digit_octal ((char)i)); } } PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:22,
示例13: python_save_filechar*python_save_file(char **dest, const char *filename){ char *ret; PyObject *module, *mainthing, *pyret; printf("the module being used for file is %s/n", config_get("module_file")); module = PyDict_GetItemString(modulemap, config_get("module_file")); CATCH(module, bottom_save_file); mainthing = PyObject_CallMethod(module, "init", NULL); CATCH(mainthing, bottom_save_file); pyret = PyObject_CallMethod(mainthing, "save_file", "s", filename); CATCH(pyret, bottom_save_file); ret = PyUnicode_AsUTF8(pyret); CATCH(ret, bottom_save_file); bottom_save_file: // label if (PyErr_Occurred()) { PyErr_Print(); } *dest = strdup(ret); Py_DecRef(mainthing); Py_DecRef(pyret); return *dest;}
开发者ID:Riamse,项目名称:notpuush,代码行数:22,
示例14: confuga_opendirCONFUGA_API int confuga_opendir(confuga *C, const char *path, confuga_dir **D){ int rc; RESOLVE(path); debug(D_CONFUGA, "opendir(`%s')", unresolved_path); *D = malloc(sizeof(confuga_dir)); if (*D == NULL) CATCH(ENOMEM); DIR *dir = opendir(path); if(dir) { (*D)->C = C; (*D)->dir = dir; strcpy((*D)->path, unresolved_path); return 0; } else { CATCH(errno); }out: debug(D_CONFUGA, "= %d (%s)", rc, strerror(rc)); if (rc) free(*D); return rc;}
开发者ID:xavierdingdev,项目名称:cctools,代码行数:22,
示例15: dm_sievescript_renameint dm_sievescript_rename(uint64_t user_idnr, char *scriptname, char *newname){ int active = 0; Connection_T c; ResultSet_T r; PreparedStatement_T s; volatile int t = FALSE; assert(scriptname); /* * According to the draft RFC, a script with the same * name as an existing script should *atomically* replace it. */ c = db_con_get(); TRY db_begin_transaction(c); s = db_stmt_prepare(c,"SELECT active FROM %ssievescripts WHERE owner_idnr = ? AND name = ?", DBPFX); db_stmt_set_u64(s,1, user_idnr); db_stmt_set_str(s,2, newname); r = db_stmt_query(s); if (db_result_next(r)) { active = db_result_get_int(r,0); db_con_clear(c); s = db_stmt_prepare(c, "DELETE FROM %ssievescripts WHERE owner_idnr = ? AND name = ?", DBPFX); db_stmt_set_u64(s, 1, user_idnr); db_stmt_set_str(s, 2, newname); db_stmt_exec(s); } db_con_clear(c); s = db_stmt_prepare(c, "UPDATE %ssievescripts SET name = ?, active = ? WHERE owner_idnr = ? AND name = ?", DBPFX); db_stmt_set_str(s, 1, newname); db_stmt_set_int(s, 2, active); db_stmt_set_u64(s, 3, user_idnr); db_stmt_set_str(s, 4, scriptname); db_stmt_exec(s); t = db_commit_transaction(c); CATCH(SQLException) LOG_SQLERROR; t = DM_EQUERY; db_rollback_transaction(c); FINALLY db_con_close(c); END_TRY; return t;}
开发者ID:alyarskiy,项目名称:dbmail,代码行数:51,
示例16: seaf_db_check_for_existencegbooleanseaf_db_check_for_existence (SeafDB *db, const char *sql, gboolean *db_err){ Connection_T conn; ResultSet_T result; gboolean ret = TRUE; *db_err = FALSE; conn = get_db_connection (db); if (!conn) { *db_err = TRUE; return FALSE; } TRY result = Connection_executeQuery (conn, "%s", sql); CATCH (SQLException) g_warning ("Error exec query %s: %s./n", sql, Exception_frame.message); Connection_close (conn); *db_err = TRUE; return FALSE; END_TRY; TRY if (!ResultSet_next (result)) ret = FALSE; CATCH (SQLException) g_warning ("Error exec query %s: %s./n", sql, Exception_frame.message); Connection_close (conn); *db_err = TRUE; return FALSE; END_TRY; Connection_close (conn); return ret;}
开发者ID:WeiY,项目名称:seafile,代码行数:38,
示例17: test_unsigned_long_long_bit_most_significantbool test_unsigned_long_long_bit_most_significant (Test *test){ TITLE (); CATCH (unsigned_long_long_bit_most_significant (0) != 0); CATCH (unsigned_long_long_bit_most_significant (1) != 0); CATCH (unsigned_long_long_bit_most_significant (2) != 1); CATCH (unsigned_long_long_bit_most_significant (3) != 1); CATCH (unsigned_long_long_bit_most_significant (4) != 2); CATCH (unsigned_long_long_bit_most_significant ((unsigned char)-1) != 7); CATCH (unsigned_long_long_bit_most_significant ((unsigned long long)-1) != 63); PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:12,
示例18: test_big_int_add_4bool test_big_int_add_4 (Test *test){ BigInt *a, *b, *to; TITLE (); CATCH (!(a = big_int_create (999))); CATCH (!(b = big_int_create (11))); CATCH (!(to = big_int_create (0))); CATCH (!big_int_add (a, b, to)); CATCH (to->digits != 4); CATCH (to->memory[0] != 1U); CATCH (to->memory[1] != 0U); CATCH (to->memory[2] != 1U); CATCH (to->memory[3] != 0U); big_int_destroy (a); big_int_destroy (b); big_int_destroy (to); PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:19,
示例19: ccnet_db_statement_set_stringintccnet_db_statement_set_string (CcnetDBStatement *p, int idx, const char *s){ TRY PreparedStatement_setString (p->p, idx, s); RETURN (0); CATCH (SQLException) g_warning ("Error set string in prep stmt: %s./n", Exception_frame.message); return -1; END_TRY; return -1;}
开发者ID:ezhangle,项目名称:ccnet,代码行数:14,
示例20: MailboxState_getPermissionunsigned MailboxState_getPermission(T M){ if (! M->permission) { Connection_T c = db_con_get(); TRY db_getmailbox_permission(M, c); CATCH(SQLException) LOG_SQLERROR; FINALLY db_con_close(c); END_TRY; } return M->permission;}
开发者ID:Alexander-KI,项目名称:dbmail,代码行数:14,
示例21: seaf_db_rollbackintseaf_db_rollback (SeafDBTrans *trans){ Connection_T conn = trans->conn; TRY Connection_rollback (conn); CATCH (SQLException) g_warning ("Rollback failed: %s./n", Exception_frame.message); return -1; END_TRY; return 0;}
开发者ID:WeiY,项目名称:seafile,代码行数:14,
示例22: seaf_db_foreach_selected_rowintseaf_db_foreach_selected_row (SeafDB *db, const char *sql, SeafDBRowFunc callback, void *data){ Connection_T conn; ResultSet_T result; SeafDBRow seaf_row; int n_rows = 0; conn = get_db_connection (db); if (!conn) return -1; TRY result = Connection_executeQuery (conn, "%s", sql); CATCH (SQLException) g_warning ("Error exec query %s: %s./n", sql, Exception_frame.message); Connection_close (conn); return -1; END_TRY; seaf_row.res = result; TRY while (ResultSet_next (result)) { n_rows++; if (!callback (&seaf_row, data)) break; } CATCH (SQLException) g_warning ("Error exec query %s: %s./n", sql, Exception_frame.message); Connection_close (conn); return -1; END_TRY; Connection_close (conn); return n_rows;}
开发者ID:WeiY,项目名称:seafile,代码行数:37,
示例23: seaf_db_get_stringchar *seaf_db_get_string (SeafDB *db, const char *sql){ char *ret = NULL; const char *s; Connection_T conn; ResultSet_T result; SeafDBRow seaf_row; conn = get_db_connection (db); if (!conn) return NULL; TRY result = Connection_executeQuery (conn, "%s", sql); CATCH (SQLException) g_warning ("Error exec query %s: %s./n", sql, Exception_frame.message); Connection_close (conn); return NULL; END_TRY; seaf_row.res = result; TRY if (ResultSet_next (result)) { s = seaf_db_row_get_column_text (&seaf_row, 0); ret = g_strdup(s); } CATCH (SQLException) g_warning ("Error exec query %s: %s./n", sql, Exception_frame.message); Connection_close (conn); return NULL; END_TRY; Connection_close (conn); return ret;}
开发者ID:WeiY,项目名称:seafile,代码行数:37,
示例24: SetIconBOOL CDrvDlg::OnInitDialog(){ TRY CDialog::OnInitDialog(); SetIcon(m_hIcon,TRUE); SetIcon(m_hIcon,FALSE); m_FftLen.SetCurSel(0); m_OsVersion.Initialize(); DWORD platformID = m_OsVersion.GetPlatformID(); if(VER_PLATFORM_WIN32_NT == platformID) { m_SvcNew.InstallService(drvnew); m_SvcOld.InstallService(drvold); } m_DrvNew.OpenDevice(drvnew); m_DrvOld.OpenDevice(drvold); ShowCPUInfo(); ShowOSInfo(); ShowIPPSLibInfo(); UpdateData(FALSE); m_string.Format(IDS_PRG_START); WriteLog(m_string); m_string.Format(IDS_DRV_OPEN,drvold,m_DrvOld.GetDeviceHandle()); WriteLog(m_string); m_string.Format(IDS_DRV_OPEN,drvnew,m_DrvNew.GetDeviceHandle()); WriteLog(m_string); CATCH(CMyException,e); Cleanup(); e->ReportError(); END_CATCH return TRUE;} // CDrvDlg::OnInitDialog()
开发者ID:vinnie38170,项目名称:klImageCore,代码行数:49,
示例25: chirp_fs_confuga_pwritestatic INT64_T chirp_fs_confuga_pwrite(int fd, const void *buffer, INT64_T length, INT64_T offset){ int rc; size_t n; SETUP_FILE if (length < 0 || offset < 0) CATCH(EINVAL); switch (open_files[fd].type) { case CHIRP_FS_CONFUGA_FILE_WRITE: { if ((confuga_off_t)offset != open_files[fd].f.file.size) CATCH(EINVAL); /* do not allow random writes */ CATCH_CONFUGA(confuga_file_write(open_files[fd].f.file.file, buffer, length, &n, STOPTIME)); open_files[fd].f.file.size += n; break; } case CHIRP_FS_CONFUGA_META_WRITE: if ((size_t)offset != buffer_pos(&open_files[fd].f.metadata)) CATCH(EINVAL); /* do not allow random writes */ CATCHUNIX(buffer_putlstring(&open_files[fd].f.metadata, buffer, length)); n = length; break; default: CATCH(EBADF); } rc = 0; goto out;out: if (rc) { return (errno = rc, -1); } else { return n; /* N.B. return n on success */ }}
开发者ID:LydiaBrothers,项目名称:cctools,代码行数:36,
示例26: MailboxState_getSequint64_t MailboxState_getSeq(T M){ if (! M->seq) { Connection_T c = db_con_get(); TRY db_getmailbox_seq(M, c); CATCH(SQLException) LOG_SQLERROR; FINALLY db_con_close(c); END_TRY; } return M->seq;}
开发者ID:Alexander-KI,项目名称:dbmail,代码行数:15,
示例27: test_ascii_is_digit_hexadecimalbool test_ascii_is_digit_hexadecimal (Test *test){ int i; TITLE (); for (i = SCHAR_MIN; i <= SCHAR_MAX; i++) { if ((char)i == '0' || (char)i == '1' || (char)i == '2' || (char)i == '3' || (char)i == '4' || (char)i == '5' || (char)i == '6' || (char)i == '7' || (char)i == '8' || (char)i == '9' || (char)i == 'a' || (char)i == 'b' || (char)i == 'c' || (char)i == 'd' || (char)i == 'e' || (char)i == 'f' || (char)i == 'A' || (char)i == 'B' || (char)i == 'C' || (char)i == 'D' || (char)i == 'E' || (char)i == 'F') { CATCH (!ascii_is_digit_hexadecimal ((char)i)); } else { CATCH (ascii_is_digit_hexadecimal ((char)i)); } } PASS ();}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:36,
示例28: seaf_db_trans_queryintseaf_db_trans_query (SeafDBTrans *trans, const char *sql){ /* Handle zdb "exception"s. */ TRY Connection_execute (trans->conn, "%s", sql); RETURN (0); CATCH (SQLException) g_warning ("Error exec query %s: %s./n", sql, Exception_frame.message); return -1; END_TRY; /* Should not be reached. */ return 0;}
开发者ID:WeiY,项目名称:seafile,代码行数:15,
示例29: resolvestatic int resolve (confuga *C, const char *path, char resolved[CONFUGA_PATH_MAX]){ int rc; char collapse[CONFUGA_PATH_MAX]; char absolute[CONFUGA_PATH_MAX]; path_collapse(path, collapse, 1); CATCHUNIX(snprintf(absolute, sizeof(absolute), "%s/root/%s", C->root, collapse)); if ((size_t)rc >= CONFUGA_PATH_MAX) CATCH(ENAMETOOLONG); path_collapse(absolute, resolved, 1); rc = 0; goto out;out: return rc;}
开发者ID:xavierdingdev,项目名称:cctools,代码行数:16,
示例30: LOG_DEBUGvoid IResourceManager::onFile(const std::string &base, const std::string &file) { _base_dir = base; if (base.empty()) return; TRY { std::string preload = Finder->find(base, "preload.xml", false); if (preload.empty()) return; LOG_DEBUG(("parsing preload file: %s", preload.c_str())); PreloadParser p; p.parse_file(preload); p.update(_preload_map, _object_preload_map, base); } CATCH("parsing preload file", {});}
开发者ID:sorokin,项目名称:btanks,代码行数:16,
注:本文中的CATCH函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CATCH_BAD_ALLOC_RET函数代码示例 C++ CAST_SUM函数代码示例 |