• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            r2100

              C++博客 :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
              8 Posts :: 9 Stories :: 2 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(3)

            我參與的團(tuán)隊(duì)

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            2015年12月21日 #

            ld在鏈接的時(shí)候找不到所需的動(dòng)態(tài)庫(kù)
            1、安裝所需的動(dòng)態(tài)庫(kù)
            2、修改鏈接查找路徑配置文件 二選一
               a)、在有root權(quán)限情況下:
                  echo "usr/local/lib >> /etc/ld.so.conf"
               b)、在沒(méi)有root權(quán)限的情況下:
                  $ echo "export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> ~/.bashrc


            ps:查找?guī)斓姆椒?br />
            $ locate libiconv.so.2
            $ whereis libiconv.so.2
            $ find /usr /lib -name libiconv.so.2
            $ find / -name libiconv.so.2 2>/dev/null





            posted @ 2015-12-21 11:53 r2100 閱讀(201) | 評(píng)論 (0)編輯 收藏

            2015年12月20日 #

            cat -A 能看到符號(hào)
            Windows: ^M$     CR LF
            Linux:   $          LF

            對(duì)于文本問(wèn)題,可以使用 UNIX2dox、dos2UNIX 轉(zhuǎn)換
            posted @ 2015-12-20 23:02 r2100 閱讀(240) | 評(píng)論 (0)編輯 收藏

            2011年4月6日 #

             

            // 把一個(gè)wstring轉(zhuǎn)化為string
            std::string& to_string(std::string& dest, std::wstring const & src)
            {
               std::setlocale(LC_CTYPE, 
            "");

               size_t 
            const mbs_len = wcstombs(NULL, src.c_str(), 0);
               std::vector
            <char> tmp(mbs_len + 1);
               wcstombs(
            &tmp[0], src.c_str(), tmp.size());

               dest.assign(tmp.begin(), tmp.end() 
            - 1);

               
            return dest;
            }

            // 把一個(gè)string轉(zhuǎn)化為wstring
            std::wstring& to_wstring(std::wstring& dest, std::string const & src)
            {
               std::setlocale(LC_CTYPE, 
            "");

               size_t 
            const wcs_len = mbstowcs(NULL, src.c_str(), 0);
               std::vector
            <wchar_t> tmp(wcs_len + 1);
               mbstowcs(
            &tmp[0], src.c_str(), src.size());

               dest.assign(tmp.begin(), tmp.end() 
            - 1);

               
            return dest;

            posted @ 2011-04-06 17:58 r2100 閱讀(2554) | 評(píng)論 (0)編輯 收藏


            對(duì)于C++類:顯示地寫(xiě)出拷貝構(gòu)造函數(shù),重載賦值操作符和析構(gòu)函數(shù)是良好的習(xí)慣,但在寫(xiě)構(gòu)造函數(shù)時(shí)需要注意一些容易的錯(cuò)誤,如下面的代碼:

             

            #include <iostream>

            using namespace std;

             

            class M{

            public:

                M()
            {}

                M(
            const M &m){

                   cout
            <<"copy construtor"<<endl;

                   
            operator =(m);

                }


                M 
            operator =(const M &m){   //問(wèn)題出在此處

                   cout
            <<"operator ="<<endl;

                   
            return *this;

                }


            }
            ;

             

            int main() {

                M m1;

                M m2;

                m2
            =m1;

                
            return 0;

            }

             

            在下面三種情況下會(huì)調(diào)用拷貝構(gòu)造函數(shù):

            (1)用一個(gè)已經(jīng)實(shí)例化了的該類對(duì)象,去實(shí)例化該類的另外一個(gè)對(duì)象;

            (2)用該類的對(duì)象傳值的方式作為一個(gè)函數(shù)的參數(shù);

            (3)一個(gè)函數(shù)返回值為該類的一個(gè)對(duì)象。

            特別地,對(duì)于語(yǔ)句 M m;  M mm=m; 屬于(1)情況,即語(yǔ)句M mm=m;調(diào)用的是拷貝構(gòu)造函數(shù),而不是構(gòu)造函數(shù)。

             

            但在重載=操作符時(shí),返回值不是引用類型將導(dǎo)致程序運(yùn)行出現(xiàn)嚴(yán)重問(wèn)題。即如果出現(xiàn)上面會(huì)調(diào)用拷貝構(gòu)造函數(shù)的三種情況之一,或者使用=操作符時(shí),拷貝構(gòu)造函數(shù)和operator =將循環(huán)遞歸調(diào)用,導(dǎo)致程序出現(xiàn)死循環(huán)。原因是拷貝構(gòu)造函數(shù)和operator =之間不斷地重復(fù)調(diào)用。

            解決辦法:將operator =的返回類型改為引用類型M&,此時(shí)調(diào)用operator =時(shí)不會(huì)去調(diào)用拷貝構(gòu)造函數(shù)。

             

            還有,若要寫(xiě)clone時(shí),若通過(guò)下面的方式:

             

                M clone(){

                   cout
            <<"clone"<<endl;

                   
            return *this;

                }


            前提是拷貝構(gòu)造函數(shù)不能調(diào)用clone來(lái)完成拷貝,否則出現(xiàn)上面同樣的問(wèn)題,下面的代碼就會(huì)出現(xiàn)這樣的問(wèn)題

               

            M(const M &m){

                   cout
            <<"copy construtor"<<endl;

                   clone();

                }


            總之,在寫(xiě)這些函數(shù)時(shí),要特別留意彼此的調(diào)用關(guān)系。

            以下是我的慣用寫(xiě)法:

            (A)對(duì)于拷貝構(gòu)造函數(shù)和重載=操作符

              

              M(const M &m){

                   cout
            <<"copy construtor"<<endl;

                   
            operator =(m);

                }


                M
            & operator =(const M &m){  //問(wèn)題出在此處

                   cout
            <<"operator ="<<endl;

                   
            /* 此處寫(xiě)上成員數(shù)據(jù)的拷貝 */

                   
            return *this;

                }


            這里寫(xiě)成了inline函數(shù),只是方便說(shuō)明問(wèn)題,其實(shí)不必非要這么寫(xiě),可以采取先聲明,后定義的常規(guī)方法。

            (B)對(duì)于clone函數(shù)

            聲明:  virtual M clone();   //考慮繼承時(shí)的多態(tài)

            定義:  

            M M::clone(){

                   cout
            <<"clone"<<endl;

                   
            //將在調(diào)用處直接調(diào)用構(gòu)造函數(shù),效率高,避免返回局部變量,更安全

                   
            return M();

                }



             

            posted @ 2011-04-06 13:18 r2100 閱讀(731) | 評(píng)論 (0)編輯 收藏

            2008年9月12日 #


            老板要求重用SQLHSTMT句柄,找到一些資料
            1、使用SQLExecDirect執(zhí)行了查詢語(yǔ)句,記錄集會(huì)存放在hstmt中,
            2、通過(guò)SQLBindCol把記錄集和變量綁定。
            3、SQLFreeStmt(hstmt, SQL_UNBIND);釋放由先前對(duì)此語(yǔ)句句柄進(jìn)行的 SQLBindCol() 調(diào)用綁定的所有列(應(yīng)用程序變量或文件引用與結(jié)果集列之間的關(guān)聯(lián)將斷開(kāi))。
            4、SQLCloseCursor(hstmt);將關(guān)閉任何與語(yǔ)句句柄相關(guān)聯(lián)的游標(biāo)并廢棄任何暫掛結(jié)果

            如果不需要使用返回的結(jié)果集
            1、使用SQLExecDirect執(zhí)行了查詢語(yǔ)句,記錄集會(huì)存放在hstmt中,
            2、SQLCloseCursor(hstmt)或者SQLFreeStmt(hstmt,SQL_CLOSE )將關(guān)閉任何與語(yǔ)句句柄相關(guān)聯(lián)的游標(biāo)并廢棄任何暫掛結(jié)果





            posted @ 2008-09-12 16:04 r2100 閱讀(268) | 評(píng)論 (0)編輯 收藏

            2008年9月11日 #

            SQLExecDirect函數(shù)源代碼
            static SQLRETURN
            ODBCExecDirect(ODBCStmt 
            *stmt, SQLCHAR *szSqlStr, SQLINTEGER nSqlStr)
            {
                
            char *query;
                MapiMsg ret;
                MapiHdl hdl;

                hdl 
            = stmt->hdl;

                
            if (stmt->State >= EXECUTED1 || (stmt->State == EXECUTED0 && mapi_more_results(hdl))) {
                    
            /* Invalid cursor state */
                    addStmtError(stmt, 
            "24000", NULL, 0);
                    
            return SQL_ERROR;
                }

                
            /* TODO: convert ODBC escape sequences ( {d 'value'} or {t 'value'} or
                   {ts 'value'} or {escape 'e-char'} or {oj outer-join} or
                   {fn scalar-function} etc. ) to MonetDB SQL syntax 
            */
                query 
            = ODBCTranslateSQL(szSqlStr, (size_t) nSqlStr, stmt->noScan);

                ODBCResetStmt(stmt);

            #ifdef ODBCDEBUG
                ODBCLOG(
            "SQLExecDirect: \"%s\"\n", query);
            #endif

                ret 
            = mapi_query_handle(hdl, query);
                free(query);
                
            switch (ret) {
                
            case MOK:
                    
            break;
                
            case MTIMEOUT:
                    
            /* Communication link failure */
                    addStmtError(stmt, 
            "08S01", mapi_error_str(stmt->Dbc->mid), 0);
                    
            return SQL_ERROR;
                
            default:
                    
            /* General error */
                    addStmtError(stmt, 
            "HY000", mapi_error_str(stmt->Dbc->mid), 0);
                    
            return SQL_ERROR;
                }

                
            /* now get the result data and store it to our internal data structure */

                
            return ODBCInitResult(stmt);
            }

            As mentioned earlier, it is more efficient to reuse statements than to drop them and allocate new ones. Before executing a new SQL statement on a statement, applications should be sure that the current statement settings are appropriate. These include statement attributes, parameter bindings, and result set bindings. Generally, parameters and result sets for the old SQL statement need to be unbound (by calling SQLFreeStmt with the SQL_RESET_PARAMS and SQL_UNBIND options) and rebound for the new SQL statement.

            When the application has finished using the statement, it calls SQLFreeHandle to free the statement. After freeing the statement, it is an application programming error to use the statement's handle in a call to an ODBC function; doing so has undefined but probably fatal consequences.

            When SQLFreeHandle is called, the driver releases the structure used to store information about the statement.

            SQLDisconnect automatically frees all statements on a connection.


                     
            /**********************************************
             * ODBCStmt.c
             *
             * Description:
             * This file contains the functions which operate on
             * ODBC statement structures/objects (see ODBCStmt.h).
             *
             * Author: Martin van Dinther
             * Date  : 30 aug 2002
             *
             *********************************************
            */

            #include 
            "ODBCGlobal.h"
            #include 
            "ODBCStmt.h"

            #define ODBC_STMT_MAGIC_NR  5461    /* for internal sanity check only */


            /*
             * Creates a new allocated ODBCStmt object and initializes it.
             *
             * Precondition: none
             * Postcondition: returns a new ODBCStmt object
             
            */
            ODBCStmt 
            *
            newODBCStmt(ODBCDbc 
            *dbc)
            {
                ODBCStmt 
            *stmt = (ODBCStmt *) malloc(sizeof(ODBCStmt));
                assert(stmt);

                assert(dbc);
                assert(dbc
            ->mid);

                
            if (stmt == NULL) {
                    
            /* Memory allocation error */
                    addDbcError(dbc, 
            "HY001", NULL, 0);
                    
            return NULL;
                }

                stmt
            ->Dbc = dbc;
                stmt
            ->Error = NULL;
                stmt
            ->RetrievedErrors = 0;

                stmt
            ->State = INITED;
                stmt
            ->hdl = mapi_new_handle(dbc->mid);
                
            if (stmt->hdl == NULL) {
                    
            /* Memory allocation error */
                    addDbcError(dbc, 
            "HY001", NULL, 0);
                    free(stmt);
                    
            return NULL;
                }
                assert(stmt
            ->hdl);

                stmt
            ->currentRow = 0;
                stmt
            ->startRow = 0;
                stmt
            ->rowSetSize = 0;
                stmt
            ->queryid = -1;
                stmt
            ->nparams = 0;
                stmt
            ->querytype = -1;
                stmt
            ->rowcount = 0;

                
            /* add this stmt to the administrative linked stmt list */
                stmt
            ->next = dbc->FirstStmt;
                dbc
            ->FirstStmt = stmt;

                stmt
            ->cursorType = SQL_CURSOR_FORWARD_ONLY;
                stmt
            ->cursorScrollable = SQL_NONSCROLLABLE;
                stmt
            ->retrieveData = SQL_RD_ON;
                stmt
            ->noScan = SQL_NOSCAN_OFF;

                stmt
            ->ApplRowDescr = newODBCDesc(dbc);
                stmt
            ->ApplParamDescr = newODBCDesc(dbc);
                stmt
            ->ImplRowDescr = newODBCDesc(dbc);
                stmt
            ->ImplParamDescr = newODBCDesc(dbc);
                stmt
            ->AutoApplRowDescr = stmt->ApplRowDescr;
                stmt
            ->AutoApplParamDescr = stmt->ApplParamDescr;

                
            if (stmt->ApplRowDescr == NULL || stmt->ApplParamDescr == NULL || stmt->ImplRowDescr == NULL || stmt->ImplParamDescr == NULL) {
                    destroyODBCStmt(stmt);
                    
            return NULL;
                }

                stmt
            ->ApplRowDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
                stmt
            ->ApplParamDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
                stmt
            ->ImplRowDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
                stmt
            ->ImplParamDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO;
                stmt
            ->ImplRowDescr->Stmt = stmt;
                stmt
            ->ImplParamDescr->Stmt = stmt;

                stmt
            ->Type = ODBC_STMT_MAGIC_NR;    /* set it valid */

                
            return stmt;
            }

            SQLFreeHandle
            ODBCFreeStmt_(ODBCStmt 
            *stmt)
            {
                
            /* check if statement is not active */
                
            if (stmt->State >= EXECUTED0) {
                    
            /* should be closed first */
                    
            if (SQLFreeStmt_(stmt, SQL_CLOSE) == SQL_ERROR)
                        
            return SQL_ERROR;
                }

                
            /* Ready to destroy the stmt handle */
                destroyODBCStmt(stmt);
                
            return SQL_SUCCESS;
            }


            SQLFreeStmt

            SQLFreeStmt_(ODBCStmt 
            *stmt, SQLUSMALLINT option)
            {
                
            switch (option) {
                
            case SQL_CLOSE:
                    
            /* Note: this option is also called from SQLCancel() and
                       SQLCloseCursor(), so be careful when changing the code 
            */
                    
            /* close cursor, discard result set, set to prepared */
                    setODBCDescRecCount(stmt
            ->ImplRowDescr, 0);
                    stmt
            ->currentRow = 0;
                    stmt
            ->startRow = 0;
                    stmt
            ->rowSetSize = 0;

                    
            if (stmt->State == EXECUTED0)
                        stmt
            ->State = stmt->queryid >= 0 ? PREPARED0 : INITED;
                    
            else if (stmt->State >= EXECUTED1)
                        stmt
            ->State = stmt->queryid >= 0 ? PREPARED1 : INITED;

                    
            /* Important: do not destroy the bind parameters and columns! */
                    
            return SQL_SUCCESS;
                
            case SQL_DROP:
                    
            return ODBCFreeStmt_(stmt);
                
            case SQL_UNBIND:
                    setODBCDescRecCount(stmt
            ->ApplRowDescr, 0);
                    
            return SQL_SUCCESS;
                
            case SQL_RESET_PARAMS:
                    setODBCDescRecCount(stmt
            ->ApplParamDescr, 0);
                    setODBCDescRecCount(stmt
            ->ImplParamDescr, 0);
                    mapi_clear_params(stmt
            ->hdl);
                    
            return SQL_SUCCESS;
                
            default:
                    
            /* Invalid attribute/option identifier */
                    addStmtError(stmt, 
            "HY092", NULL, 0);
                    
            return SQL_ERROR;
                }

                
            /* not reached */
            }

            SQLHSTMT的結(jié)構(gòu)
            typedef 
            struct tODBCDRIVERSTMT {
                
            /* Stmt properties */
                
            int Type;        /* structure type, used for handle validy test */
                ODBCError 
            *Error;    /* pointer to an Error object or NULL */
                
            int RetrievedErrors;    /* # of errors already retrieved by SQLError */
                ODBCDbc 
            *Dbc;        /* Connection context */
                
            struct tODBCDRIVERSTMT *next;    /* the linked list of stmt's in this Dbc */
                
            enum StatementState State;    /* needed to detect invalid cursor state */
                MapiHdl hdl;

                unsigned 
            int rowcount;    /* # affected rows */

                
            /* startRow is the row number of first row in the result
                   set (0 based); rowSetSize is the number of rows in the
                   current result set; currentRow is the row number of the
                   current row within the current result set 
            */
                unsigned 
            int currentRow;
                unsigned 
            int startRow;
                unsigned 
            int rowSetSize;

                unsigned 
            int currentCol; /* used by SQLGetData() */
                SQLINTEGER retrieved;    
            /* amount of data retrieved */
                
            int queryid;        /* the query to be executed */
                
            int nparams;        /* the number of parameters expected */

                
            int querytype;        /* query type as returned by server */

                SQLUINTEGER cursorType;
                SQLUINTEGER cursorScrollable;
                SQLUINTEGER retrieveData;
                SQLUINTEGER noScan;

                ODBCDesc 
            *ApplRowDescr;    /* Application Row Descriptor (ARD) */
                ODBCDesc 
            *ApplParamDescr; /* Application Parameter Descriptor (APD) */
                ODBCDesc 
            *ImplRowDescr;    /* Implementation Row Descriptor (IRD) */
                ODBCDesc 
            *ImplParamDescr; /* Implementation Parameter Descriptor (IPD) */

                ODBCDesc 
            *AutoApplRowDescr; /* Auto-allocated ARD */
                ODBCDesc 
            *AutoApplParamDescr; /* Auto-allocated APD */

                
            /* Stmt children: none yet */
            } ODBCStmt;






            posted @ 2008-09-11 11:31 r2100 閱讀(1158) | 評(píng)論 (2)編輯 收藏

            2008年2月26日 #

            Dom Programming Guid: (Apache)http://www.slac.stanford.edu/exp/glast/ground/software/extDoc/xerces/2_6_0/doc/program-dom.html#validation-dynamic

            Java與XML聯(lián)合編程之DOM篇:http://kimmyzhang.zhmy.com/archives/2006/9579.shtml

            DOM初步及jdom的介紹http://www.xml.org.cn/dispbbs.asp?boardID=11&ID=37000

            DOM的一些介紹http://blog.sina.com.cn/u/57db2a730100037i

            用Xerces操作XML文檔:http://blog.sina.com.cn/u/57db2a73010002p5

            使用 Xerces-C++ 緩存和序列化 XML 模式:http://www-128.ibm.com/developerworks/cn/xml/x-xsdxerc.html

            充分利用 Xerces-C++,第 1 部分:http://www-128.ibm.com/developerworks/cn/xml/x-xercc/

            充分利用 Xerces-C++,第 1 部分http://www-128.ibm.com/developerworks/cn/xml/x-xercc2/


            技巧: 如何利用Xerces C++正確處理XML文檔中的WhiteSpaceL:http://www-128.ibm.com/developerworks/cn/xml/tips/x-xercesc2/

            淺談利用Xerces C++解析XML文檔
            http://hi.baidu.com/fx0517/blog/item/258f12d53c32c6c451da4bb3.html


            apache xerces c++ windows 下編譯與vc6實(shí)例 

            http://blog.csdn.net/smq65/archive/2006/09/04/1174368.aspx

            posted @ 2008-02-26 21:12 r2100 閱讀(337) | 評(píng)論 (0)編輯 收藏

            2008年1月31日 #

            低級(jí)錯(cuò)誤:在頭文件中定義全局變量
            posted @ 2008-01-31 09:52 r2100| 編輯 收藏

            久久亚洲日韩精品一区二区三区| 久久精品国产精品亚洲精品 | 亚洲AV无码1区2区久久| 99精品国产综合久久久久五月天| 久久精品国产亚洲AV无码麻豆 | 狠色狠色狠狠色综合久久| 久久精品夜色噜噜亚洲A∨| 国产A三级久久精品| 国内精品久久久久久久涩爱 | 狠狠色噜噜色狠狠狠综合久久| 99久久精品午夜一区二区| 久久久久人妻一区精品果冻| 国产精品久久久久久吹潮| 久久青青色综合| 欧美性大战久久久久久| 国产精品久久精品| 久久精品国产亚洲AV香蕉| 日韩久久无码免费毛片软件| 伊人久久大香线焦综合四虎| 国产综合久久久久| 久久精品人人做人人爽电影蜜月| 久久影院亚洲一区| 久久国产视屏| 久久久久久极精品久久久 | 天天做夜夜做久久做狠狠| 99久久www免费人成精品| 精品国产乱码久久久久久1区2区 | 国产99久久九九精品无码| 久久国产乱子伦精品免费强| 亚洲AV日韩精品久久久久| 久久影院综合精品| 国产精品9999久久久久| 2020久久精品国产免费| 久久久久99精品成人片欧美| 亚洲国产另类久久久精品| 久久午夜伦鲁片免费无码| AV无码久久久久不卡网站下载| 久久天天躁狠狠躁夜夜96流白浆| 97久久精品人妻人人搡人人玩 | 狠狠久久亚洲欧美专区| 精品国产青草久久久久福利|