⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ocilib_checks.h

📁 oci的源码,可以在任何平台上编译,相当方便实用
💻 H
📖 第 1 页 / 共 2 页
字号:
                        MISCELLANEOUS CHECKING MACROS
 * ************************************************************************ */

/**
 * @brief 
 * Checks if an integer parameter value fits into the given bounds
 *
 * @param con - Connection handle
 * @param v   - Integer value 
 * @param b1  - Lower bound 
 * @param b2  - Upper bound
 * @param ret - Return value
 *
 * @note
 * Throws an exception if the input value is out of bounds.
 *
 */

#define OCI_CHECK_BOUND(con, v, b1, b2, ret)                                   \
                                                                               \
    if ((v < (b1)) || (v > (b2)))                                              \
    {                                                                          \
        OCI_ExceptionOutOfBounds((con), (v));                                  \
                                                                               \
        return (ret);                                                          \
    } 

/**
 * @brief 
 * Checks if an integer parameter value is >= minimum provided value
 *
 * @param con  - Connection handle
 * @param stmt - Statement handle
 * @param v    - Integer value 
 * @param m    - Minimum value 
 * @param ret  - Return value
 *
 * @note
 * Throws an exception if the input value is < 1.
 *
 */

#define OCI_CHECK_MIN(con, stmt, v, m, ret)                                    \
                                                                               \
    if ((v) < (m))                                                             \
    {                                                                          \
        OCI_ExceptionMinimumValue((con), (stmt), m);                           \
                                                                               \
        return (ret);                                                          \
    } 

/**
 * @brief 
 * Checks if two expressions are compatible
 *
 * @param con - Connection handle
 * @param exp - Equality expression 
 * @param ret - Return value
 *
 * @note
 * Throws an exception if the 2 expressions are not compatible.
 *
 */

#define OCI_CHECK_COMPAT(con, exp, ret)                                        \
                                                                               \
    if ((exp) == FALSE)                                                         \
    {                                                                          \
        OCI_ExceptionTypeNotCompatible((con));                                 \
                                                                               \
        return (ret);                                                          \
    } 


/* ************************************************************************ *
                  INTERNAL STATES/ATTRIBUTES CHECKING MACROS
 * ************************************************************************ */

/**
 * @brief 
 * Checks if the input OCILIB object was fetched and not discartable
 *
 * @param obj - OCILIB object handle
 * @param ret - Return value
 *
 * @note
 * Returns the value 'ret' if the object was fetched from a sql statement
 *
 */

#define OCI_CHECK_OBJECT_FETCHED(obj, ret)                                     \
                                                                               \
    if ((obj)->hstate == OCI_OBJECT_FETCHED_CLEAN)                             \
        return (ret);                                                      

/**
 * @brief 
 * Checks if the status of a OCILIB statement matches the provided one
 *
 * @param st  - Statement handle
 * @param v   - Status to compare
 * @param ret - Return value
 *
 * @note
 * Throws an exception if the status of the statement equals the provided one.
 *
 */

#define OCI_CHECK_STMT_STATUS(st, v, ret)                                      \
                                                                               \
    if ((st)->status == (v))                                                   \
    {                                                                          \
        OCI_ExceptionStatementState((st), v);                                  \
        return ret;                                                            \
    }                                                                          \

/**
 * @brief 
 * Checks if the given statement is scrollable
 *
 * @param st  - Statement handle
 * @param ret - Return value
 *
 * @note
 * Throws an exception if the statement is not scrollable.
 *
 */

#define OCI_CHECK_SCROLLABLE_CURSOR_ACTIVATED(st, ret)                         \
                                                                               \
    if (((st)->nb_rbinds > 0) ||                                             \
        ((st)->exec_mode != OCI_STMT_SCROLLABLE_READONLY))                     \
    {                                                                          \
        OCI_ExceptionStatementNotScrollable(st);                               \
        return ret;                                                            \
    }

/**
 * @brief 
 * Checks if the status of a OCILIB direct path handle is compatible with the
 * given one
 *
 * @param st  - Direct path handle
 * @param v   - Status to compare
 * @param ret - Return value
 *
 * @note
 * Throws an exception if the status of the direct path handle is different than
 * the provided one.
 *
 */
