diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-01-29 15:45:51 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-01-29 15:45:51 +0100 |
commit | 517ad9d4b6eae320b708d03a9340a22893b0cab7 (patch) | |
tree | 37cf1907008821b4155cf90718b8d7b00a9d3461 /src/utils/xb_dbfutil.cpp | |
parent | 4875a3dd9b183dcd2256e2abfc4ccf7484c233b4 (diff) |
New upstream version 4.0.3upstream/4.0.3
Diffstat (limited to 'src/utils/xb_dbfutil.cpp')
-rwxr-xr-x | src/utils/xb_dbfutil.cpp | 87 |
1 files changed, 62 insertions, 25 deletions
diff --git a/src/utils/xb_dbfutil.cpp b/src/utils/xb_dbfutil.cpp index e008155..9c04fe3 100755 --- a/src/utils/xb_dbfutil.cpp +++ b/src/utils/xb_dbfutil.cpp @@ -87,6 +87,7 @@ class xbUtil{ void CopyDbfStructure(); void UpdateTableAutoCommit(); void DisplayTableInfo(); + void RenameTable(); // 4 - RecordMenu options void GetRecord(); @@ -136,18 +137,18 @@ class xbUtil{ #ifdef XB_INDEX_SUPPORT void LockIndices(); void UnlockIndices(); - #endif // XB_INDEX_SUPPORT + #endif // XB_INDEX_SUPPORT #ifdef XB_MEMO_SUPPORT void LockMemo(); void UnlockMemo(); - #endif + #endif // XB_MEMO_SUPPORT void LockHeader(); void UnlockHeader(); void xbFileLock(); void xbFileUnlock(); - #endif + #endif // XB_LOCKING_SUPPORT // 7 - Expression Menu options #ifdef XB_EXPRESSION_SUPPORT @@ -159,8 +160,8 @@ class xbUtil{ void IsLeapYear(); #ifdef XB_DEBUG_SUPPORT void DumpExpressionTree(); - #endif - #endif + #endif // XB_DEBUG_SUPPORT + #endif // XB_EXPRESSION_SUPPORT // 8 - Index Menu Options #ifdef XB_INDEX_SUPPORT @@ -345,10 +346,12 @@ void xbUtil::UnlockIndices(){ x.DisplayError( iRc ); } -#endif // XB_LOCKING_SUPPORT +#endif // XB_LOCKING_SUPPORT +#endif // XB_INDEX_SUPPORT /*************************************************************************************/ +#ifdef XB_EXPRESSION_SUPPORT void xbUtil::ParseExpression( xbInt16 iOption ){ if( iOption == 0 ) @@ -395,9 +398,9 @@ void xbUtil::ProcessParsedExpression( xbInt16 iOption ){ if( !exp ) return; - std::cout << "Dump from w/i dbfutil before processing expression\n"; - exp->DumpTree( xbTrue ); - std::cout << "-- end of dumptree in dbfutil before processExpression\n"; + // std::cout << "Dump from w/i dbfutil before processing expression\n"; + //exp->DumpTree( xbTrue ); + //std::cout << "-- end of dumptree in dbfutil before processExpression\n"; xbInt16 iRc = exp->ProcessExpression(); if( iRc != XB_NO_ERROR ){ @@ -405,9 +408,9 @@ void xbUtil::ProcessParsedExpression( xbInt16 iOption ){ return; } - std::cout << "Dump from w/i dbfutil after processing expression\n"; - exp->DumpTree( xbTrue ); - std::cout << "-- end of dumptree in dbfutil\n"; + //std::cout << "Dump from w/i dbfutil after processing expression\n"; + //exp->DumpTree( xbTrue ); + //std::cout << "-- end of dumptree in dbfutil\n"; xbString sResult; xbDouble dResult; @@ -455,7 +458,6 @@ void xbUtil::DumpExpressionTree(){ } #endif // XB_DEBUG_SUPPORT - void xbUtil::JulToDate8(){ std::cout << "Convert Julian Date to Date8 (CCYYMMDD) format" << std::endl; std::cout << "Enter Julian Value" << std::endl; @@ -1427,6 +1429,31 @@ void xbUtil::DisplayTableInfo(){ } /*************************************************************************************/ +void xbUtil::RenameTable(){ + + if( !dActiveTable ) + dActiveTable = GetTablePtr( " - select table" ); + + if( !dActiveTable ){ + std::cout << "No table selected" << std::endl; + return; + } + + char cBuf[128]; + std::cout << "Enter new tablefile name (filename.DBF)" << std::endl; + std::cin.getline( cBuf, 128 ); + + if( cBuf[0] ){ + dActiveTable->Rename( cBuf ); + dActiveTable->Close(); + dActiveTable = NULL; + std::cout << "Table closed. Reopen if needed.\n"; + } + + +} + +/*************************************************************************************/ void xbUtil::GetRecord(){ char cBuf[15]; @@ -1528,7 +1555,7 @@ void xbUtil::UpdateTableAutoCommit(){ std::cout << "ON]" << std::endl; else std::cout << "OFF]" << std::endl; - std::cout << " 0 ==> Disable Auto Commit for table" << std::endl; + std::cout << " 0 ==> Disable Auto Commit for table" << std::endl; std::cout << " 1 ==> Enable Auto Commit for table" << std::endl; std::cout << "Current setting is [" << d->GetAutoCommit() << "]" << std::endl; char cBuf[15]; @@ -1546,7 +1573,7 @@ void xbUtil::UpdateTableAutoCommit(){ } d->SetAutoCommit( iAuto ); std::cout << "Auto Commit set to [" << d->GetAutoCommit(0) << "]" << std::endl; - if( d->GetAutoCommit() ) + if( d->GetAutoCommit() ) std::cout << "Auto Commit enabled for table" << std::endl; else std::cout << "Auto Commit disabled for table" << std::endl; @@ -1582,7 +1609,7 @@ void xbUtil::CopyDbfStructure(){ return; } std::cout << "Copy Table" << std::endl; - std::cout << "Enter new DBF file name (ie; myfile.dbf or MYFILE.DBF): "; + std::cout << "Enter new DBF file name (ie; MYFILE.DBF): "; std::cin.getline( filename, 128 ); f.SetFileName( filename ); if( strlen( filename ) == 0 ){ @@ -1725,7 +1752,7 @@ void xbUtil::Open(){ unsigned char cFileTypeByte; std::cout << "Open Table" << std::endl; - std::cout << "Enter DBF file name (.dbf or .DBF): "; + std::cout << "Enter DBF file name (.DBF): "; std::cin.getline( filename, 128 ); f.SetFileName( filename ); @@ -2138,6 +2165,8 @@ void xbUtil::ProcessOption( const xbString &sOption ){ UpdateTableAutoCommit(); else if( sOption == "=3.14" ) DisplayTableInfo(); + else if( sOption == "=3.15" ) + RenameTable(); else if( sOption == "=4" ) RecordMenu(); else if( sOption == "=4.1" ) @@ -2169,7 +2198,7 @@ void xbUtil::ProcessOption( const xbString &sOption ){ else if( sOption == "=4.14" ) CommitRecord(); #ifdef XB_FILTER_SUPPORT - else if( sOption == "=4.20" ) + else if( sOption == "=4.20" ) SetFilter(); else if( sOption == "=4.21" ) GetFirstFilterRec(); @@ -2238,8 +2267,8 @@ void xbUtil::ProcessOption( const xbString &sOption ){ xbFileLock(); else if( sOption == "=6.21" ) xbFileUnlock(); - #endif - #endif + #endif // XB_DEBUG_SUPPORT + #endif // XB_LOCKING_SUPPORT #ifdef XB_EXPRESSION_SUPPORT else if( sOption == "=7" ) @@ -2250,6 +2279,7 @@ void xbUtil::ProcessOption( const xbString &sOption ){ ProcessParsedExpression( 0 ); else if( sOption == "=7.3" ) ParseAndProcessExpression(); + #ifdef XB_DEBUG_SUPPORT else if (sOption == "=7.4" ) DumpExpressionTree(); @@ -2263,7 +2293,6 @@ void xbUtil::ProcessOption( const xbString &sOption ){ #endif // XB_EXPRESSION_SUPPORT #ifdef XB_INDEX_SUPPORT - else if( sOption == "=8" ) IndexMenu(); else if( sOption == "=8.1" ) @@ -2408,11 +2437,12 @@ void xbUtil::IndexMenu() std::cout << " 10 - Get Prev Key" << std::endl; std::cout << " 11 - Get Last Key" << std::endl; std::cout << " 12 - Find Key" << std::endl; - std::cout << " 13 - Check Index Integrity" << std::endl; + std::cout << " 13 - Check Index Integrity" << std::endl; std::cout << " 14 - Reindex" << std::endl; std::cout << " 15 - Delete Tag" << std::endl; std::cout << " 16 - Associate NDX file" << std::endl; - + + #ifdef XB_DEBUG_SUPPORT std::cout << std::endl; std::cout << " 20 - Dump Header" << std::endl; @@ -2768,6 +2798,8 @@ void xbUtil::FileMenu() std::cout << "12 - Copy Dbf Structure" << std::endl; std::cout << "13 - Update Table Auto Commit Setting" << std::endl; std::cout << "14 - Display Table Info" << std::endl; + std::cout << "15 - Rename Table" << std::endl; + std::cout << "99 - Exit Menu" << std::endl; option = GetOption(); @@ -2787,6 +2819,7 @@ void xbUtil::FileMenu() case 12: CopyDbfStructure(); break; case 13: UpdateTableAutoCommit(); break; case 14: DisplayTableInfo(); break; + case 15: RenameTable(); break; case 99: break; default: std::cout << "Invalid Option" << std::endl; @@ -2886,7 +2919,10 @@ void xbUtil::SystemMenu() void xbUtil::MainMenu() { int option = 0; - std::cout << std::endl<< std::endl << "XBase64 Utility Program"; + std::cout << std::endl<< std::endl << "XBase64 Utility Program " << + xbase_VERSION_MAJOR << "." << xbase_VERSION_MINOR << "." << + xbase_VERSION_PATCH << "\n"; + DisplayActiveTable(); while( option != 99 ) { std::cout << std::endl << std::endl << " 0 - Main Menu" << std::endl; @@ -2968,6 +3004,7 @@ void xbUtil::MainMenu() } } /*************************************************************************************/ + #ifdef XB_INDEX_SUPPORT void xbUtil::DisplayOpenIndexFiles(){ @@ -3425,8 +3462,8 @@ void xbUtil::AssociateNonProdIx(){ std::cout << "See InfFile menu option, option 11 from the main menu or =11 from here\n"; } -#ifdef XB_DEBUG_SUPPORT +#ifdef XB_DEBUG_SUPPORT void xbUtil::DumpRecsByIx( xbInt16 iOpt ){ // iDirection = 0 - Forward - MDX // = 1 - Reverse - MDX |