1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#ident "%W%"
////////////////////////////////////////////////////////////////////////////////
// //
// File: ACColumnInfo.C //
// //
// Date: August 3, 1995 //
// //
////////////////////////////////////////////////////////////////////////////////
#include "obj_handler/ACColumnInfo.h"
// constructor
ACColumnInfo::ACColumnInfo()
{
#if CPLUSREL >= 6
dictionary = new RWTValHashMap58<RWCString,RWTValSlist<Column> *,str_hash,StringEqual> ();
#else
dictionary = new RWTValHashMap<RWCString,RWTValSlist<Column> *,str_hash,StringEqual> ();
#endif
index = -1;
}
// destructor
ACColumnInfo::~ACColumnInfo()
{
RWTValSlist<Column> *list_ptr;
#if CPLUSREL >= 6
RWTValHashMapIterator58<RWCString,RWTValSlist<Column> *,str_hash,StringEqual> iterator(*dictionary);
#else
RWTValHashMapIterator<RWCString,RWTValSlist<Column> *,str_hash,StringEqual> iterator(*dictionary);
#endif
// iterate through every object
while (++iterator)
{
// delete the column list
list_ptr = iterator.value();
list_ptr->clear();
delete list_ptr;
}
// delete the dictionary
dictionary->clear();
delete dictionary;
}
// add a new Accounts object to the dictionary
int ACColumnInfo::addObject(const RWCString& object_name)
{
RWCString tmpstr;
RWTValSlist<Column> *list_ptr;
index = -1;
if (dictionary->find(object_name, tmpstr) == FALSE)
{
list_ptr = new RWTValSlist<Column>;
column_list_ptr = list_ptr;
dictionary->insertKeyAndValue(object_name, list_ptr);
return 0;
}
else
return 1;
}
// add a new column to the column list
void ACColumnInfo::addColumn()
{
index = -1;
column_list_ptr->append(column);
}
// advance to the next column in the column list
int ACColumnInfo::operator++()
{
if (column_list_ptr->isEmpty())
{
// the column list is empty
index = -1;
}
else if (index == -1)
{
// point to the first column in the column list
index = 0;
column = column_list_ptr->at(index);
}
else if (index < (column_list_ptr->entries() - 1))
{
// advance to the next column in the column list
column = column_list_ptr->at(++index);
}
else
{
// the column list is empty
index = -1;
}
// return with an appropriate return code
if (index >= 0)
return 1;
else
return 0;
}
// find and use the column list of the Accounts object
int ACColumnInfo::findObject(const RWCString& object_name)
{
RWTValSlist<Column> *list_ptr;
if (dictionary->findValue(object_name, list_ptr) == TRUE)
{
index = -1;
column_list_ptr = list_ptr;
count = list_ptr->entries();
return 0;
}
else
return 1;
}
|