#define OCI_CHECK_DIRPATH_STATUS(dp, v, ret)                                   \
                                                                               \
    if ((dp)->status != (v))                                                   \
    {                                                                          \
        OCI_ExceptionDirPathState((dp), (dp)->status);                         \
        return ret;                                                            \
    } 


/* ************************************************************************ *
                    INTERNAL FEATURES AVAILABILITY CHECKING MACROS
 * ************************************************************************ */

/**
 * @brief 
 * Checks the library has been initialized
 *
 * @param ret - Return value
 *
 * @note
 * Returns 'ret' if the library has not been initialized
 *
 */

#define OCI_CHECK_INITIALIZED(ret)                                             \
                                                                               \
        if (OCILib.loaded == FALSE)                                            \
        {                                                                      \
            OCI_ExceptionNotInitialized();                                     \
            return ret;                                                        \
        }

/**
 * @brief 
 * Internal check for various features
 *
 * @param con  - Connection handle
 * @param feat - Feature to check
 * @param ver  - OCI version that introduced the feature
 * @param ret  - Return value
*
 * @note
 * Throws an exception the given feature is not available
 *
 */

#define OCI_CHECK_FEATURE(con, feat, ver,  ret)                                \
                                                                               \
    if (OCILib.ver_runtime < ver || (((con) != NULL) && (con)->ver_maj < ver)) \
    {                                                                          \
        OCI_ExceptionNotAvailable(con, feat);                                  \
        return ret;                                                            \
    }

/**
 * @brief 
 * Checks if multithreading mode is activated
 *
 * @param ret - Return value
 *
 * @note
 * Throws an exception the library has not been initialized with multithreading
 * mode
 *
 */

#define OCI_CHECK_THREAD_ENABLED(ret)                                          \
                                                                               \
        if ((OCI_LIB_THREADED) == FALSE)                                       \
        {                                                                      \
            OCI_ExceptionNotMultithreaded();                                   \
            return ret;                                                        \
        }

/**
 * @brief 
 * Checks if the timestamp datatype is supported by the connection
 *
 * @param con - Connection handle
 * @param ret - Return value
 *
 * @note
 * Throws an exception if the connection (client and server versions) does not
 * support timestamps
 *
 */

#define OCI_CHECK_TIMESTAMP_ENABLED(con,  ret)                                 \
                                                                               \
        OCI_CHECK_FEATURE(con, OCI_FEATURE_TIMESTAMP, OCI_9, ret)

/**
 * @brief 
 * Checks if the interval datatype is supported by the connection
 *
 * @param con - Connection handle
 * @param ret - Return value
 *
 * @note
 * Throws an exception if the connection (client and server versions) does not
 * support intervals
 *
 */

#define OCI_CHECK_INTERVAL_ENABLED OCI_CHECK_TIMESTAMP_ENABLED

/**
 * @brief 
 * Checks if the connection supports scrollable cursors
 *
 * @param con - Connection handle
 * @param ret - Return value
 *
 * @note
 * Throws an exception if the connection (client and server versions) does not
 * support scrollable cursors
 *
 */

#define OCI_CHECK_SCROLLABLE_CURSOR_ENABLED(con, ret)                          \
                                                                               \
        OCI_CHECK_FEATURE(con, OCI_FEATURE_SCROLLABLE_CURSOR, OCI_9, ret)


/**
 * @brief 
 * Checks if the direct path date caching is available
 *
 * @param con - Connection handle
 * @param ret - Return value
 *
 * @note
 * Throws an exception if the Oracle client does not support date caching
 *
 */

#define OCI_CHECK_DIRPATH_DATE_CACHE_ENABLED(dp,  ret)                         \
                                                                               \
    if (OCILib.ver_runtime < OCI_9)                                            \
    {                                                                          \
        OCI_ExceptionNotAvailable((dp)->con, OCI_FEATURE_DIRPATH_DATE_CACHE);  \
        return ret;                                                            \
    }


#endif    /* OCILIB_OCILIB_CHECKS_H_INCLUDED */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -