diff options
Diffstat (limited to 'src/Client/UserListCommands.cpp')
-rw-r--r-- | src/Client/UserListCommands.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/src/Client/UserListCommands.cpp b/src/Client/UserListCommands.cpp index 7774240..947cbc1 100644 --- a/src/Client/UserListCommands.cpp +++ b/src/Client/UserListCommands.cpp @@ -42,7 +42,7 @@ const UserListCommands::Command UserListCommands::commands[] = { {{0}, 0, 0, 0, 0} }; -const UserListCommands::Command* UserListCommands::findCommand(const std::string& command) { +const UserListCommands::Command* UserListCommands::findCommand(const Core::String& command) { for(int i = 0; commands[i].commands[0] != 0; ++i) { for(int j = 0; commands[i].commands[j] != 0; ++j) { if(command == commands[i].commands[j]) { @@ -54,7 +54,7 @@ const UserListCommands::Command* UserListCommands::findCommand(const std::string return 0; } -void UserListCommands::printUsage(const std::string& command) { +void UserListCommands::printUsage(const Core::String& command) { const UserListCommands::Command *cmd = findCommand(command); if(cmd) @@ -62,7 +62,7 @@ void UserListCommands::printUsage(const std::string& command) { } -void UserListCommands::helpCommand(CommandParser* /*commandParser*/, const std::vector<std::string> &args) { +void UserListCommands::helpCommand(CommandParser* /*commandParser*/, const std::vector<Core::String> &args) { if(args.size() <= 2) { std::cout << "Available commands:" << std::endl << std::endl; @@ -91,7 +91,7 @@ void UserListCommands::helpCommand(CommandParser* /*commandParser*/, const std:: } } -void UserListCommands::listCommand(CommandParser *commandParser, const std::vector<std::string>& /*args*/) { +void UserListCommands::listCommand(CommandParser *commandParser, const std::vector<Core::String>& /*args*/) { boost::shared_ptr<Requests::UserLists::UserListListRequest> userListRequest(new Requests::UserLists::UserListListRequest(commandParser->application)); boost::shared_ptr<Requests::UserLists::UserListDiffListRequest> userListDiffRequest(new Requests::UserLists::UserListDiffListRequest(commandParser->application)); @@ -126,7 +126,7 @@ void UserListCommands::listCommand(CommandParser *commandParser, const std::vect std::cout << "There are " << userLists->getSize() << " user lists stored on the server:" << std::endl; for(Common::XmlData::List::const_iterator userList = userLists->begin(); userList != userLists->end(); ++userList) { - std::cout << " " << userList->get<const std::string&>("name") << std::endl; + std::cout << " " << userList->get<const Core::String&>("name") << std::endl; } } @@ -139,12 +139,12 @@ void UserListCommands::listCommand(CommandParser *commandParser, const std::vect std::cout << "There are " << userListDiffs->getSize() << " user list difference records stored on the server:" << std::endl; for(Common::XmlData::List::const_iterator diff = userListDiffs->begin(); diff != userListDiffs->end(); ++diff) { - std::cout << " " << diff->get<const std::string&>("name") << std::endl; + std::cout << " " << diff->get<const Core::String&>("name") << std::endl; } } } -void UserListCommands::showListCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserListCommands::showListCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 3) { std::cerr << args[0] << " " << args[1] << ": No list name given." << std::endl; printUsage("show_list"); @@ -188,7 +188,7 @@ void UserListCommands::showListCommand(CommandParser *commandParser, const std:: } } -void UserListCommands::importCommand(CommandParser* /*commandParser*/, const std::vector<std::string> &args) { +void UserListCommands::importCommand(CommandParser* /*commandParser*/, const std::vector<Core::String> &args) { if(args.size() < 3) { std::cerr << args[0] << " " << args[1] << ": No filename given." << std::endl; printUsage("import"); @@ -196,7 +196,7 @@ void UserListCommands::importCommand(CommandParser* /*commandParser*/, const std } else if(args.size() == 3) { try { - XLSReader reader(args[2]); + XLSReader reader(args[2].extract()); const std::list<boost::shared_ptr<XLSSheet> > &sheets = reader.getSheets(); if(sheets.empty()) { @@ -253,12 +253,12 @@ void UserListCommands::importCommand(CommandParser* /*commandParser*/, const std unsigned id = 1; for(std::vector<XLSSheet::RowType>::const_iterator rowIt = rows.begin(); rowIt != rows.end(); ++rowIt, ++id) { - const std::vector<std::string> &row = **rowIt; + const std::vector<Core::String> &row = **rowIt; Common::UserLists::UserListEntry entry; std::ostringstream stream; stream << id; - entry.setName(stream.str()); + entry.setName(stream.str().c_str()); for(unsigned col = 0; col < (*sheet)->getColumnCount(); ++col) { entry.setDetail((*sheet)->getColumnName(col), row[col]); @@ -283,21 +283,21 @@ void UserListCommands::importCommand(CommandParser* /*commandParser*/, const std void UserListCommands::printUserList(const Common::UserLists::UserList &list) { - std::map<std::string, unsigned> lengths; + std::map<Core::String, boost::int32_t> lengths; - static const std::string USER_NAME = "User name"; - static const std::string GROUP_NAME = "Group name"; + static const Core::String USER_NAME = "User name"; + static const Core::String GROUP_NAME = "Group name"; lengths.insert(std::make_pair(USER_NAME, USER_NAME.length())); lengths.insert(std::make_pair(GROUP_NAME, GROUP_NAME.length())); - std::set<std::string> details = list.getDetails(); - for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) { + std::set<Core::String> details = list.getDetails(); + for(std::set<Core::String>::iterator detail = details.begin(); detail != details.end(); ++detail) { lengths.insert(std::make_pair(*detail, detail->length())); } for(Common::UserLists::UserList::const_iterator user = list.begin(); user != list.end(); ++user) { - std::map<std::string, unsigned>::iterator it = lengths.find(USER_NAME); + std::map<Core::String, boost::int32_t>::iterator it = lengths.find(USER_NAME); if(user->getName().length() > it->second) it->second = user->getName().length(); @@ -305,9 +305,9 @@ void UserListCommands::printUserList(const Common::UserLists::UserList &list) { if(user->getGroup().length() > it->second) it->second = user->getGroup().length(); - for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) { + for(std::set<Core::String>::iterator detail = details.begin(); detail != details.end(); ++detail) { it = lengths.find(*detail); - std::string detailStr = user->getDetail(*detail); + Core::String detailStr = user->getDetail(*detail); if(detailStr.length() > it->second) it->second = detailStr.length(); } @@ -317,7 +317,7 @@ void UserListCommands::printUserList(const Common::UserLists::UserList &list) { printPadded(USER_NAME, lengths.find(USER_NAME)->second); std::cout << " "; printPadded(GROUP_NAME, lengths.find(GROUP_NAME)->second); - for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) { + for(std::set<Core::String>::iterator detail = details.begin(); detail != details.end(); ++detail) { std::cout << " "; printPadded(*detail, lengths.find(*detail)->second); } @@ -327,30 +327,30 @@ void UserListCommands::printUserList(const Common::UserLists::UserList &list) { printDelimiter(lengths.find(USER_NAME)->second); std::cout << "- -"; printDelimiter(lengths.find(GROUP_NAME)->second); - for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) { + for(std::set<Core::String>::iterator detail = details.begin(); detail != details.end(); ++detail) { std::cout << "- -"; printDelimiter(lengths.find(*detail)->second); } std::cout << "-" << std::endl; for(Common::UserLists::UserList::const_iterator user = list.begin(); user != list.end(); ++user) { - static const std::string UNSET("<unset>"); + static const Core::String UNSET("<unset>"); std::cout << " "; - if(!user->getName().empty()) + if(!user->getName().isEmpty()) printPadded(user->getName(), lengths.find(USER_NAME)->second); else printPadded(UNSET, lengths.find(USER_NAME)->second); std::cout << " "; - if(!user->getGroup().empty()) + if(!user->getGroup().isEmpty()) printPadded(user->getGroup(), lengths.find(GROUP_NAME)->second); else printPadded(UNSET, lengths.find(GROUP_NAME)->second); - for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) { + for(std::set<Core::String>::iterator detail = details.begin(); detail != details.end(); ++detail) { std::cout << " "; printPadded(user->getDetail(*detail), lengths.find(*detail)->second); } @@ -361,18 +361,18 @@ void UserListCommands::printUserList(const Common::UserLists::UserList &list) { void UserListCommands::printSheet(const XLSSheet &sheet, unsigned rowCount) { const std::vector<XLSSheet::RowType> &rows = sheet.getRows(); - std::vector<unsigned> lengths(sheet.getColumnCount()); + std::vector<boost::int32_t> lengths(sheet.getColumnCount()); for(unsigned col = 0; col < sheet.getColumnCount(); ++col) { - lengths[col] = sheet.getColumnName(col).size(); + lengths[col] = sheet.getColumnName(col).length(); } for(std::vector<XLSSheet::RowType>::const_iterator rowIt = rows.begin(); rowIt != rows.end() && (rowCount == 0 || rowIt != rows.begin()+rowCount); ++rowIt) { - const std::vector<std::string> &row = **rowIt; + const std::vector<Core::String> &row = **rowIt; for(unsigned col = 0; col < sheet.getColumnCount(); ++col) { - if(row[col].size() > lengths[col]) - lengths[col] = row[col].size(); + if(row[col].length() > lengths[col]) + lengths[col] = row[col].length(); } } @@ -391,7 +391,7 @@ void UserListCommands::printSheet(const XLSSheet &sheet, unsigned rowCount) { std::cout << std::endl; for(std::vector<XLSSheet::RowType>::const_iterator rowIt = rows.begin(); rowIt != rows.end() && (rowCount == 0 || rowIt != rows.begin()+rowCount); ++rowIt) { - const std::vector<std::string> &row = **rowIt; + const std::vector<Core::String> &row = **rowIt; for(unsigned col = 0; col < sheet.getColumnCount(); ++col) { std::cout << " "; @@ -409,19 +409,19 @@ void UserListCommands::printSheet(const XLSSheet &sheet, unsigned rowCount) { } } -void UserListCommands::printPadded(const std::string &str, unsigned length) { +void UserListCommands::printPadded(const Core::String &str, boost::int32_t length) { std::cout << str; if(str.length() < length) std::cout << std::string(length-str.length(), ' '); } -void UserListCommands::printDelimiter(unsigned length) { - printPadded(std::string(length, '-'), length); +void UserListCommands::printDelimiter(boost::int32_t length) { + printPadded(Core::String(std::string(length, '-').c_str()), length); } -void UserListCommands::userListCommand(CommandParser *commandParser, const std::vector<std::string> &args) { - std::string cmd; +void UserListCommands::userListCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { + Core::String cmd; if(args.size() < 2) cmd = "help"; |