void XMLimport::readMap() { while( ! atEnd() ) { readNext(); if( isStartElement() ) { if( name() == "areas" ) { mpHost->mpMap->areaNamesMap.clear(); readAreas(); } else if( name() == "rooms" ) { readRooms(); } else if( name() == "environments" ) { readEnvColors(); } } } }
int main() { // Room names array. Static, but dynamically assigned to each room. // There must be more names here than MAX_ROOMS! // char *roomNames[10] = { "Mozart", "Schubert", "Beethoven", "Bach", "Wagner", "Vivaldi", "Pachelbel", "Satie", "Berg", "Chopin" }; // Array holding Room names read in from files (see readRooms()). // char *readRoomNames[MAX_ROOMS] = {0}; // Array of pointers to Rooms. This array is first used to set up // Rooms to be output to files (see setupRooms()), then it is reused // to read in Rooms from files (see readRooms()). // struct Room *prooms[MAX_ROOMS]; // Holds the name of the output file directory. // char dirName[30]; // Create the output file directory. The name is hardcoded to include // my ONID username (ratclier), then ".rooms.", then the PID of the // running program. This directory is not removed at the end of the // game, per assignment guidelines. // sprintf(dirName, "%s.%ld", "ratclier.rooms", (long) getpid()); mkdir(dirName, 0755); // File permissions: u = rwx, g = r-x, o = r-x // 421 4-1 4-1 // 7 5 5 // Set up the Room files. // setupRooms(prooms, dirName, roomNames); // Read the Room data in from files. // readRooms(prooms, dirName, readRoomNames); // Play the game. // playGame(prooms, readRoomNames); // Clean up Room struct pointers. // cleanRooms(prooms); return 0; }
bool ConfigurationReader::readHome(File* file, char* fileContentBuffer, Actor* actor, Configuration* config) { if (!readToBuffer(file, fileContentBuffer)) { return false; } //DiagnosticOutputStream.sendln(fileContentBuffer); StaticJsonBuffer<READ_FILE_BUFFOR_SIZE> jsonBuffer; JsonObject& root = jsonBuffer.parseObject(fileContentBuffer); if (!root.success()) { DiagnosticOutputStream.sendln("Config parse failed"); return false; } readConfig(root, config); JsonArray& jsonRooms = root[JSON_HOME][JSON_ROOMS].asArray(); readRooms(jsonRooms, actor); }