diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
commit | abada90e3f84dc703b8ddc9efcbed8a946fadead (patch) | |
tree | 2c6f9dccd510ea97cb927a7bd635422efaae547a /cpp/demo/Database/Oracle/proc/Client.cpp | |
parent | removing trace message (diff) | |
download | ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2 ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip |
Expanded tabs into spaces
Diffstat (limited to 'cpp/demo/Database/Oracle/proc/Client.cpp')
-rw-r--r-- | cpp/demo/Database/Oracle/proc/Client.cpp | 606 |
1 files changed, 303 insertions, 303 deletions
diff --git a/cpp/demo/Database/Oracle/proc/Client.cpp b/cpp/demo/Database/Oracle/proc/Client.cpp index 2260decdd0b..569fdf620fc 100644 --- a/cpp/demo/Database/Oracle/proc/Client.cpp +++ b/cpp/demo/Database/Oracle/proc/Client.cpp @@ -63,32 +63,32 @@ HRClient::HRClient() : _currentMenu(rootMenu) { _commonCommands = - "dept <number>: set department <number> as the current department\n" - "emp <number>: set employee <number> as the current employee\n" - "exit or quit: exit client\n" - "help: print this list of commands\n" - "root: go back to the root menu\n"; + "dept <number>: set department <number> as the current department\n" + "emp <number>: set employee <number> as the current employee\n" + "exit or quit: exit client\n" + "help: print this list of commands\n" + "root: go back to the root menu\n"; _rootCommands = - "create: create a new department\n" - "find <name>: find the department(s) with the given name\n" - "list: list all departments\n"; + "create: create a new department\n" + "find <name>: find the department(s) with the given name\n" + "list: list all departments\n"; - + _deptCommands = - "create: create a new employee in this department\n" - "find <name>: find employee(s) named <name> in this department\n" - "list: list all employees in this department\n" - "ping: ping this department\n" - "remove: remove this department\n" - "show: describe this department\n" - "update <dname|loc> <new value>: update this department\n"; + "create: create a new employee in this department\n" + "find <name>: find employee(s) named <name> in this department\n" + "list: list all employees in this department\n" + "ping: ping this department\n" + "remove: remove this department\n" + "show: describe this department\n" + "update <dname|loc> <new value>: update this department\n"; _empCommands = - "ping: ping this employee\n" - "remove: remove this employee\n" - "show: describe this employee\n" - "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; + "ping: ping this employee\n" + "remove: remove this employee\n" + "show: describe this employee\n" + "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; } void @@ -96,13 +96,13 @@ HRClient::checkEof(const string& command) const { if(!cin.eof()) { - string extra; - getline(cin, extra); - if(extra.size() > 0) - { - cout << "Warning: ignoring extra args '" << extra - << "' for '" << command << "'" << endl; - } + string extra; + getline(cin, extra); + if(extra.size() > 0) + { + cout << "Warning: ignoring extra args '" << extra + << "' for '" << command << "'" << endl; + } } } @@ -111,10 +111,10 @@ HRClient::checkCin(const string& command) const { if(!cin) { - cout << "Error: failed to read arguments for '" << command << "'" << endl; - cin.clear(); - cin.ignore(numeric_limits<streamsize>::max(), '\n'); - return false; + cout << "Error: failed to read arguments for '" << command << "'" << endl; + cin.clear(); + cin.ignore(numeric_limits<streamsize>::max(), '\n'); + return false; } checkEof(command); return true; @@ -124,7 +124,7 @@ void HRClient::invalidCommand(const string& command) const { cout << "Invalid command '" << command << "'. " - "Type 'help' for help." << endl; + "Type 'help' for help." << endl; cin.ignore(numeric_limits<streamsize>::max(), '\n'); } @@ -136,21 +136,21 @@ HRClient::help() const switch(_currentMenu) { - case rootMenu: - { - cout << _rootCommands; - break; - } - case deptMenu: - { - cout << _deptCommands; - break; - } - case empMenu: - { - cout << _empCommands; - break; - } + case rootMenu: + { + cout << _rootCommands; + break; + } + case deptMenu: + { + cout << _deptCommands; + break; + } + case empMenu: + { + cout << _empCommands; + break; + } } cout << "--- Common to all menus ---\n"; cout << _commonCommands << endl; @@ -163,8 +163,8 @@ HRClient::run(int argc, char* argv[]) _factory = DeptFactoryPrx::checkedCast(base); if(_factory == 0) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } Ice::EndpointSeq endpoints = _factory->ice_getEndpoints(); @@ -178,102 +178,102 @@ HRClient::run(int argc, char* argv[]) do { - cout << "==> "; - cin >> command; - - if(!cin) - { - break; - } - - try - { - - // - // Common commands - // - if(command == "dept") - { - int deptno; - cin >> deptno; - if(checkCin(command)) - { - _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); - if(_currentDept != 0) - { - _currentMenu = deptMenu; - } - else - { - cout << "There is no department with deptno " << deptno << endl; - } - } - } - else if(command == "emp") - { - int empno; - cin >> empno; - if(checkCin(command)) - { - _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); - if(_currentEmp != 0) - { - _currentMenu = empMenu; - } - else - { - cout << "There is no employee with empno " << empno << endl; - } - } - } - else if(command == "exit" || command == "quit") - { - checkEof(command); - break; - } - else if(command == "help") - { - checkEof(command); - help(); - } - else if(command == "root") - { - checkEof(command); - _currentMenu = rootMenu; - } - else if(_currentMenu == rootMenu) - { - doRootMenu(command); - } - else if(_currentMenu == deptMenu) - { - doDeptMenu(command); - } - else if(_currentMenu == empMenu) - { - doEmpMenu(command); - } - else - { - assert(0); - } - } - catch(const SqlException& e) - { - cout << "Caught a SqlException: " << e.reason << endl; - } - catch(const IceUtil::Exception& e) - { - cout << "Caught an Ice exception: " << e << endl; - } - catch(const std::exception& e) - { - cout << "Caught a std::exception: " << e.what() << endl; - } - catch(...) - { - cout << "Caught an unknown exception" << endl; - } + cout << "==> "; + cin >> command; + + if(!cin) + { + break; + } + + try + { + + // + // Common commands + // + if(command == "dept") + { + int deptno; + cin >> deptno; + if(checkCin(command)) + { + _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); + if(_currentDept != 0) + { + _currentMenu = deptMenu; + } + else + { + cout << "There is no department with deptno " << deptno << endl; + } + } + } + else if(command == "emp") + { + int empno; + cin >> empno; + if(checkCin(command)) + { + _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); + if(_currentEmp != 0) + { + _currentMenu = empMenu; + } + else + { + cout << "There is no employee with empno " << empno << endl; + } + } + } + else if(command == "exit" || command == "quit") + { + checkEof(command); + break; + } + else if(command == "help") + { + checkEof(command); + help(); + } + else if(command == "root") + { + checkEof(command); + _currentMenu = rootMenu; + } + else if(_currentMenu == rootMenu) + { + doRootMenu(command); + } + else if(_currentMenu == deptMenu) + { + doDeptMenu(command); + } + else if(_currentMenu == empMenu) + { + doEmpMenu(command); + } + else + { + assert(0); + } + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } } while(cin.good()); @@ -285,38 +285,38 @@ HRClient::doRootMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: deptno dname loc ==> "; - int deptno; - DeptDesc desc; - cin >> deptno >> desc.dname >> desc.loc; - - desc.dname = unquote(desc.dname); - desc.loc = unquote(desc.loc); - - if(checkCin("create parameters")) - { - _factory->createDept(deptno, desc); - cout << "Created new department number " << deptno << endl; - } + checkEof(command); + cout << "Please enter: deptno dname loc ==> "; + int deptno; + DeptDesc desc; + cin >> deptno >> desc.dname >> desc.loc; + + desc.dname = unquote(desc.dname); + desc.loc = unquote(desc.loc); + + if(checkCin("create parameters")) + { + _factory->createDept(deptno, desc); + cout << "Created new department number " << deptno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printDepts(_factory->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printDepts(_factory->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printDepts(_factory->findAll()); + checkEof(command); + printDepts(_factory->findAll()); } else { - invalidCommand(command); + invalidCommand(command); } } @@ -325,84 +325,84 @@ HRClient::doDeptMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; - int empno; - int mgrEmpno; - EmpDesc desc; - cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; - - desc.ename = unquote(desc.ename); - desc.job = unquote(desc.job); - - if(mgrEmpno != 0) - { - desc.mgr = _factory->findEmpByNo(mgrEmpno); - if(desc.mgr == 0) - { - cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; - } - } - desc.hiredate = unquote(desc.hiredate); - desc.sal = unquote(desc.sal); - desc.comm = unquote(desc.comm); - - desc.edept = _currentDept; - - if(checkCin("create parameters")) - { - _currentDept->createEmp(empno, desc); - cout << "Created new employee number " << empno << endl; - } + checkEof(command); + cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; + int empno; + int mgrEmpno; + EmpDesc desc; + cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; + + desc.ename = unquote(desc.ename); + desc.job = unquote(desc.job); + + if(mgrEmpno != 0) + { + desc.mgr = _factory->findEmpByNo(mgrEmpno); + if(desc.mgr == 0) + { + cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; + } + } + desc.hiredate = unquote(desc.hiredate); + desc.sal = unquote(desc.sal); + desc.comm = unquote(desc.comm); + + desc.edept = _currentDept; + + if(checkCin("create parameters")) + { + _currentDept->createEmp(empno, desc); + cout << "Created new employee number " << empno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printEmps(_currentDept->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printEmps(_currentDept->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printEmps(_currentDept->findAll()); + checkEof(command); + printEmps(_currentDept->findAll()); } else if(command == "ping") { - checkEof(command); - _currentDept->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentDept->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentDept->remove(); + checkEof(command); + _currentDept->remove(); } else if(command == "show") { - checkEof(command); - DeptDesc desc = _currentDept->getDesc(); - cout << "deptno: " << desc.deptno << endl; - cout << "dname: " << quote(desc.dname) << endl; - cout << "loc: " << quote(desc.loc) << endl; + checkEof(command); + DeptDesc desc = _currentDept->getDesc(); + cout << "deptno: " << desc.deptno << endl; + cout << "dname: " << quote(desc.dname) << endl; + cout << "loc: " << quote(desc.loc) << endl; } else if(command == "update") { - string field; - string newValue; - cin >> field >> newValue; - newValue = unquote(newValue); - - if(checkCin("update " + field)) - { - _currentDept->updateField(field, newValue); - } + string field; + string newValue; + cin >> field >> newValue; + newValue = unquote(newValue); + + if(checkCin("update " + field)) + { + _currentDept->updateField(field, newValue); + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -411,80 +411,80 @@ HRClient::doEmpMenu(const string& command) const { if(command == "ping") { - checkEof(command); - _currentEmp->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentEmp->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentEmp->remove(); + checkEof(command); + _currentEmp->remove(); } else if(command == "show") { - checkEof(command); - EmpDesc desc = _currentEmp->getDesc(); - cout << "empno: " << desc.empno << endl; - cout << "ename: " << quote(desc.ename) << endl; - cout << "job: " << quote(desc.job) << endl; - cout << "mgr: "; - if(desc.mgr == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.mgr->getDesc().empno << endl; - } - cout << "hiredate: " << quote(desc.hiredate) << endl; - cout << "sal: " << quote(desc.sal) << endl; - cout << "comm: " << quote(desc.comm) << endl; - cout << "dept: "; - if(desc.edept == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.edept->getDesc().deptno << endl; - } + checkEof(command); + EmpDesc desc = _currentEmp->getDesc(); + cout << "empno: " << desc.empno << endl; + cout << "ename: " << quote(desc.ename) << endl; + cout << "job: " << quote(desc.job) << endl; + cout << "mgr: "; + if(desc.mgr == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.mgr->getDesc().empno << endl; + } + cout << "hiredate: " << quote(desc.hiredate) << endl; + cout << "sal: " << quote(desc.sal) << endl; + cout << "comm: " << quote(desc.comm) << endl; + cout << "dept: "; + if(desc.edept == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.edept->getDesc().deptno << endl; + } } else if(command == "update") { - string field; - cin >> field; - if(field == "mgr") - { - int mgr; - cin >> mgr; - if(checkCin("update mgr")) - { - _currentEmp->updateMgr(mgr); - } - } - else if(field == "dept") - { - int deptno; - cin >> deptno; - if(checkCin("update dept")) - { - _currentEmp->updateDept(deptno); - } - } - else - { - string newValue; - cin >> newValue; - newValue = unquote(newValue); - if(checkCin("update " + field)) - { - _currentEmp->updateField(field, newValue); - } - } + string field; + cin >> field; + if(field == "mgr") + { + int mgr; + cin >> mgr; + if(checkCin("update mgr")) + { + _currentEmp->updateMgr(mgr); + } + } + else if(field == "dept") + { + int deptno; + cin >> deptno; + if(checkCin("update dept")) + { + _currentEmp->updateDept(deptno); + } + } + else + { + string newValue; + cin >> newValue; + newValue = unquote(newValue); + if(checkCin("update " + field)) + { + _currentEmp->updateField(field, newValue); + } + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -494,15 +494,15 @@ HRClient::printDepts(const DeptPrxSeq& depts) const cout << "Deptno\t Dname\t Loc" << endl; if(depts.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) - { - HR::DeptDesc desc = (*p)->getDesc(); - cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; - } + for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) + { + HR::DeptDesc desc = (*p)->getDesc(); + cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; + } } } @@ -512,15 +512,15 @@ HRClient::printEmps(const EmpPrxSeq& emps) const cout << "Empno\t Ename" << endl; if(emps.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) - { - HR::EmpDesc desc = (*p)->getDesc(); - cout << desc.empno << "\t " << desc.ename << endl; - } + for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) + { + HR::EmpDesc desc = (*p)->getDesc(); + cout << desc.empno << "\t " << desc.ename << endl; + } } } @@ -530,11 +530,11 @@ HRClient::quote(const string& str) { if(str == "") { - return "''"; + return "''"; } else { - return str; + return str; } } @@ -544,10 +544,10 @@ HRClient::unquote(const string& str) { if(str == "''") { - return ""; + return ""; } else { - return str; + return str; } } |