コード例 #1
0
int CStorageUnitInfoTable::GetCapacityInfo(const char* buf, sCapacityInfo *pInfo)
{
    if(!m_pDB) 
    {
        cout<<"Invalid Sqlite"<<endl;
        return -1;
    }    

    try
    {
        CppSQLite3Query q = m_pDB->execQuery(buf);
        if(!q.eof())
        {
            pInfo->m_sumCap = q.getInt64Field("sumCapacity");
            pInfo->m_declaredCap = q.getInt64Field("declaredCapacity");
            pInfo->m_usedCap = q.getInt64Field("usedCapacity");
        }
        else
           return -1; 

    }

    catch(CppSQLite3Exception e)
    {
        cerr<<"CStorageUnitInfoTable::GetCapacityInfo:"<<e.errorCode()<<" "<<e.errorMessage()<<endl;
    }

    return 0;
}
コード例 #2
0
int CStorageUnitInfoTable::GetSysCapacityInfo(sCapacityInfo *pInfo)
{
    char buf[MAX_BUF_LEN];
    memset(buf, 0, MAX_BUF_LEN);
    sprintf(buf, "select sum(sumCapacity), sum(declaredCapacity), sum(usedCapacity) from %s", m_strTableName.c_str());
    if(!m_pDB) 
    {
        cout<<"Invalid Sqlite"<<endl;
        return -1;
    }    

    try
    {
        CppSQLite3Query q = m_pDB->execQuery(buf);
        if(!q.eof())
        {
            pInfo->m_sumCap = q.getInt64Field(0);
            pInfo->m_declaredCap = q.getInt64Field(1);
            pInfo->m_usedCap = q.getInt64Field(2);
        }
        else
           return -1; 

    }

    catch(CppSQLite3Exception e)
    {
        cerr<<"CStorageUnitInfoTable::GetSysCapacityInfo:"<<e.errorCode()<<" "<<e.errorMessage()<<endl;
    }


    return 0;
}
コード例 #3
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
tstring CBrainMemory::RetrieveToken(int64 RoomID){
	int64 CurrentRoomValue,RoomType; 
    int64  CurrentID = RoomID;
	
	//首先得到意义空间的信息
	if(!GetRoomInfo(RoomID,CurrentRoomValue,RoomType)){
		return NULL;
	}
	
	deque<int64> BodyList;
	while(1)
	{
		//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
		CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
		if(Result.eof())return 0;
		CurrentID = Result.getInt64Field(0);  //fatherID
		if(CurrentID == ROOT_SPACE)break;;
		CurrentRoomValue = Result.getInt64Field(1); //fatherValuse
        BodyList.push_front(CurrentRoomValue);
	}	

	tstring s;
	for (int i=0; i<BodyList.size(); i++)
	{
		int64 ID = BodyList[i];
		TCHAR ch = (TCHAR)ID;
		s += ch;
	}
	return s;
}
コード例 #4
0
ファイル: Space.cpp プロジェクト: GMIS/GMIS
void  GetAllVisiter(int64 ParentID, vector<int64>& VisiterList,int64 NotIncludeChildID/*=0*/){

	char TableName[30];
	int64toa(ParentID,TableName);
	if(!GetWorldDB().tableExists(TableName)){
		return ;
	}

	CppSQLite3Buffer SQL;
	SQL.format("select %s from \"%s\" where  %s>%d",
		ITEM_ID,
		TableName,
		ITEM_TYPE,
		OBJECT_SPACE
		);

	CppSQLite3Query Result = GetWorldDB().execQuery(SQL);
	if(Result.eof())return ;

	while(!Result.eof()){
		int64  ChildID = Result.getInt64Field(0);
		if (ChildID != NotIncludeChildID)
		{
			VisiterList.push_back(ChildID);			
		}
		Result.nextRow();
	}
}
コード例 #5
0
ファイル: wizIndexBase.cpp プロジェクト: flyfire/WizQTClient
bool CWizIndexBase::SQLToDocumentAttachmentDataArray(const CString& strSQL,
                                                     CWizDocumentAttachmentDataArray& arrayAttachment)
{
    try
    {
        CppSQLite3Query query = m_db.execQuery(strSQL);
        while (!query.eof())
        {
            WIZDOCUMENTATTACHMENTDATA data;
            data.strKbGUID = kbGUID();
            data.strGUID = query.getStringField(documentattachmentATTACHMENT_GUID);
            data.strDocumentGUID = query.getStringField(documentattachmentDOCUMENT_GUID);
            data.strName = query.getStringField(documentattachmentATTACHMENT_NAME);
            data.strURL = query.getStringField(documentattachmentATTACHMENT_URL);
            data.strDescription = query.getStringField(documentattachmentATTACHMENT_DESCRIPTION);
            data.tInfoModified = query.getTimeField(documentattachmentDT_INFO_MODIFIED);
            data.strInfoMD5 = query.getStringField(documentattachmentATTACHMENT_INFO_MD5);
            data.tDataModified = query.getTimeField(documentattachmentDT_DATA_MODIFIED);
            data.strDataMD5 = query.getStringField(documentattachmentATTACHMENT_DATA_MD5);
            data.nVersion = query.getInt64Field(documentattachmentVersion);

            arrayAttachment.push_back(data);
            query.nextRow();
        }

        std::sort(arrayAttachment.begin(), arrayAttachment.end());
        return true;
    }
    catch (const CppSQLite3Exception& e)
    {
        return LogSQLException(e, strSQL);
    }
}
コード例 #6
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
/*
int32 CBrainMemory::GetAllMeaning(int64 ID, map<int64,int64> 
&MeaningList){

	   CppSQLite3Buffer SQL;
	   CppSQLite3Query  Result;
       char a[30];
	   char b[30];
      
       MeaningList.clear();
	
//	   if(!RBrainHasTable(ID))return 0;
	   
	   ToRBrain(ID);
	   SQL.format("select %s, %s  from \"%s\" where %s=\"%s\" ;",
						RB_SPACE_ID,
		                RB_SPACE_VALUE,
			            _i64toa(ID,a,10),
						RB_SPACE_TYPE,
						_i64toa(MEMORY_TYPE_MEANING,b,10)                  
						);
	   Result = BrainDB.execQuery(SQL);
       
	   while(!Result.eof())
	   {
          MeaningList[Result.getInt64Field(1)] = Result.getInt64Field(0);
		  Result.nextRow();
	   }
	   return MeaningList.size();
}
*/	
int32 CBrainMemory::GetAllMeaningRoomID(int64 ID, deque<int64>& MeaningRoomIDList){
	   CppSQLite3Buffer SQL;
	   CppSQLite3Query  Result;
       char a[30],b[30];      
       MeaningRoomIDList.clear();
	
//	   if(!RBrainHasTable(ID))return 0;
	   
	   ToRBrain(ID);

	   int64toa(ID,a);
	   int64toa(MEMORY_BODY,b);
	   SQL.format("select %s  from \"%s\" where %s > \"%s\";",
						RB_SPACE_ID,
			            a, 
						RB_SPACE_TYPE,
						b                   
						);
	   Result = BrainDB.execQuery(SQL);
       
	   while(!Result.eof())
	   {
          MeaningRoomIDList.push_back(Result.getInt64Field(0));
		  Result.nextRow();
	   }
	   return MeaningRoomIDList.size();
}
コード例 #7
0
ファイル: wizIndexBase.cpp プロジェクト: flyfire/WizQTClient
bool CWizIndexBase::SQLToTagDataArray(const CString& strSQL, CWizTagDataArray& arrayTag)
{
    try
    {
        CppSQLite3Query query = m_db.execQuery(strSQL);
        while (!query.eof())
        {
            WIZTAGDATA data;
            data.strKbGUID = kbGUID();
            data.strGUID = query.getStringField(tagTAG_GUID);
            data.strParentGUID = query.getStringField(tagTAG_GROUP_GUID);
            data.strName = query.getStringField(tagTAG_NAME);
            data.strDescription = query.getStringField(tagTAG_DESCRIPTION);
            data.tModified = query.getTimeField(tagDT_MODIFIED);
            data.nVersion = query.getInt64Field(tagVersion);

            arrayTag.push_back(data);
            query.nextRow();
        }

        std::sort(arrayTag.begin(), arrayTag.end());
        return true;
    }
    catch (const CppSQLite3Exception& e)
    {
        return LogSQLException(e, strSQL);
    }
}
コード例 #8
0
ファイル: wizIndexBase.cpp プロジェクト: flyfire/WizQTClient
bool CWizIndexBase::SQLToStyleDataArray(const CString& strSQL, CWizStyleDataArray& arrayStyle)
{
    try
    {
        CppSQLite3Query query = m_db.execQuery(strSQL);
        while (!query.eof())
        {
            WIZSTYLEDATA data;
            data.strKbGUID = kbGUID();
            data.strGUID = query.getStringField(styleSTYLE_GUID);
            data.strName = query.getStringField(styleSTYLE_NAME);
            data.strDescription = query.getStringField(styleSTYLE_DESCRIPTION);
            data.crTextColor = query.getColorField(styleSTYLE_TEXT_COLOR);
            data.crBackColor = query.getColorField(styleSTYLE_BACK_COLOR);
            data.bTextBold = query.getBoolField(styleSTYLE_TEXT_BOLD);
            data.nFlagIndex = query.getIntField(styleSTYLE_FLAG_INDEX);
            data.tModified = query.getTimeField(styleDT_MODIFIED);
            data.nVersion = query.getInt64Field(styleVersion);

            arrayStyle.push_back(data);
            query.nextRow();
        }

        std::sort(arrayStyle.begin(), arrayStyle.end());
        return true;
    }
    catch (const CppSQLite3Exception& e)
    {
        return LogSQLException(e, strSQL);
    }
}
コード例 #9
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
int64 CBrainMemory::GetChildType(int64 ParentRoomID,int64 ChildRoomID){
	ToRBrain(ParentRoomID);
 	 	
	if(!RBrainHasTable(ParentRoomID))return 0;

	CppSQLite3Buffer SQL;
	CppSQLite3Query  Result;
	char a[30],b[30];
   
	assert(ChildRoomID != 0 );
	int64toa(ParentRoomID,a);
	int64toa(ChildRoomID,b);

	SQL.format("select \"%s\" from \"%s\" where \"%s\" = \"%s\" ",
				RB_SPACE_TYPE,
				a,
				RB_SPACE_ID,
				b
				);
				
	Result = BrainDB.execQuery(SQL);
    if(Result.eof())return 0;  

	int64 ChildType = Result.getInt64Field(0);
	return ChildType;
};
コード例 #10
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
int64 CBrainMemory::GetChildID(int64 ParentRoom,int64 ChildRoomValue,int64 ChildRoomType)
{
	ToRBrain(ParentRoom);
    int64 ChildID;
	 
	
	if(!RBrainHasTable(ParentRoom))return 0;

	CppSQLite3Buffer SQL;
	CppSQLite3Query  Result;
	char a[30],b[30],c[30];
   
	assert(ChildRoomValue != 0 || ChildRoomType != 0);

	int64toa(ParentRoom,a);
	int64toa(ChildRoomValue,b);
	int64toa(ChildRoomType,c);

	SQL.format("select \"%s\" from \"%s\" where \"%s\" = \"%s\" and \"%s\" = %s;",
				RB_SPACE_ID,
				a,
				RB_SPACE_VALUE,
				b,				
				RB_SPACE_TYPE,
				c
				);
				
	Result = BrainDB.execQuery(SQL);
    if(Result.eof())return 0;  

	ChildID = Result.getInt64Field(0);
	return ChildID;
}
コード例 #11
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
//返回一个Ojbect/people的存储路径,不包括CRC32
uint32  CBrainMemory::RetrieveObject(int64 RoomID,tstring& Text){
	int64 CurrentRoomValue,RoomType; 
    int64  CurrentID = RoomID;

	//首先得到意义空间的信息
	GetRoomInfo(RoomID,CurrentRoomValue,RoomType);
	if (RoomType == MEMORY_OBJECT){
		Text = _T("Object: ");
	}else if(RoomType == MEMORY_PEOPLE)
	{
        Text = _T("People: ");
	}else return 0;
	uint32 crc = CurrentRoomValue;

	deque<int64> MeaingList;
	while(1)
	{
		//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
		CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
		if(Result.eof())return 0;
 		CurrentID = Result.getInt64Field(0);  //fatherID
		if(CurrentID == ROOT_SPACE)break;;
	    CurrentRoomValue = Result.getInt64Field(1); //fatherValuse
        MeaingList.push_front(CurrentRoomValue);
	} 

	deque<int64>::iterator It = MeaingList.begin();
	deque<int64>::iterator ItEnd = MeaingList.end();
	int64 ID = *It;
	IP ip((uint32)ID);

	AnsiString s = ip.Get();
	tstring ws = UTF8toWS(s);
	Text += ws;

	It++;
	tstring Name;
	while (It <ItEnd){
		ID = *It;
  	    Text += _T("\\");
		if(!RetrieveText(ID,Name))return 0;
		Text +=Name;
		Name=_T("");
		It++;
	};
	return crc;
}
コード例 #12
0
ファイル: wizIndexBase.cpp プロジェクト: flyfire/WizQTClient
bool CWizIndexBase::SQLToDocumentDataArray(const CString& strSQL, CWizDocumentDataArray& arrayDocument)
{
    try
    {
        CppSQLite3Query query = m_db.execQuery(strSQL);
        CWizStdStringArray arrayGUID;
        std::map<CString, int> mapDocumentIndex;
        while (!query.eof())
        {
            WIZDOCUMENTDATA data;
            data.strKbGUID = kbGUID();
            data.strGUID = query.getStringField(documentDOCUMENT_GUID);
            data.strTitle = query.getStringField(documentDOCUMENT_TITLE);
            data.strLocation = query.getStringField(documentDOCUMENT_LOCATION);
            data.strName = query.getStringField(documentDOCUMENT_NAME);
            data.strSEO = query.getStringField(documentDOCUMENT_SEO);
            data.strURL = query.getStringField(documentDOCUMENT_URL);
            data.strAuthor = query.getStringField(documentDOCUMENT_AUTHOR);
            data.strKeywords = query.getStringField(documentDOCUMENT_KEYWORDS);
            data.strType = query.getStringField(documentDOCUMENT_TYPE);
            data.strOwner = query.getStringField(documentDOCUMENT_OWNER);
            data.strFileType = query.getStringField(documentDOCUMENT_FILE_TYPE);
            data.strStyleGUID = query.getStringField(documentSTYLE_GUID);
            data.tCreated = query.getTimeField(documentDT_CREATED);
            data.tModified = query.getTimeField(documentDT_MODIFIED);
            data.tAccessed = query.getTimeField(documentDT_ACCESSED);
            data.nIconIndex = query.getIntField(documentDOCUMENT_ICON_INDEX);
            data.nSync = query.getIntField(documentDOCUMENT_SYNC);
            data.nProtected = query.getIntField(documentDOCUMENT_PROTECT);
            data.nReadCount = query.getIntField(documentDOCUMENT_READ_COUNT);
            data.nAttachmentCount = query.getIntField(documentDOCUMENT_ATTACHEMENT_COUNT);
            data.nIndexed = query.getIntField(documentDOCUMENT_INDEXED);
            data.tInfoModified = query.getTimeField(documentDT_INFO_MODIFIED);
            data.strInfoMD5 = query.getStringField(documentDOCUMENT_INFO_MD5);
            data.tDataModified = query.getTimeField(documentDT_DATA_MODIFIED);
            data.strDataMD5 = query.getStringField(documentDOCUMENT_DATA_MD5);
            data.tParamModified = query.getTimeField(documentDT_PARAM_MODIFIED);
            data.strParamMD5 = query.getStringField(documentDOCUMENT_PARAM_MD5);
            data.nVersion = query.getInt64Field(documentVersion);

            arrayGUID.push_back(data.strGUID);
            arrayDocument.push_back(data);
            mapDocumentIndex[data.strGUID] = int(arrayDocument.size() - 1);
            query.nextRow();
        }

        if (!arrayGUID.empty()) {
            InitDocumentExFields(arrayDocument, arrayGUID, mapDocumentIndex);
        }

        return true;
    }
    catch (const CppSQLite3Exception& e)
    {
        return LogSQLException(e, strSQL);
    }
}
コード例 #13
0
void BudgetWindow::RefreshBudgetGrid(void)
{
	fIncomeGrid.MakeEmpty();
	fSpendingGrid.MakeEmpty();

	CppSQLite3Query query = gDatabase.DBQuery("select category,amount,period from "
											"budgetlist order by category",
											"BudgetWindow::RefreshCategories");
	while(!query.eof())
	{
		BString cat = DeescapeIllegalCharacters(query.getStringField(0));
		Fixed amount;
		amount.SetPremultiplied(query.getInt64Field(1));
		BudgetPeriod period = (BudgetPeriod)query.getIntField(2);

		ReportGrid *grid = (amount.IsPositive()) ? &fIncomeGrid : &fSpendingGrid;

		int32 index = grid->CountItems();
		grid->AddItem();
		grid->SetRowTitle(index, cat.String());

		Fixed f(amount.AbsoluteValue());
		switch(period)
		{
			case BUDGET_QUARTERLY:
			{
				f /= 3;
				Fixed qamt(amount);
				qamt *= 4;
				grid->SetValue(12,index,qamt);
				break;
			}
			case BUDGET_ANNUALLY:
			{
				f /=12;
				grid->SetValue(12,index,amount);
				break;
			}
			default:
			{
				Fixed mamt(f);
				mamt *= 12;
				grid->SetValue(12,index,mamt);
				break;
			}
		}

		for(int32 i=0; i<12; i++)
			grid->SetValue(i,index,f);

		query.nextRow();
	}
}
コード例 #14
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
//返回一段逻辑,存储为可编译状态
bool  CBrainMemory::RetrieveLogic(int64 RoomID,ePipeline* Pipe,bool IsShunt/* = false*/){
	int64 CurrentRoomValue,RoomType; 
    int64  CurrentID = RoomID;

	//首先得到意义空间的信息
	GetRoomInfo(RoomID,CurrentRoomValue,RoomType);
	if(RoomType ==  MEMORY_ACT){  //递归终止
		return RetrieveAction(RoomID,CurrentRoomValue,Pipe,IsShunt);
	}

	if(RoomType != MEMORY_SERIES && 
		RoomType != MEMORY_SHUNT)return false;
  
    int64 LogicType = RoomType;

	deque<int64> MeaingList;
    while(1)
	{
		//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
		CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
		if(Result.eof())return false;
		CurrentID = Result.getInt64Field(0);  //fatherID
		if(CurrentID == ROOT_SPACE)break;
		CurrentRoomValue = Result.getInt64Field(1); //fatherValuse
        MeaingList.push_back(CurrentRoomValue);
	} 
	
    IsShunt = RoomType == MEMORY_SHUNT;
	deque<int64>::reverse_iterator It = MeaingList.rbegin();
	while (It != MeaingList.rend())
	{
		CurrentRoomValue = *It;
        ePipeline* ChildPipe = new ePipeline;
		Pipe->Push_Directly(ChildPipe);
		if (!RetrieveLogic(CurrentRoomValue,ChildPipe,IsShunt))return false;
	    It++;	
	}
	return true;
}
コード例 #15
0
ファイル: wizIndexBase.cpp プロジェクト: flyfire/WizQTClient
bool CWizIndexBase::SQLToSize(const CString& strSQL, int& size)
{
    try
    {
        CppSQLite3Query query = m_db.execQuery(strSQL);
        size = query.getInt64Field(0);
        return true;
    }
    catch (const CppSQLite3Exception& e)
    {
        return LogSQLException(e, strSQL);
    }
}
コード例 #16
0
ファイル: wizIndexBase.cpp プロジェクト: flyfire/WizQTClient
bool CWizIndexBase::SQLToMessageDataArray(const QString& strSQL,
                                          CWizMessageDataArray& arrayMessage)
{
    try
    {
        CppSQLite3Query query = m_db.execQuery(strSQL);
        while (!query.eof())
        {
            WIZMESSAGEDATA data;
            data.nId = query.getInt64Field(msgMESSAGE_ID);
            data.bizGUID = query.getStringField(msgBIZ_GUID);
            data.kbGUID = query.getStringField(msgKB_GUID);
            data.documentGUID = query.getStringField(msgDOCUMENT_GUID);
            data.senderAlias = query.getStringField(msgSENDER);
            data.senderId = query.getStringField(msgSENDER_ID);
            data.senderGUID = query.getStringField(msgSENDER_GUID);
            data.receiverAlias = query.getStringField(msgRECEIVER);
            data.receiverId = query.getStringField(msgRECEIVER_ID);
            data.receiverGUID = query.getStringField(msgRECEIVER_GUID);
            data.nMessageType = query.getIntField(msgMESSAGE_TYPE);
            data.nReadStatus = query.getIntField(msgREAD_STATUS);
            data.tCreated = query.getTimeField(msgDT_CREATED);
            data.title = query.getStringField(msgMESSAGE_TITLE);
            data.messageBody = query.getStringField(msgMESSAGE_TEXT);
            data.nVersion = query.getInt64Field(msgWIZ_VERSION);

            arrayMessage.push_back(data);
            query.nextRow();
        }

        return true;
    }
    catch (const CppSQLite3Exception& e)
    {
        return LogSQLException(e, strSQL);
    }
}
コード例 #17
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
ePipeline* CBrainMemory::RetrievePipe(int64 RoomID){
	int64 CurrentRoomValue,RoomType; 
    int64  CurrentID = RoomID;
	
	//首先得到意义空间的信息
	if(!GetRoomInfo(RoomID,CurrentRoomValue,RoomType)){
		return NULL;
	}
	
	deque<int64> BodyList;
	while(1)
	{
		//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
		CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
		if(Result.eof())return 0;
		CurrentID = Result.getInt64Field(0);  //fatherID
		if(CurrentID == ROOT_SPACE)break;;
		CurrentRoomValue = Result.getInt64Field(1); //fatherValuse
        BodyList.push_front(CurrentRoomValue);
	}

	ePipeline* Pipe = new ePipeline;
	eElectron E(Pipe);

	for (int i=0; i<BodyList.size(); i++)
	{
		int64 ID = BodyList[i];
		Energy* e = RetrieveEnergy(ID);
		if (!e)
		{
			return NULL;
		}
		Pipe->Push_Directly(e);
	}

	return (ePipeline*)E.Release();
}
コード例 #18
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
bool CBrainMemory::RetrieveAction(int64 RoomID,int64 RoomValue, tstring& Text,bool IsShunt){
    
	deque<int64> MeaingList;
	
	while(1){
		//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
		CppSQLite3Query Result = LBrainQuery("*",RoomValue,LB_CHILD_ID,RoomID);
		if(Result.eof())return false;
    
	    RoomValue = Result.getInt64Field(1); //fatherValuse
		RoomID = Result.getInt64Field(0);  //fatherID
        if(RoomID == ROOT_SPACE)break;
		MeaingList.push_front(RoomValue);
	}
	
	assert(MeaingList.size() <3);
	int64 ActionID = MeaingList.front();
	int64 Param   = 0;
	if(MeaingList.size()==2)Param = MeaingList.back();

	if(BelongInstinct(ActionID)){
		Text = Instinct2Str(ActionID);
	}
	else {
		RetrieveText(ActionID,Text);//返回命令的文本: todo something;
	}
	if(IsShunt)Text = _T("and ")+Text;
	if(Param){ //如果是本能还要返回参数
		assert(BelongInstinct(ActionID));
		tstring ParamText;
		RetrieveText(Param,ParamText);
		Text +=_T(' ');
		Text += ParamText;
	}
	return true;
}
コード例 #19
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
bool CBrainMemory::GetRoomInfo(int64 RoomID, int64& RoomValue, int64& RoomType){
    
	assert(RoomID != ROOT_SPACE);

	CppSQLite3Buffer SQL;
	CppSQLite3Query  Result;

	RoomValue = GetRoomValue(RoomID);

	if(RoomValue==0)return false;

	//但要得到逻辑暗文需要在向上走一次,得到父空间的ID
    Result = LBrainQuery(LB_FATHER_ID,RoomValue,LB_CHILD_ID,RoomID);
	if(Result.eof())return false;
		
	int64 FatherID = Result.getInt64Field(0);

	//回过头来,找当前空间的逻辑暗文
    Result = RBrainQuery(RB_SPACE_TYPE,FatherID,RB_SPACE_ID,RoomID);
	if(Result.eof())return false;
    
	RoomType =  Result.getInt64Field(0);
	return true;
}
コード例 #20
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
//根据子空间找父空间
int64 CBrainMemory::GetFatherID(int64 Child)
{
	assert(Child != ROOT_SPACE);

	//首先找到它的逻辑明文
	
	int64 ChildRoomValue = GetRoomValue(Child);
	if(!ChildRoomValue)return 0;

	//得到父空间的ID
    CppSQLite3Query  Result = LBrainQuery(LB_FATHER_ID,ChildRoomValue,LB_CHILD_ID,Child);
	if(Result.eof())return false;
		
	return  Result.getInt64Field(0);
}
コード例 #21
0
ファイル: Space.cpp プロジェクト: GMIS/GMIS
SpaceAddress  FindSpace(ePipeline& Path){
	SpaceAddress Addr;
	
	if (Path.Size()==0)
	{
		Addr.ParentID = ROOT_SPACE;
		Addr.ChildID  = LOCAL_SPACEID;
		return Addr;
	}
	
	CppSQLite3Buffer SQL;
	
	int64 ParentID = 0;
	int64 ChildID  = ROOT_SPACE;
	
	char       ParentName[30]; 
	while (Path.Size())
	{
		tstring Name = Path.PopString();
		AnsiString AnsiName = WStoUTF8(Name);
		
		ParentID = ChildID;
		ChildID  = 0;
		
		int64toa(ParentID,ParentName);
		
		SQL.format("select %s from \"%s\" where %s=\"%s\"",
			ITEM_ID,
			ParentName,
			ITEM_NAME,
			AnsiName.c_str()
			);
		CppSQLite3Query Result = GetWorldDB().execQuery(SQL);
		
		if(!Result.eof()){
			ChildID  = Result.getInt64Field(0);
			Result.nextRow();
		}else{
			return  Addr;
		}
	}
	
	assert(Path.Size()==0);
	
	Addr.ParentID = ParentID;
	Addr.ChildID  = ChildID;
    return Addr;	
}
コード例 #22
0
void BudgetWindow::RefreshCategories(void)
{
	fCategoryList->Clear();
	fIncomeRow = new BRow();
	fCategoryList->AddRow(fIncomeRow);
	fSpendingRow = new BRow();
	fCategoryList->AddRow(fSpendingRow);
	fIncomeRow->SetField(new BStringField(TRANSLATE("Income")),0);
	fSpendingRow->SetField(new BStringField(TRANSLATE("Spending")),0);

	CppSQLite3Query query = gDatabase.DBQuery("select category,amount,period,isexpense from "
											"budgetlist order by category",
											"BudgetWindow::RefreshCategories");
	float maxwidth=fCategoryList->StringWidth("Category");
	while(!query.eof())
	{
		BString cat = DeescapeIllegalCharacters(query.getStringField(0));
		Fixed amount;
		amount.SetPremultiplied(query.getInt64Field(1));
		BudgetPeriod period = (BudgetPeriod)query.getIntField(2);

		BRow *row = new BRow();

		if(query.getIntField(3)==0)
			fCategoryList->AddRow(row,fIncomeRow);
		else
			fCategoryList->AddRow(row,fSpendingRow);

		row->SetField(new BStringField(cat.String()),0);

		BString amountstr;
		gDefaultLocale.CurrencyToString(amount.AbsoluteValue(),amountstr);
		amountstr.Truncate(amountstr.FindFirst(gDefaultLocale.CurrencyDecimal()));
		amountstr.RemoveFirst(gDefaultLocale.CurrencySymbol());

		row->SetField(new BStringField(amountstr.String()),1);

		float tempwidth = fCategoryList->StringWidth(cat.String());
		maxwidth = MAX(tempwidth,maxwidth);

		row->SetField(new BStringField(BudgetPeriodToString(period).String()),2);

		query.nextRow();
	}
	fCategoryList->ColumnAt(0)->SetWidth(maxwidth+30);
	fCategoryList->ExpandOrCollapse(fIncomeRow,true);
	fCategoryList->ExpandOrCollapse(fSpendingRow,true);
}
コード例 #23
0
ファイル: Space.cpp プロジェクト: GMIS/GMIS
int32 GetAllChildList(int64 ParentID, ePipeline& ChildList,int64 NotIncludeChildID /*=0*/){
    assert(ParentID >0);
	ChildList.Clear();

	char TableName[30];
	int64toa(ParentID,TableName);
	if(!GetWorldDB().tableExists(TableName)){
		return 0;
	}

	//ChildList.SetID(ParentID);

    CppSQLite3Buffer SQL;
	SQL.format("select %s,%s,%s,%s from \"%s\"",
		     ITEM_ID,
		     ITEM_NAME,
			 ITEM_TYPE,
			 ITEM_FINGERPRINT,
		     TableName
	);

	CppSQLite3Query Result = GetWorldDB().execQuery(SQL);
	
	while(!Result.eof()){
		int64      ChildID     = Result.getInt64Field(0);
		
		if (ChildID !=NotIncludeChildID)
		{
			AnsiString s    = Result.getStringField(1,"");
			
			tstring Name = UTF8toWS(s);
			Name = GetFileNoPathName(Name);
			Name = GetFileName(Name);
			
			int32      Type        = Result.getIntField(2);
			AnsiString FingerPrint = Result.getStringField(3,"");

			//ChildList.PushInt64(ChildID);
			ChildList.PushString(Name);
			ChildList.PushInt(Type);
			ChildList.PushString(FingerPrint);

		}
		Result.nextRow();
	}
	return ChildList.Size()/3;
}
コード例 #24
0
ファイル: Space.cpp プロジェクト: GMIS/GMIS
/*
-注意:由于是递归,外部调用着应该考虑用事物回滚
*/
void DeleteAllChild(int64 ParentID)
{
	char     ParentName[30];   	
    int64toa(ParentID,ParentName);
    if(!GetWorldDB().tableExists(ParentName))return;  //指定空间没有子空间
	
	CppSQLite3Buffer SQL;
	
	//首先找到所有子空间的地址
	vector<int64> AddressList;
	
	SQL.format("select %s from \"%s\" ",
		ITEM_ID,
		ParentName
		);
	CppSQLite3Query Result = GetWorldDB().execQuery(SQL);
	while(!Result.eof()){
		int64 ChildID  = Result.getInt64Field(0);
		AddressList.push_back(ChildID);
		Result.nextRow();
	}
	
	   
	//根据地址,执行递归操作
	for(uint32 i=0; i<AddressList.size();i++)
	{
        int64 ID = AddressList[i];
		DeleteAllChild(ID);
	}
	
	//最后删除子空间的所在的容器(表)
    if(AddressList.size() != 0){
		SQL.format("drop table \"%s\" ",ParentName);
		GetWorldDB().execDML(SQL);
	}
	
}
コード例 #25
0
void BudgetWindow::CalcStats(const char *cat, Fixed &high, Fixed &low, Fixed &avg)
{
	if(!cat)
		return;

	BString querystring;
	Fixed cattotal;
	CppSQLite3Query query;

	// find the average amount
	for(int32 j=0; j<gDatabase.CountAccounts(); j++)
	{
		Account *acc = gDatabase.AccountAt(j);
		querystring = "select sum(amount) from account_" ;
		querystring << acc->GetID()	<< " where category = '"
					<< EscapeIllegalCharacters(cat)
					<< "';";
		query = gDatabase.DBQuery(querystring.String(),
								"BudgetWindow::CalcStats:get average");
		cattotal.AddPremultiplied(query.getInt64Field(0));
		query.finalize();
	}
	avg = cattotal;
	avg /= 12;

	// find the highest amount
	cattotal=0;
	for(int32 j=0; j<gDatabase.CountAccounts(); j++)
	{
		Account *acc = gDatabase.AccountAt(j);
		querystring = "select max(amount) from account_" ;
		querystring << acc->GetID()	<< " where category = '"
					<< EscapeIllegalCharacters(cat)
					<< "';";
		query = gDatabase.DBQuery(querystring.String(),
								"BudgetWindow::CalcStats:get highest");
		Fixed value;
		value.SetPremultiplied(query.getInt64Field(0));
		cattotal = MAX(cattotal,value);
		query.finalize();
	}
	high = cattotal;

	// find the lowest amount
	cattotal=0;
	for(int32 j=0; j<gDatabase.CountAccounts(); j++)
	{
		Account *acc = gDatabase.AccountAt(j);
		querystring = "select min(amount) from account_" ;
		querystring << acc->GetID()	<< " where category = '"
					<< EscapeIllegalCharacters(cat)
					<< "';";
		query = gDatabase.DBQuery(querystring.String(),
								"BudgetWindow::CalcStats:get highest");
		Fixed value;
		value.SetPremultiplied(query.getInt64Field(0));
		cattotal = MIN(cattotal,value);
		query.finalize();
	}
	low = cattotal;
}
コード例 #26
0
void BudgetWindow::GenerateBudget(const bool &zero)
{
	// Generate a budget based on the last year's transactions
	ReportGrid income(1,0), spending(1,0);

	gDatabase.DBCommand("delete from budgetlist",
						"BudgetWindow::GenerateBudget:empty budget");

	CppSQLite3Query query;
	query = gDatabase.DBQuery("select * from categorylist order by name",
							"BudgetWindow::GenerateBudget:get categories");

	if(query.eof())
		return;

	float maxwidth=fCategoryList->StringWidth(TRANSLATE("Category"));
	while(!query.eof())
	{
		BString catname = DeescapeIllegalCharacters(query.getStringField(0));

		if(catname.ICompare(TRANSLATE("Transfer"))==0)
		{
			query.nextRow();
			continue;
		}

		bool isexpense = !query.getIntField(1);

		if(isexpense)
		{
			spending.AddItem();
			spending.SetRowTitle(spending.CountItems()-1,catname.String());
		}
		else
		{
			income.AddItem();
			income.SetRowTitle(income.CountItems()-1,catname.String());
		}
		float tempwidth = fCategoryList->StringWidth(catname.String());
		maxwidth = MAX(maxwidth,tempwidth);
		query.nextRow();
	}

	query.finalize();

	// Now that we have the list of categories, query for transactions for each
	// account from each category

	BString querystring;
	Fixed cattotal;
	for(int32 i=0; i<income.CountItems(); i++)
	{
		querystring = "";
		cattotal = 0;

		if(!zero)
		{
			for(int32 j=0; j<gDatabase.CountAccounts(); j++)
			{
				Account *acc = gDatabase.AccountAt(j);
				querystring = "select sum(amount) from account_" ;
				querystring << acc->GetID()	<< " where category = '"
							<< EscapeIllegalCharacters(income.RowTitle(i))
							<< "' and date > " << DecrementDateByYear(GetCurrentDate()) << ";";
				query = gDatabase.DBQuery(querystring.String(),
										"BudgetWindow::GenerateBudget:get category");
				cattotal.AddPremultiplied(query.getInt64Field(0));
				query.finalize();
			}
			cattotal /= 12;
			cattotal.Round();
		}
		income.SetValue(0,i,cattotal);
		gDatabase.AddBudgetEntry(BudgetEntry(income.RowTitle(i),cattotal,BUDGET_MONTHLY,false));
	}

	for(int32 i=0; i<spending.CountItems(); i++)
	{
		querystring = "";
		cattotal = 0;

		if(!zero)
		{
			for(int32 j=0; j<gDatabase.CountAccounts(); j++)
			{
				Account *acc = gDatabase.AccountAt(j);
				querystring = "select sum(amount) from account_" ;
				querystring << acc->GetID()	<< " where category = '"
							<< EscapeIllegalCharacters(spending.RowTitle(i))
							<< "';";
				query = gDatabase.DBQuery(querystring.String(),
										"BudgetWindow::GenerateBudget:get category");
				cattotal.AddPremultiplied(query.getInt64Field(0));
				query.finalize();
			}
			cattotal /= 12;
			cattotal.Round();
		}
		spending.SetValue(0,i,cattotal);
		gDatabase.AddBudgetEntry(BudgetEntry(spending.RowTitle(i),cattotal,BUDGET_MONTHLY,true));
	}
}
コード例 #27
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
//返回一段逻辑,表达为文字
bool  CBrainMemory::RetrieveLogic(int64 RoomID,deque<tstring>& LogicList,tstring* Text/*=NULL*/,bool IsShunt /* = false*/){
	int64 CurrentRoomValue,RoomType; 
    int64  CurrentID = RoomID;

	//首先得到意义空间的信息
	GetRoomInfo(RoomID,CurrentRoomValue,RoomType);

	if(RoomType ==  MEMORY_ACT){//递归终止
		assert(Text != NULL);
		return RetrieveAction(RoomID,CurrentRoomValue,*Text,IsShunt);
	}
 
	if(RoomType == MEMORY_INSTINCT){
		tstring s;
	    if(!RetrieveText(RoomID,s))return false;
		s = _T("Custom Command : ") + s;
        s+=_T(';');
		LogicList.push_back(s);
		return true;
	}

	if(RoomType != MEMORY_SERIES && 
		RoomType != MEMORY_SHUNT)return false;
  
    int64 LogicType = RoomType;

	deque<int64> MeaingList;
    while(1)
	{
		//向上漫游,找到父空间空间的ID和逻辑明文,得记忆的形ID
		CppSQLite3Query Result = LBrainQuery("*",CurrentRoomValue,LB_CHILD_ID,CurrentID);
		if(Result.eof())return false;
		CurrentID = Result.getInt64Field(0);  //fatherID
		if(CurrentID == ROOT_SPACE)break;
		CurrentRoomValue = Result.getInt64Field(1); //fatherValuse
        MeaingList.push_front(CurrentRoomValue);
	} 

    if(Text) *Text = Format1024(_T("use logic %d"),LogicList.size());

	tstring LogicText = Format1024(_T("Logic %d: "),LogicList.size());
	LogicList.push_back(LogicText);

	tstring& NestLogicText = LogicList.back();

    IsShunt = RoomType == MEMORY_SHUNT;
	deque<int64>::reverse_iterator It = MeaingList.rbegin();

	while (It != MeaingList.rend())
	{
		CurrentRoomValue = *It;
		LogicText= _T("");
		if (!RetrieveLogic(CurrentRoomValue,LogicList,&LogicText,IsShunt))return false;
	    LogicText +=_T(',');
		NestLogicText += LogicText;
		It++;	
	}
  
	*NestLogicText.rbegin() =_T(';');
     
	return true;
}
コード例 #28
0
ファイル: BrainMemory.cpp プロジェクト: GMIS/GMIS
int64 CBrainMemory::GetRoomValue(int64 RoomID){
	assert(RoomID != ROOT_SPACE);

	CppSQLite3Buffer SQL;
	CppSQLite3Query  Result;
	char a[30],b[30];

	ToRBrain(RoomID);

    if(!RBrainHasTable(RoomID))return 0;

	int64toa(RoomID,a);
	int64toa(MEMORY_NULL_END,b);

	//首先找无意义结尾子空间,其空间值就是父空间的空间值
	SQL.format("select %s from \"%s\" where  %s = %s;",
				RB_SPACE_VALUE,
				a,
				RB_SPACE_TYPE,
				b
	);

	int64 RoomValue;		
	
	Result = BrainDB.execQuery(SQL);
	if(!Result.eof()){  
		RoomValue = Result.getInt64Field(0);
	    assert(RoomValue);
		return RoomValue;
	}

	//如果没有再找任意一个非结尾子空间的逻辑明文
	int64toa(RoomID,a);
	int64toa(MEMORY_LOGIC_END,b);

	SQL.format("select %s from \"%s\" where  %s > \"%s\";",
		        RB_SPACE_VALUE,
				a,
				RB_SPACE_TYPE,
				b
				);
				
	Result = BrainDB.execQuery(SQL);
    if(Result.eof())return 0;   
	RoomValue = Result.getInt64Field(0);

	ToLBrain(RoomValue);

	int64toa(RoomValue,a);
	int64toa(RoomID,b);
	//通过左脑,根据子空间值以及RoomID得到当前空间的逻辑明文
	//也就是当前空间的ID和逻辑明文,以便能向上漫游		
	SQL.format("select %s from \"%s\" where  %s = \"%s\";",
		        LB_FATHER_VALUE,
				a,
				LB_FATHER_ID,
				b
			);
				
	Result = BrainDB.execQuery(SQL);

    if(Result.eof())return 0;    		
	return Result.getInt64Field(0);
}
コード例 #29
0
// 导出所有父结点为nParentId的结点的收藏数据
// nDataNum为导出的收藏数据
BOOL FireFox3PlugIn::ExportFavoriteData(int nParentId, PFAVORITELINEDATA* ppData, int32& nCurrentIndex)
{
	wstring strSql = L"select * from moz_bookmarks where parent = " ;
	strSql += StringHelper::ANSIToUnicode(StringHelper::ConvertFromInt(nParentId));
	if( nParentId == BOOKMARKS_MENU)
	{
		strSql += BOOKMARKS_MENU_EXCLUED_SQL;
	}
	else if ( nParentId == BOOKMARKS_TOOLSBAR)
	{
		strSql += BOOKMARKS_TOOLSBAR_EXCLUED_SQL;
	}

	CCRCHash ojbCrcHash;

	CppSQLite3Query Query = m_pSqliteDatabase->execQuery(StringHelper::UnicodeToUtf8(strSql).c_str());
	while(!Query.eof())
	{
		int nId = Query.getIntField("id", 0);

		if( nParentId == 2 || nParentId == 3 || nParentId == 4 || nParentId == 5)
		{
			ppData[nCurrentIndex]->nPid = 0;
		}
		else
		{
			ppData[nCurrentIndex]->nPid = Query.getIntField("parent", 0);
		}

		ppData[nCurrentIndex]->nId = nId + ID_VALUE_FIREFOX_BEGIN;
		if (ppData[nCurrentIndex]->nPid != 0)
		{
			ppData[nCurrentIndex]->nPid += ID_VALUE_FIREFOX_BEGIN;
		}

		ppData[nCurrentIndex]->bFolder = Query.getIntField("type", 1) == 2 ? true : false;

		wcscpy_s(ppData[nCurrentIndex]->szTitle, MAX_LENGTH - 1, StringHelper::Utf8ToUnicode(Query.getStringField("title", 0)).c_str());
		ppData[nCurrentIndex]->szTitle[MAX_LENGTH - 1] = 0;

		ppData[nCurrentIndex]->nOrder = Query.getIntField("position", 0);
		ppData[nCurrentIndex]->nAddTimes = Query.getInt64Field("dateAdded", 0);
		ppData[nCurrentIndex]->nLastModifyTime = Query.getInt64Field("lastModified",0);

		ojbCrcHash.GetHash((BYTE *)ppData[nCurrentIndex]->szTitle, 
			wcslen(ppData[nCurrentIndex]->szTitle) * sizeof(wchar_t),
			(BYTE *)&ppData[nCurrentIndex]->nHashId, sizeof(uint32));
		ppData[nCurrentIndex]->bDelete = false;

		// 查找对应的URL
		string strUrlQuerySql = "select place.url from moz_bookmarks as marks,\
					moz_places as place where marks.id = " ;
		strUrlQuerySql += StringHelper::ConvertFromInt(nId);
		strUrlQuerySql += " and marks.fk = place.id";
		CppSQLite3Query urlQuery = m_pSqliteDatabase->execQuery(strUrlQuerySql.c_str());
		if(!urlQuery.eof())
		{
			wcscpy_s(ppData[nCurrentIndex]->szUrl, MAX_LENGTH-1, StringHelper::Utf8ToUnicode(urlQuery.getStringField("url", 0)).c_str());
			ppData[nCurrentIndex]->szUrl[MAX_LENGTH-1] = 0;
		}

		nCurrentIndex++;

		ExportFavoriteData(nId, ppData, nCurrentIndex);
		
		Query.nextRow();
	}

	return TRUE;
}
コード例 #30
0
ファイル: CppSQLite3DemoExt.cpp プロジェクト: Omgan/CppSQLite
int main(int argc, char** argv)
{
    try
    {
		int row;
        CppSQLite3DB db;

        cout << "SQLite Header Version: " << CppSQLite3DB::SQLiteHeaderVersion() << endl;
        cout << "SQLite Library Version: " << CppSQLite3DB::SQLiteLibraryVersion() << endl;
        cout << "SQLite Library Version Number: " << CppSQLite3DB::SQLiteLibraryVersionNumber() << endl;

        remove(gszFile);
        db.open(gszFile);

        ////////////////////////////////////////////////////////////////////////////////
        // Demonstrate getStringField(), getIntField(), getFloatField()
        ////////////////////////////////////////////////////////////////////////////////
        db.execDML("create table parts(no int, name char(20), qty int, cost number);");
        db.execDML("insert into parts values(1, 'part1', 100, 1.11);");
        db.execDML("insert into parts values(2, null, 200, 2.22);");
        db.execDML("insert into parts values(3, 'part3', null, 3.33);");
        db.execDML("insert into parts values(4, 'part4', 400, null);");

        cout << endl << "CppSQLite3Query getStringField(), getIntField(), getFloatField() tests" << endl;
        CppSQLite3Query q = db.execQuery("select * from parts;");
        while (!q.eof())
        {
            cout << q.getIntField(0) << "|";
            cout << q.getStringField(1) << "|";
            cout << q.getInt64Field(2) << "|";
            cout << q.getFloatField(3) << "|" << endl;
            q.nextRow();
        }

        cout << endl << "specify NULL values tests" << endl;
        q = db.execQuery("select * from parts;");
        while (!q.eof())
        {
            cout << q.getIntField(0) << "|";
            cout << q.getStringField(1, "NULL") << "|";
            cout << q.getIntField(2, -1) << "|";
            cout << q.getFloatField(3, -3.33) << "|" << endl;
            q.nextRow();
        }

        cout << endl << "Specify fields by name" << endl;
        q = db.execQuery("select * from parts;");
        while (!q.eof())
        {
            cout << q.getIntField("no") << "|";
            cout << q.getStringField("name") << "|";
            cout << q.getInt64Field("qty") << "|";
            cout << q.getFloatField("cost") << "|" << endl;
            q.nextRow();
        }

        cout << endl << "specify NULL values tests" << endl;
        q = db.execQuery("select * from parts;");
        while (!q.eof())
        {
            cout << q.getIntField("no") << "|";
            cout << q.getStringField("name", "NULL") << "|";
            cout << q.getIntField("qty", -1) << "|";
            cout << q.getFloatField("cost", -3.33) << "|" << endl;
            q.nextRow();
        }
		q.finalize();

		////////////////////////////////////////////////////////////////////////////////
        // Demonstrate getStringField(), getIntField(), getFloatField()
		// But this time on CppSQLite3Table
        ////////////////////////////////////////////////////////////////////////////////
        cout << endl << "CppSQLite3Table getStringField(), getIntField(), getFloatField() tests" << endl;
        CppSQLite3Table t = db.getTable("select * from parts;");
        for (row = 0; row < t.numRows(); row++)
        {
            t.setRow(row);
            cout << t.getIntField(0) << "|";
            cout << t.getStringField(1) << "|";
            cout << t.getIntField(2) << "|";
            cout << t.getFloatField(3) << "|" << endl;
        }

        cout << endl << "specify NULL values tests" << endl;
        for (row = 0; row < t.numRows(); row++)
        {
            t.setRow(row);
            cout << t.getIntField(0, -1) << "|";
            cout << t.getStringField(1, "NULL") << "|";
            cout << t.getIntField(2, -1) << "|";
            cout << t.getFloatField(3, -3.33) << "|" << endl;
        }

        cout << endl << "Specify fields by name" << endl;
        for (row = 0; row < t.numRows(); row++)
        {
            t.setRow(row);
            cout << t.getIntField("no") << "|";
            cout << t.getStringField("name") << "|";
            cout << t.getIntField("qty") << "|";
            cout << t.getFloatField("cost") << "|" << endl;
        }

        cout << endl << "specify NULL values tests" << endl;
        for (row = 0; row < t.numRows(); row++)
        {
            t.setRow(row);
            cout << t.getIntField("no") << "|";
            cout << t.getStringField("name", "NULL") << "|";
            cout << t.getIntField("qty", -1) << "|";
            cout << t.getFloatField("cost", -3.33) << "|" << endl;
        }


		////////////////////////////////////////////////////////////////////////////////
		// Demonstrate multi-statement DML
		// Note that number of rows affected is only from the last statement
		// when multiple statements are used
		////////////////////////////////////////////////////////////////////////////////
        cout << endl << "Multi-Statement execDML()" << endl;
		const char* szDML = "insert into parts values(5, 'part5', 500, 5.55);"
							"insert into parts values(6, 'part6', 600, 6.66);"
							"insert into parts values(7, 'part7', 700, 7.77);";
		int nRows = db.execDML(szDML);
		cout << endl << nRows << " rows affected" << endl;
        cout << db.execScalar("select count(*) from parts;") << " rows in parts table" << endl;
		            szDML = "delete from parts where no = 2;"
							"delete from parts where no = 3;";
		nRows = db.execDML(szDML);
        cout << endl << nRows << " rows affected" << endl;
        cout << db.execScalar("select count(*) from parts;") << " rows in parts table" << endl;


		////////////////////////////////////////////////////////////////////////////////
		// Demonstrate new typing system & BLOBS
		// ANy data can be stored in any column
		////////////////////////////////////////////////////////////////////////////////
        cout << endl << "Data types and BLOBs()" << endl;
        db.execDML("create table types(no int, "
				"name char(20), qty float, dat blob);");
        db.execDML("insert into types values(null, null, null, null);");
        db.execDML("insert into types values(1, 2, 3, 4);");
        db.execDML("insert into types values(1.1, 2.2, 3.3, 4.4);");
        db.execDML("insert into types values('a', 'b', 'c', 'd');");

        CppSQLite3Statement stmt = db.compileStatement("insert into types values(?,?,?,?);");
        unsigned char buf[256];
		memset(buf, 1, 1); stmt.bind(1, buf, 1);
		memset(buf, 2, 2); stmt.bind(2, buf, 2);
		memset(buf, 3, 3); stmt.bind(3, buf, 3);
		memset(buf, 4, 4); stmt.bind(4, buf, 4);
		stmt.execDML();
        cout << db.execScalar("select count(*) from types;") << " rows in types table" << endl;

        q = db.execQuery("select * from types;");
        while (!q.eof())
        {
			for (int i = 0; i < q.numFields(); i++)
			{
				switch (q.fieldDataType(i))
				{
				case SQLITE_INTEGER  : cout << "SQLITE_INTEGER|"; break;
				case SQLITE_FLOAT    : cout << "SQLITE_FLOAT  |"; break;
				case SQLITE_TEXT     : cout << "SQLITE_TEXT   |"; break;
				case SQLITE_BLOB     : cout << "SQLITE_BLOB   |"; break;
				case SQLITE_NULL     : cout << "SQLITE_NULL   |"; break;
				default: cout << "***UNKNOWN TYPE***"; break;
				}
			}
            q.nextRow();
			cout << endl;
        }

        nRows = db.execDML("delete from types where no = 1 or no = 1.1 or no = 'a' or no is null;");
		cout << endl << nRows << " rows deleted, leaving binary row only" << endl;

        q = db.execQuery("select * from types;");
		const unsigned char* pBlob;
		int nLen;
		pBlob = q.getBlobField(0, nLen);
		cout << "Field 1 BLOB length: " << nLen << endl;
		pBlob = q.getBlobField(1, nLen);
		cout << "Field 2 BLOB length: " << nLen << endl;
		pBlob = q.getBlobField(2, nLen);
		cout << "Field 3 BLOB length: " << nLen << endl;
		pBlob = q.getBlobField(3, nLen);
		cout << "Field 4 BLOB length: " << nLen << endl;

		q.finalize();

        nRows = db.execDML("delete from types;");
		cout << endl << nRows << " rows deleted, leaving empty table" << endl;
        unsigned char bin[256];

        for (int i = 0; i < sizeof bin; i++)
        {
            bin[i] = i;
        }

        stmt = db.compileStatement("insert into types values(?,0,0,0);");
		stmt.bind(1, bin, sizeof bin);
		stmt.execDML();

        cout << "Stored binary Length: " << sizeof bin << endl;

        q = db.execQuery("select * from types;");

		pBlob = q.getBlobField(0, nLen);
		cout << "Field 1 BLOB length: " << nLen << endl;

        for (i = 0; i < sizeof bin; i++)
        {
            if (pBlob[i] != i)
            {
				cout << "Problem: i: ," << i << " BLOB[i]: " << pBlob[i] << endl;
            }
        }
	}
    catch (CppSQLite3Exception& e)
    {
        cerr << e.errorCode() << ":" << e.errorMessage() << endl;
    }

	////////////////////////////////////////////////////////////////////////////////
    // Loop until user enters q or Q
    ////////////////////////////////////////////////////////////////////////////////
    char c(' ');

    while (c != 'q' && c != 'Q')
    {
        cout << "Press q then enter to quit: ";
        cin >> c;
    }
    return 0;
}