summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/mork/MorkParser.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/mork/MorkParser.cxx')
-rw-r--r--connectivity/source/drivers/mork/MorkParser.cxx133
1 files changed, 133 insertions, 0 deletions
diff --git a/connectivity/source/drivers/mork/MorkParser.cxx b/connectivity/source/drivers/mork/MorkParser.cxx
index da772a101f49..06373310e3d5 100644
--- a/connectivity/source/drivers/mork/MorkParser.cxx
+++ b/connectivity/source/drivers/mork/MorkParser.cxx
@@ -39,6 +39,7 @@
#include <stdexcept>
#include <fstream>
#include <iostream>
+#include <algorithm>
std::string g_Empty = "";
@@ -598,6 +599,138 @@ std::string &MorkParser::getColumn( int oid )
return foundIter->second;
}
+void MorkParser::retrieveLists(std::set<std::string>& lists)
+{
+ MorkTableMap* tables = getTables(defaultScope_);
+ if (!tables) return;
+ for (MorkTableMap::iterator TableIter = tables->begin();
+ TableIter != tables->end(); TableIter++ )
+ {
+#ifdef VERBOSE
+ std::cout << "\t Table:"
+ << ( ( int ) TableIter->first < 0 ? "-" : " " )
+ << std::hex << std::uppercase << TableIter->first << std::endl;
+#endif
+ MorkRowMap* rows = getRows( defaultListScope_, &TableIter->second );
+ if (!rows) return;
+ for ( MorkRowMap::iterator RowIter = rows->begin();
+ RowIter != rows->end(); RowIter++ )
+ {
+#ifdef VERBOSE
+ std::cout << "\t\t\t Row Id:"
+ << ( ( int ) RowIter->first < 0 ? "-" : " ")
+ << std::hex << std::uppercase << RowIter->first << std::endl;
+ std::cout << "\t\t\t\t Cells:\r\n";
+#endif
+ // Get cells
+ for ( MorkCells::iterator cellsIter = RowIter->second.begin();
+ cellsIter != RowIter->second.end(); cellsIter++ )
+ {
+ if (cellsIter->first == 0xC1)
+ {
+ lists.insert(getValue( cellsIter->second ));
+ break;
+ }
+ }
+ }
+ }
+}
+
+void MorkParser::getRecordKeys4List(std::string& listName, std::vector<std::string>& records)
+{
+ MorkTableMap* tables = getTables(defaultScope_);
+ if (!tables) return;
+ for (MorkTableMap::iterator TableIter = tables->begin();
+ TableIter != tables->end(); TableIter++ )
+ {
+#ifdef VERBOSE
+ std::cout << "\t Table:"
+ << ( ( int ) TableIter->first < 0 ? "-" : " " )
+ << std::hex << std::uppercase << TableIter->first << std::endl;
+#endif
+ MorkRowMap* rows = getRows( 0x81, &TableIter->second );
+ if (!rows) return;
+ for ( MorkRowMap::iterator RowIter = rows->begin();
+ RowIter != rows->end(); RowIter++ )
+ {
+#ifdef VERBOSE
+ std::cout << "\t\t\t Row Id:"
+ << ( ( int ) RowIter->first < 0 ? "-" : " ")
+ << std::hex << std::uppercase << RowIter->first << std::endl;
+ std::cout << "\t\t\t\t Cells:\r\n";
+#endif
+ // Get cells
+ bool listFound = false;
+ for ( MorkCells::iterator cellsIter = RowIter->second.begin();
+ cellsIter != RowIter->second.end(); cellsIter++ )
+ {
+ if (listFound)
+ {
+ if (cellsIter->first >= 0xC7)
+ {
+ std::string value = getValue(cellsIter->second);
+ records.push_back(value);
+ }
+ }
+ else if ((cellsIter->first == 0xC1) &&
+ listName == getValue( cellsIter->second ))
+ {
+ listFound = true;
+ }
+ }
+
+ }
+ }
+}
+
+void MorkParser::getRecordKeysForListTable(std::string& listName, std::set<int>& records)
+{
+ MorkTableMap* tables = getTables(defaultScope_);
+ if (!tables) return;
+ for (MorkTableMap::iterator TableIter = tables->begin();
+ TableIter != tables->end(); TableIter++ )
+ {
+#ifdef VERBOSE
+ std::cout << "\t Table:"
+ << ( ( int ) TableIter->first < 0 ? "-" : " " )
+ << std::hex << std::uppercase << TableIter->first << std::endl;
+#endif
+ MorkRowMap* rows = getRows( 0x81, &TableIter->second );
+ if (!rows) return;
+ for ( MorkRowMap::iterator RowIter = rows->begin();
+ RowIter != rows->end(); RowIter++ )
+ {
+#ifdef VERBOSE
+ std::cout << "\t\t\t Row Id:"
+ << ( ( int ) RowIter->first < 0 ? "-" : " ")
+ << std::hex << std::uppercase << RowIter->first << std::endl;
+ std::cout << "\t\t\t\t Cells:\r\n";
+#endif
+ // Get cells
+ bool listFound = false;
+ for ( MorkCells::iterator cellsIter = RowIter->second.begin();
+ cellsIter != RowIter->second.end(); cellsIter++ )
+ {
+ if (listFound)
+ {
+ if (cellsIter->first >= 0xC7)
+ {
+ std::string value = getValue(cellsIter->second);
+ int id = strtoul(value.c_str(), 0, 16);
+ records.insert(id);
+ }
+ }
+ else if ((cellsIter->first == 0xC1) &&
+ listName == getValue( cellsIter->second ))
+ {
+ listFound = true;
+ }
+ }
+
+ }
+ }
+}
+
void MorkParser::dump()
{
std::cout << "Column Dict:\r\n";