//*****
為了記錄code的每一腳步,所以我必須要寫下這code日誌
因為學習的種類太複雜,之前忘了做這些notes還滿後悔的
所以,就是強迫做的每件事情寫在這notes上面
//*****
first 14september3
程式註解,c++
"註解",有很多都留下來作參考,但是要保持程式的易讀,所以把主要code和comment作區分,留下來參考的都寫在code的後面
--------------------------------------------------------------------------------------------------------------------------
try{} catch {} throw{} exception
看看c++的try catch end throw exception ,在此學長已經給我個範例了,所以我也記錄一下,和我自己的方式看是否看到的人能懂一些
***當我們要記錄一筆基本資料,電話姓名地址
而try 就是輸入這些基本資料的地方,意思就是 試試看 我輸入的是否正確
像我輸入我的名字,原本要輸入都是字元,不會出現符號,但是輸入錯誤,所以
try{
nameFunction("曾培))");
}catch
--------------------------------------------------------------------------------------------------------------------------
新舊的轉換 C 換 C++
看到std::cout 了嗎,這是c++的用法,而下面的fprintf是c的用法,學長說要換
std::cout << "Table Close successfully" << std::endl;
fprintf(stdout, "Table Close successfully\n");
--------------------------------------------------------------------------------------------------------------------------
觀看所有sqlite or spatialite 的資料表屬性,還有如何刪除所有XX屬性資料表,我們以view為範例
這條是觀看所有資料表的屬性和建立的指令等等::select * from sqlite_master
因為virtual的table 在sqlite_master 內 的type欄位,也是和正常一般的table一樣,所以要如何區分開來,我們看到sqlite_master 內的sql欄位,有每個table的屬性
首先如何刪除所有的view,我們利用sqlite_master來刪除,但是是有步驟的
如果我們直接下:
delect from sqlite_master where type = 'view' ;
you must got↓
SQL error:table sqlite_master may not be modified
so how will we do??
pragma writable_schema = 1 ; 開啟修改系統表
delect from sqlite_master where type = 'view' ;
pragma writable_schema = 0 ; 關閉修改系統表;
如果我們要刪除所有只要是virtual 的不管 view 或是table ,我們可以看到 在sqlite_master 的sql欄位,只要是virtual 都會有 create virtual的 字 ,所以要怎麼刪除呢??
How can I delete all virtual table ,view and any virtual in sqlite,spatialite ?
pragma writable_schema = 1 ;
delete from sqlite_master where sql like '%virtual%' or type = 'view' ;
pragma writable_schema = 0 ;
pragma writeable_schema 可以參考: you can reference:
http://www.w3cschool.cc/sqlite/sqlite-pragma.html
--------------------------------------------------------------------------------------------------------------------------
__FILE__ 和 __LINE__ 是甚麼呢?? What is c++
file 是 程式碼在甚麼檔案的名稱內 而__LINE__ 是第幾行的意思,而為什麼要做,是因為可以知道出現錯誤的檔案 和行數 ,以便來除錯
if (rc != SQLITE_OK)
{
std::string Mesg = std::string("BaiDemon::SQL error::") + zErrMsg + __FILE__ + "- >" + std::to_string(__LINE__);
sqlite3_free(zErrMsg);
throw Mesg;
}
else{
std::cout << "Table Close successfully" << std::endl;
}
try{
這次放呼叫function的區塊,也是在這個區塊,如果有throw exception 就會執行下面的catch
}
catch(std::string & error){
std::cout<< error<<std::endl;
}
//如果你丟出的錯誤訊息有error 就會執行這個catch內程式碼
CStringArray ,How to add and print ? USE C++
CString variableTest ; //create cstring array variable
add.variableTest("HelloWorld"); //add
add.variableTest("MyNameIsRay");
add.variableTest("I have four dog");
add.variableTest("TheyAreSoQ");
//print
for(int i =0 ; i < variableTest.getSize)
http://msdn.microsoft.com/zh-tw/library/tddz3etf.aspx
--------------------------------------------------------------------------------------------------------------------------
我用spatialite library 下select 指令,如果只令沒有錯誤,但select出來沒有任何東西的話要如何判斷呢??
std::string test =""; //假設沒有東西 ,但是如果我是用直接判斷為 "" 是沒有辦法成功的 不知道為啥拉,
以下為if else的簡寫
test.empty() = 0 ? std::cout "no anythings!!"<<std::endl : std::cout "your command successfully!!"<<cout::endl;
沒有留言:
張貼留言