| 64 | } |
| 65 | |
| 66 | int |
| 67 | DataOutputDatabaseHandler::open(char **dataDescription, int numData) |
| 68 | { |
| 69 | // |
| 70 | // check the args are valid & that database has been set |
| 71 | // |
| 72 | |
| 73 | if (theDatabase == 0) { |
| 74 | opserr << "DataOutputStreamHandler::open() - database has not been set\n"; |
| 75 | return -1; |
| 76 | } |
| 77 | |
| 78 | if (tableName == 0) { |
| 79 | opserr << "DataOutputDatabaseHandler::open() - no tableName passed or failed to get memory\n"; |
| 80 | return -1; |
| 81 | } |
| 82 | |
| 83 | if (dataDescription == 0) { |
| 84 | opserr << "DataOutputDatabaseHandler::open() - no column description data passed\n"; |
| 85 | return -1; |
| 86 | } |
| 87 | |
| 88 | if (numData < 0) { |
| 89 | opserr << "DataOutputDatabaseHandler::open() - numColumns (" << numData << ") < 0\n"; |
| 90 | return -1; |
| 91 | } else |
| 92 | numColumns = numData; |
| 93 | |
| 94 | // |
| 95 | // remove old if open has already been called |
| 96 | // |
| 97 | |
| 98 | if (columns != 0) { |
| 99 | for (int j=0; j<numColumns; j++) |
| 100 | delete [] columns[j]; |
| 101 | delete [] columns; |
| 102 | columns = 0; |
| 103 | } |
| 104 | |
| 105 | // |
| 106 | // create memory to store the dataDescription and make a copy of it |
| 107 | // |
| 108 | |
| 109 | columns = new char *[numColumns]; |
| 110 | if (columns == 0) { |
| 111 | opserr << "DataOutputDatabaseHandler::open() - out of memory creating array for columns of size (" << numData << ") < 0\n"; |
| 112 | numColumns = 0; |
| 113 | return -1; |
| 114 | } |
| 115 | |
| 116 | // make copy |
| 117 | for (int i=0; i<numColumns; i++) { |
| 118 | columns[i] = new char[strlen(dataDescription[i])+1]; |
| 119 | if (columns[i] == 0) { |
| 120 | opserr << "DataOutputDatabaseHandler::open() - out of memory creating copy of string " << dataDescription[i] << endln; |
| 121 | for (int j=0; j<i; j++) |
| 122 | delete [] columns[j]; |
| 123 | delete [] columns; |
nothing calls this directly
no test coverage detected