VALUE DetermineValue(POSITION position) { gUseGPS = gGlobalPositionSolver && gUndoMove != NULL; if (gAnalyzing && !LoadAnalysis()) { gLoadDatabase = FALSE; } if(gLoadDatabase && LoadDatabase()) { if (gPrintDatabaseInfo) printf("\nLoading in Database for %s...",kGameName); if (GetValueOfPosition(position) == undecided) { if (gPrintDatabaseInfo) printf("\nRe-evaluating the value of %s...", kGameName); gSolver(position); AnalysisCollation(); printf("done in %u seconds!\e[K", gAnalysis.TimeToSolve = Stopwatch()); /* Extra Spacing to Clear Status Printing */ if(gSaveDatabase) { printf("\nWriting the values of %s into a database...", kGameName); SaveDatabase(); SaveAnalysis(); } } } else { if (gPrintDatabaseInfo)
STDMETHODIMP CServiceSettings::put_DatabaseConnection(BSTR newVal) { ObjectLock lock(this); _bstr_t bsNew = newVal; if(bsNew.length() && bsNew != m_bsConnectionString) { m_bsConnectionString = newVal; if(SaveDatabase()) Fire_DatabaseConnectionChanged(m_bsConnectionString); m_bRequiresSave = true; } return S_OK; }
bool AddToDatabase(const string& record) { if (record.size() < 1 || record.back() != '\n') return false; if (!LoadDatabase()) return false; if (pivot < 0 || pivot >= (int)data.size()) data.push_back(record); else data[pivot] = record; SaveDatabase(); return true; }
int Maxthon3PlugIn::ImportFavoriteData( PFAVORITELINEDATA pData, int32& nDataNum ) { if (pData == NULL || nDataNum == 0) { return ERROR_INVALID_PARAM; } #define MAX_BUFFER_LEN 4096 CppSQLite3DB m_SqliteDatabase; wchar_t szInsert[MAX_BUFFER_LEN] = {0}; wchar_t szDelete[MAX_BUFFER_LEN] = {0}; if (m_pMemFavoriteDB != NULL) { m_SqliteDatabase.openmem(m_pMemFavoriteDB, ""); int i = 0; m_SqliteDatabase.execDML(StringHelper::UnicodeToUtf8(L"delete from MyFavNodes where parent_id <> ''").c_str()); m_SqliteDatabase.execDML("begin transaction"); for (int i = 0; i < nDataNum; i++) { if (pData[i].bDelete == true) { continue; } swprintf_s(szInsert, MAX_BUFFER_LEN-1, L"insert into MyFavNodes" L"(id,parent_id,type,title,url,most_fav,visit_count,norder,add_date,shortcut)" L" values(?,?,%d,?,?,0,0,%d,%d,0)", pData[i].bFolder == true ? IT_FOLDER : IT_URL, pData[i].nOrder, (int32)pData[i].nAddTimes); CppSQLite3Statement sqliteStatement = m_SqliteDatabase.compileStatement(StringHelper::UnicodeToANSI(szInsert).c_str()); std::string strTemp1 = StringHelper::StringToHex( StringHelper::ANSIToUnicode(CMD5Checksum::GetMD5((BYTE *)&pData[i].nId, sizeof(int32)))); sqliteStatement.bind(1, (unsigned char *)strTemp1.c_str(), strTemp1.length()); if (pData[i].nPid == 0) { unsigned char szParentNode[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; sqliteStatement.bind(2, szParentNode, 16); } else { strTemp1 = StringHelper::StringToHex(StringHelper::ANSIToUnicode( CMD5Checksum::GetMD5((BYTE *)&pData[i].nPid, sizeof(int32))).c_str()); sqliteStatement.bind(2, (unsigned char *)strTemp1.c_str(), strTemp1.length()); } sqliteStatement.bind(3, (unsigned char *)pData[i].szTitle, (wcslen(pData[i].szTitle) + 1) * sizeof(wchar_t)); sqliteStatement.bind(4, (unsigned char *)pData[i].szUrl, (wcslen(pData[i].szUrl) + 1) * sizeof(wchar_t)); sqliteStatement.execDML(); sqliteStatement.reset(); } m_SqliteDatabase.execDML("commit transaction"); SaveDatabase(); return ERROR_OK; } return ERROR_SQLITE_ERROR; }