diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-09-27 19:58:24 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-09-27 19:58:24 +0200 |
commit | b40ba0cf91603b695f1f2380cbd39966a458f22f (patch) | |
tree | 1fec48ddc59eb1392fac38495b230e4b2cbf7528 /src/Client | |
parent | e1d8490f0654a3da0b900407d80d91d8d0da68c8 (diff) | |
download | mad-b40ba0cf91603b695f1f2380cbd39966a458f22f.tar mad-b40ba0cf91603b695f1f2380cbd39966a458f22f.zip |
Use Unicode-aware String class instead of std::string
Diffstat (limited to 'src/Client')
24 files changed, 286 insertions, 284 deletions
diff --git a/src/Client/Authenticators/ChallengeResponseAuthenticator.cpp b/src/Client/Authenticators/ChallengeResponseAuthenticator.cpp index 4aadb63..7ccaa63 100644 --- a/src/Client/Authenticators/ChallengeResponseAuthenticator.cpp +++ b/src/Client/Authenticators/ChallengeResponseAuthenticator.cpp @@ -40,7 +40,7 @@ void ChallengeResponseAuthenticator::ChallengeResponseAuthRequest::sendRequest() void ChallengeResponseAuthenticator::ChallengeResponseAuthRequest::handlePacket(boost::shared_ptr<const Common::XmlData> packet) { if(packet->getType() == "Error") { - signalFinished(Core::Exception(packet->get<const std::string&>("Where"), static_cast<Core::Exception::ErrorCode>(packet->get<long>("ErrorCode")), + signalFinished(Core::Exception(packet->get<const Core::String&>("Where").extract(), static_cast<Core::Exception::ErrorCode>(packet->get<long>("ErrorCode")), packet->get<long>("SubCode"), packet->get<long>("SubSubCode"))); return; } @@ -58,7 +58,7 @@ void ChallengeResponseAuthenticator::ChallengeResponseAuthRequest::handlePacket( ret.set("user", username); - std::vector<boost::uint8_t> hashedPassword = Common::Hash::hash(std::vector<boost::uint8_t>(password.begin(), password.end()), hash); + std::vector<boost::uint8_t> hashedPassword = Common::Hash::hash(password, hash); const std::vector<boost::uint8_t> &challenge = packet->get<const std::vector<boost::uint8_t>&>("data"); hashedPassword.insert(hashedPassword.end(), challenge.begin(), challenge.end()); @@ -79,8 +79,8 @@ void ChallengeResponseAuthenticator::ChallengeResponseAuthRequest::handlePacket( } } -void ChallengeResponseAuthenticator::authenticate(Common::Application *application, Common::Connection *con, const std::string &username, const std::string &password) throw (Core::Exception) { - std::string hash; +void ChallengeResponseAuthenticator::authenticate(Common::Application *application, Common::Connection *con, const Core::String &username, const Core::String &password) throw (Core::Exception) { + Core::String hash; { boost::shared_ptr<Common::Requests::AuthMethodRequest> request(new Common::Requests::AuthMethodRequest(application)); @@ -96,14 +96,14 @@ void ChallengeResponseAuthenticator::authenticate(Common::Application *applicati const Common::XmlData::List *methods = result.first->getList("methods"); for(Common::XmlData::List::const_iterator method = methods->begin(); method != methods->end(); ++method) { - if(method->get<const std::string&>("name") != "Challenge-Response") + if(method->get<const Core::String&>("name") != "Challenge-Response") continue; const Common::XmlData::List *subMethods = method->getList("subMethods"); for(Common::XmlData::List::const_iterator subMethod = subMethods->begin(); subMethod != subMethods->end(); ++subMethod) { - if(Common::Hash::isHashSupported(subMethod->get<const std::string&>("name"))) { - hash = subMethod->get<const std::string&>("name"); + if(Common::Hash::isHashSupported(subMethod->get<const Core::String&>("name"))) { + hash = subMethod->get<const Core::String&>("name"); break; } } @@ -111,11 +111,11 @@ void ChallengeResponseAuthenticator::authenticate(Common::Application *applicati break; } - if(hash.empty()) + if(hash.isEmpty()) throw Core::Exception(Core::Exception::NOT_AVAILABLE); } - application->logf(Core::Logger::LOG_VERBOSE, "Authenticating with method 'Challenge-Response' using hash '%s'...", hash.c_str()); + application->logf(Core::Logger::LOG_VERBOSE, "Authenticating with method 'Challenge-Response' using hash '%s'...", hash.extract().c_str()); boost::shared_ptr<ChallengeResponseAuthRequest> request(new ChallengeResponseAuthRequest(application, username, password, hash)); diff --git a/src/Client/Authenticators/ChallengeResponseAuthenticator.h b/src/Client/Authenticators/ChallengeResponseAuthenticator.h index 3906ba9..5787b1b 100644 --- a/src/Client/Authenticators/ChallengeResponseAuthenticator.h +++ b/src/Client/Authenticators/ChallengeResponseAuthenticator.h @@ -32,10 +32,10 @@ class MAD_CLIENT_EXPORT ChallengeResponseAuthenticator { private: class MAD_CLIENT_EXPORT ChallengeResponseAuthRequest : public Common::Request { private: - std::string username; - std::string password; + Core::String username; + Core::String password; - std::string hash; + Core::String hash; bool hasResponded; @@ -44,14 +44,14 @@ class MAD_CLIENT_EXPORT ChallengeResponseAuthenticator { virtual void handlePacket(boost::shared_ptr<const Common::XmlData> packet); public: - ChallengeResponseAuthRequest(Common::Application *application, const std::string &username0, const std::string &password0, const std::string &hash0) + ChallengeResponseAuthRequest(Common::Application *application, const Core::String &username0, const Core::String &password0, const Core::String &hash0) : Common::Request(application), username(username0), password(password0), hash(hash0), hasResponded(false) {} }; ChallengeResponseAuthenticator(); public: - static void authenticate(Common::Application *application, Common::Connection *con, const std::string &username, const std::string &password) throw (Core::Exception); + static void authenticate(Common::Application *application, Common::Connection *con, const Core::String &username, const Core::String &password) throw (Core::Exception); }; } diff --git a/src/Client/Authenticators/PasswordAuthenticator.cpp b/src/Client/Authenticators/PasswordAuthenticator.cpp index bf2a284..2ac9d68 100644 --- a/src/Client/Authenticators/PasswordAuthenticator.cpp +++ b/src/Client/Authenticators/PasswordAuthenticator.cpp @@ -35,17 +35,22 @@ void PasswordAuthenticator::PasswordAuthRequest::sendRequest() { packet.set("user", username); - if(hash == "Clear") - packet.set("data", std::vector<boost::uint8_t>(password.begin(), password.end())); - else - packet.set("data", Common::Hash::hash(std::vector<boost::uint8_t>(password.begin(), password.end()), hash)); + + + if(hash == "Clear") { + std::string passwordStr = password.extractUTF8(); + packet.set("data", std::vector<boost::uint8_t>(passwordStr.begin(), passwordStr.end())); + } + else { + packet.set("data", Common::Hash::hash(password, hash)); + } sendPacket(packet); } void PasswordAuthenticator::PasswordAuthRequest::handlePacket(boost::shared_ptr<const Common::XmlData> packet) { if(packet->getType() == "Error") { - signalFinished(Core::Exception(packet->get<const std::string&>("Where"), static_cast<Core::Exception::ErrorCode>(packet->get<long>("ErrorCode")), + signalFinished(Core::Exception(packet->get<const Core::String&>("Where").extract(), static_cast<Core::Exception::ErrorCode>(packet->get<long>("ErrorCode")), packet->get<long>("SubCode"), packet->get<long>("SubSubCode"))); return; } @@ -57,8 +62,8 @@ void PasswordAuthenticator::PasswordAuthRequest::handlePacket(boost::shared_ptr< signalFinished(packet); } -void PasswordAuthenticator::authenticate(Common::Application *application, Common::Connection *con, const std::string &username, const std::string &password) throw (Core::Exception) { - std::string hash; +void PasswordAuthenticator::authenticate(Common::Application *application, Common::Connection *con, const Core::String &username, const Core::String &password) throw (Core::Exception) { + Core::String hash; { boost::shared_ptr<Common::Requests::AuthMethodRequest> request(new Common::Requests::AuthMethodRequest(application)); @@ -74,14 +79,14 @@ void PasswordAuthenticator::authenticate(Common::Application *application, Commo const Common::XmlData::List *methods = result.first->getList("methods"); for(Common::XmlData::List::const_iterator method = methods->begin(); method != methods->end(); ++method) { - if(method->get<const std::string&>("name") != "Password") + if(method->get<const Core::String&>("name") != "Password") continue; const Common::XmlData::List *subMethods = method->getList("subMethods"); for(Common::XmlData::List::const_iterator subMethod = subMethods->begin(); subMethod != subMethods->end(); ++subMethod) { - if(Common::Hash::isHashSupported(subMethod->get<const std::string&>("name"))) { - hash = subMethod->get<const std::string&>("name"); + if(Common::Hash::isHashSupported(subMethod->get<const Core::String&>("name"))) { + hash = subMethod->get<const Core::String&>("name"); break; } } @@ -89,11 +94,11 @@ void PasswordAuthenticator::authenticate(Common::Application *application, Commo break; } - if(hash.empty()) + if(hash.isEmpty()) throw Core::Exception(Core::Exception::NOT_AVAILABLE); } - application->logf(Core::Logger::LOG_VERBOSE, "Authenticating with method 'Password' using hash '%s'...", hash.c_str()); + application->logf(Core::Logger::LOG_VERBOSE, "Authenticating with method 'Password' using hash '%s'...", hash.extract().c_str()); boost::shared_ptr<PasswordAuthRequest> request(new PasswordAuthRequest(application, username, password, hash)); diff --git a/src/Client/Authenticators/PasswordAuthenticator.h b/src/Client/Authenticators/PasswordAuthenticator.h index 70ab3f2..e0ae8ef 100644 --- a/src/Client/Authenticators/PasswordAuthenticator.h +++ b/src/Client/Authenticators/PasswordAuthenticator.h @@ -32,24 +32,24 @@ class MAD_CLIENT_EXPORT PasswordAuthenticator { private: class MAD_CLIENT_EXPORT PasswordAuthRequest : public Common::Request { private: - std::string username; - std::string password; + Core::String username; + Core::String password; - std::string hash; + Core::String hash; protected: virtual void sendRequest(); virtual void handlePacket(boost::shared_ptr<const Common::XmlData> packet); public: - PasswordAuthRequest(Common::Application *application, const std::string &username0, const std::string &password0, const std::string &hash0) + PasswordAuthRequest(Common::Application *application, const Core::String &username0, const Core::String &password0, const Core::String &hash0) : Common::Request(application), username(username0), password(password0), hash(hash0) {} }; PasswordAuthenticator(); public: - static void authenticate(Common::Application *application, Common::Connection *con, const std::string &username, const std::string &password) throw (Core::Exception); + static void authenticate(Common::Application *application, Common::Connection *con, const Core::String &username, const Core::String &password) throw (Core::Exception); }; } diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp index a271860..9b5c6bf 100644 --- a/src/Client/CommandParser.cpp +++ b/src/Client/CommandParser.cpp @@ -63,7 +63,7 @@ const CommandParser::Command CommandParser::commands[] = { }; -const CommandParser::Command* CommandParser::findCommand(const std::string& command) { +const CommandParser::Command* CommandParser::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]) { @@ -75,7 +75,7 @@ const CommandParser::Command* CommandParser::findCommand(const std::string& comm return 0; } -void CommandParser::printUsage(const std::string& command) { +void CommandParser::printUsage(const Core::String& command) { const CommandParser::Command *cmd = findCommand(command); if(cmd) @@ -83,14 +83,14 @@ void CommandParser::printUsage(const std::string& command) { } -std::map<std::string, Common::HostInfo> CommandParser::parseHostList(const std::vector<std::string> &args, bool mustBeActive) { - const std::map<std::string, Common::HostInfo>& hosts = application->getInformationManager()->getDaemons(); - std::map<std::string, Common::HostInfo> ret; +std::map<Core::String, Common::HostInfo> CommandParser::parseHostList(const std::vector<Core::String> &args, bool mustBeActive) { + const std::map<Core::String, Common::HostInfo>& hosts = application->getInformationManager()->getDaemons(); + std::map<Core::String, Common::HostInfo> ret; - for(std::vector<std::string>::const_iterator arg = args.begin(); arg != args.end(); ++arg) { + for(std::vector<Core::String>::const_iterator arg = args.begin(); arg != args.end(); ++arg) { if(*arg == "*") { if(mustBeActive) { - for(std::map<std::string, Common::HostInfo>::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { + for(std::map<Core::String, Common::HostInfo>::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { if(host->second.getState() != Common::HostInfo::INACTIVE) ret.insert(*host); } @@ -103,7 +103,7 @@ std::map<std::string, Common::HostInfo> CommandParser::parseHostList(const std:: } } else { - std::map<std::string, Common::HostInfo>::const_iterator host = hosts.find(*arg); + std::map<Core::String, Common::HostInfo>::const_iterator host = hosts.find(*arg); if(host == hosts.end()) std::cerr << "Host '" << *arg << "' doesn't exist." << std::endl; @@ -117,7 +117,7 @@ std::map<std::string, Common::HostInfo> CommandParser::parseHostList(const std:: return ret; } -void CommandParser::helpCommand(const std::vector<std::string> &args) { +void CommandParser::helpCommand(const std::vector<Core::String> &args) { if(args.size() == 1) { std::cout << "Available commands:" << std::endl << std::endl; @@ -146,8 +146,8 @@ void CommandParser::helpCommand(const std::vector<std::string> &args) { } } -void CommandParser::listHostsCommand(const std::vector<std::string> &args) { - const std::map<std::string, Common::HostInfo>& hosts = application->getInformationManager()->getDaemons(); +void CommandParser::listHostsCommand(const std::vector<Core::String> &args) { + const std::map<Core::String, Common::HostInfo>& hosts = application->getInformationManager()->getDaemons(); if(args.size() == 1) { if(hosts.empty()) { @@ -157,7 +157,7 @@ void CommandParser::listHostsCommand(const std::vector<std::string> &args) { bool output = false; - for(std::map<std::string, Common::HostInfo>::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { + for(std::map<Core::String, Common::HostInfo>::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { if(host->second.getState() == Common::HostInfo::INACTIVE) continue; @@ -186,7 +186,7 @@ void CommandParser::listHostsCommand(const std::vector<std::string> &args) { std::cout << "Host list:" << std::endl; - for(std::map<std::string, Common::HostInfo>::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { + for(std::map<Core::String, Common::HostInfo>::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { std::cout << " " << host->first << " (" << (host->second.getState() == Common::HostInfo::RUNNING ? "running" : "inactive") << ")" << std::endl; } @@ -198,7 +198,7 @@ void CommandParser::listHostsCommand(const std::vector<std::string> &args) { } } -void CommandParser::exitCommand(const std::vector<std::string> &/*args*/) { +void CommandParser::exitCommand(const std::vector<Core::String> &/*args*/) { boost::shared_ptr<Common::Requests::DisconnectRequest> request(new Common::Requests::DisconnectRequest(application)); application->getRequestManager()->sendRequest(connection, request); @@ -212,26 +212,26 @@ void CommandParser::exitCommand(const std::vector<std::string> &/*args*/) { disconnect = true; } -bool CommandParser::parse(const std::string &cmd) { - std::vector<Core::UnicodeString> splitCmd; +bool CommandParser::parse(const Core::String &cmd) { + std::vector<Core::String> splitCmd; - Core::Tokenizer::tokenize(cmd.c_str(), splitCmd); + Core::Tokenizer::tokenize(cmd, splitCmd); if(splitCmd.empty()) return true; - const Command* command = findCommand(splitCmd[0].extract()); + const Command* command = findCommand(splitCmd[0]); if(command) { - std::vector<std::string> strings; + std::vector<Core::String> strings; - for(std::vector<Core::UnicodeString>::iterator it = splitCmd.begin(); it != splitCmd.end(); ++it) - strings.push_back(it->extract()); + for(std::vector<Core::String>::iterator it = splitCmd.begin(); it != splitCmd.end(); ++it) + strings.push_back(*it); command->function(this, strings); } else { - std::cerr << "Unknown command '" << splitCmd[0].extract() << "'." << std::endl; + std::cerr << "Unknown command '" << splitCmd[0] << "'." << std::endl; } return true; diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h index c4a0f79..87262d7 100644 --- a/src/Client/CommandParser.h +++ b/src/Client/CommandParser.h @@ -29,7 +29,6 @@ #include <boost/smart_ptr.hpp> #include <map> -#include <string> #include <vector> namespace Mad { @@ -57,7 +56,7 @@ class MAD_CLIENT_EXPORT CommandParser { const char* desc; const char* longdesc; - boost::function2<void, CommandParser*, const std::vector<std::string> > function; + boost::function2<void, CommandParser*, const std::vector<Core::String> > function; }; static const Command commands[]; @@ -68,14 +67,14 @@ class MAD_CLIENT_EXPORT CommandParser { bool disconnect; - static const Command* findCommand(const std::string& command); + static const Command* findCommand(const Core::String& command); - static void printUsage(const std::string& command); - std::map<std::string, Common::HostInfo> parseHostList(const std::vector<std::string> &args, bool mustBeActive = false); + static void printUsage(const Core::String& command); + std::map<Core::String, Common::HostInfo> parseHostList(const std::vector<Core::String> &args, bool mustBeActive = false); - void helpCommand(const std::vector<std::string> &args); - void listHostsCommand(const std::vector<std::string> &args); - void exitCommand(const std::vector<std::string> &args); + void helpCommand(const std::vector<Core::String> &args); + void listHostsCommand(const std::vector<Core::String> &args); + void exitCommand(const std::vector<Core::String> &args); public: CommandParser(Application *application0, Common::Connection *connection0); @@ -84,10 +83,10 @@ class MAD_CLIENT_EXPORT CommandParser { return connection; } - bool parse(const std::string &cmd); + bool parse(const Core::String &cmd); void requestDisconnect() { - exitCommand(std::vector<std::string>()); + exitCommand(std::vector<Core::String>()); } bool willDisconnect() const { diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp index 0021d49..e66f43d 100644 --- a/src/Client/InformationManager.cpp +++ b/src/Client/InformationManager.cpp @@ -36,7 +36,7 @@ void InformationManager::DaemonStateUpdateRequestHandler::handleRequest(boost::s { boost::lock_guard<boost::mutex> lock(informationManager->mutex); - std::map<std::string, Common::HostInfo>::iterator host = informationManager->daemons.find(packet->get<const std::string&>("name")); + std::map<Core::String, Common::HostInfo>::iterator host = informationManager->daemons.find(packet->get<const Core::String&>("name")); if(host != informationManager->daemons.end()) host->second.setState(static_cast<Common::HostInfo::State>(packet->get<long>("state"))); else @@ -83,8 +83,8 @@ void InformationManager::daemonListRequestFinished(boost::shared_ptr<const Commo if(list) { for(Common::XmlData::List::const_iterator entry = list->begin(); entry != list->end(); ++entry) { Common::HostInfo info; - info.setName(entry->get<const std::string&>("name")); - info.setIP(entry->get<const std::string&>("address")); + info.setName(entry->get<const Core::String&>("name")); + info.setIP(entry->get<const Core::String&>("address").extract()); info.setState(static_cast<Common::HostInfo::State>(entry->get<long>("state"))); daemons.insert(std::make_pair(info.getName(), info)); diff --git a/src/Client/InformationManager.h b/src/Client/InformationManager.h index dcb0212..65672ef 100644 --- a/src/Client/InformationManager.h +++ b/src/Client/InformationManager.h @@ -59,7 +59,7 @@ class MAD_CLIENT_EXPORT InformationManager : private boost::noncopyable { boost::shared_ptr<Common::Request> updateRequest; - std::map<std::string, Common::HostInfo> daemons; + std::map<Core::String, Common::HostInfo> daemons; bool updating; @@ -86,7 +86,7 @@ class MAD_CLIENT_EXPORT InformationManager : private boost::noncopyable { } - std::map<std::string, Common::HostInfo> getDaemons() { + std::map<Core::String, Common::HostInfo> getDaemons() { boost::lock_guard<boost::mutex> lock(mutex); return daemons; } diff --git a/src/Client/PasswordReader.cpp b/src/Client/PasswordReader.cpp index d5c4fe8..8d549f5 100644 --- a/src/Client/PasswordReader.cpp +++ b/src/Client/PasswordReader.cpp @@ -32,7 +32,7 @@ namespace Mad { namespace Client { -std::string PasswordReader::readPassword(const std::string &prompt) { +Core::String PasswordReader::readPassword(const Core::String &prompt) { std::string password; #ifdef _WIN32 @@ -41,7 +41,7 @@ std::string PasswordReader::readPassword(const std::string &prompt) { GetConsoleMode(handle, &mode); SetConsoleMode(handle, mode & ~(ENABLE_ECHO_INPUT)); - std::cout << prompt << std::flush; + std::cout << prompt.extract() << std::flush; std::getline(std::cin, password); std::cout << std::endl; @@ -56,14 +56,14 @@ std::string PasswordReader::readPassword(const std::string &prompt) { termnew.c_lflag &= ~ECHO; tcsetattr(STDIN_FILENO, TCSAFLUSH, &termnew); - std::cout << prompt << std::flush; + std::cout << prompt.extract() << std::flush; std::getline(std::cin, password); std::cout << std::endl; tcsetattr(STDIN_FILENO, TCSAFLUSH, &termold); #endif - return password; + return password.c_str(); } } diff --git a/src/Client/PasswordReader.h b/src/Client/PasswordReader.h index 35487c4..d96c9c1 100644 --- a/src/Client/PasswordReader.h +++ b/src/Client/PasswordReader.h @@ -22,7 +22,7 @@ #include "export.h" -#include <string> +#include <Core/String.h> namespace Mad { namespace Client { @@ -32,10 +32,10 @@ class MAD_CLIENT_EXPORT PasswordReader { PasswordReader(); public: - static std::string readPassword(const std::string &prompt); + static Core::String readPassword(const Core::String &prompt); }; } } -#endif /* MAD_CLIENT_PASSWORDREADER_H_ */
\ No newline at end of file +#endif /* MAD_CLIENT_PASSWORDREADER_H_ */ diff --git a/src/Client/Requests/DaemonCommandRequest.h b/src/Client/Requests/DaemonCommandRequest.h index 04e0304..e4efa99 100644 --- a/src/Client/Requests/DaemonCommandRequest.h +++ b/src/Client/Requests/DaemonCommandRequest.h @@ -23,7 +23,6 @@ #include "../export.h" #include <Common/Request.h> -#include <string> namespace Mad { namespace Client { @@ -31,14 +30,14 @@ namespace Requests { class MAD_CLIENT_EXPORT DaemonCommandRequest : public Common::Request { private: - std::string daemon; + Core::String daemon; bool reboot; protected: virtual void sendRequest(); public: - DaemonCommandRequest(Common::Application *application, const std::string &daemon0, bool reboot0) + DaemonCommandRequest(Common::Application *application, const Core::String &daemon0, bool reboot0) : Common::Request(application), daemon(daemon0), reboot(reboot0) {} }; diff --git a/src/Client/Requests/DaemonFSInfoRequest.h b/src/Client/Requests/DaemonFSInfoRequest.h index 50c0783..7d20645 100644 --- a/src/Client/Requests/DaemonFSInfoRequest.h +++ b/src/Client/Requests/DaemonFSInfoRequest.h @@ -24,7 +24,6 @@ #include <Common/Request.h> -#include <string> namespace Mad { namespace Client { @@ -32,13 +31,13 @@ namespace Requests { class MAD_CLIENT_EXPORT DaemonFSInfoRequest : public Common::Request { private: - std::string daemon; + Core::String daemon; protected: virtual void sendRequest(); public: - DaemonFSInfoRequest(Common::Application *application, const std::string &daemon0) : Common::Request(application), daemon(daemon0) {} + DaemonFSInfoRequest(Common::Application *application, const Core::String &daemon0) : Common::Request(application), daemon(daemon0) {} }; } diff --git a/src/Client/Requests/DaemonStatusRequest.h b/src/Client/Requests/DaemonStatusRequest.h index 1cdc82e..23e9e29 100644 --- a/src/Client/Requests/DaemonStatusRequest.h +++ b/src/Client/Requests/DaemonStatusRequest.h @@ -24,21 +24,19 @@ #include <Common/Request.h> -#include <string> - namespace Mad { namespace Client { namespace Requests { class MAD_CLIENT_EXPORT DaemonStatusRequest : public Common::Request { private: - std::string daemon; + Core::String daemon; protected: virtual void sendRequest(); public: - DaemonStatusRequest(Common::Application *application, const std::string &daemon0) : Common::Request(application), daemon(daemon0) {} + DaemonStatusRequest(Common::Application *application, const Core::String &daemon0) : Common::Request(application), daemon(daemon0) {} }; } diff --git a/src/Client/Requests/UserLists/UserListDownloadRequest.h b/src/Client/Requests/UserLists/UserListDownloadRequest.h index 570899f..13536f8 100644 --- a/src/Client/Requests/UserLists/UserListDownloadRequest.h +++ b/src/Client/Requests/UserLists/UserListDownloadRequest.h @@ -29,13 +29,13 @@ namespace UserLists { class UserListDownloadRequest : public Common::Request { private: - std::string name; + Core::String name; protected: virtual void sendRequest(); public: - UserListDownloadRequest(Common::Application *application, const std::string &name0) + UserListDownloadRequest(Common::Application *application, const Core::String &name0) : Common::Request(application), name(name0) {} }; diff --git a/src/Client/SystemCommands.cpp b/src/Client/SystemCommands.cpp index ff14cc5..d33441f 100644 --- a/src/Client/SystemCommands.cpp +++ b/src/Client/SystemCommands.cpp @@ -36,7 +36,7 @@ namespace Mad { namespace Client { void SystemCommands::printFSInfo(boost::shared_ptr<const Common::XmlData> &packet) { - const std::string units[] = { + const Core::String units[] = { "kB", "MB", "GB", "TB", "" }; @@ -50,36 +50,38 @@ void SystemCommands::printFSInfo(boost::shared_ptr<const Common::XmlData> &packe float total = fs->get<float>("totalSize"); float available = fs->get<float>("availableSize"); - while(used >= 1024 && !units[usedUnit+1].empty()) { + while(used >= 1024 && !units[usedUnit+1].isEmpty()) { ++usedUnit; used /= 1024; available /= 1024; } - while(total >= 1024 && !units[totalUnit+1].empty()) { + while(total >= 1024 && !units[totalUnit+1].isEmpty()) { ++totalUnit; total /= 1024; } - std::string name = fs->get<const std::string&>("name"); - std::string mountedOn = fs->get<const std::string&>("mountedOn"); + Core::String name = fs->get<const Core::String&>("name"); + Core::String mountedOn = fs->get<const Core::String&>("mountedOn"); - std::string nameString = mountedOn + " (" + name + ")"; + Core::String nameString = mountedOn + " (" + name + ")"; if(nameString.length() < 32) { - nameString.resize(32, ' '); + while(nameString.length() < 32) + nameString.append(' '); } else { nameString += "\n\t"; - nameString.resize(nameString.length() + 32, ' '); + for(int i = 0; i < 32; ++i) + nameString.append(' '); } float percent = 100*used/(used+available); if(percent > 100) percent = 100; - std::printf("\t%s%.*f%s", nameString.c_str(), (used < 10) ? 2 : 1, used, (usedUnit == totalUnit) ? "" : (" " + units[usedUnit]).c_str()); - std::printf("/%.*f %s (%.1f%%)\n", (total < 10) ? 2 : 1, total, units[totalUnit].c_str(), percent); + std::printf("\t%s%.*f%s", nameString.extract().c_str(), (used < 10) ? 2 : 1, used, (usedUnit == totalUnit) ? "" : Core::String(" " + units[usedUnit]).extract().c_str()); + std::printf("/%.*f %s (%.1f%%)\n", (total < 10) ? 2 : 1, total, units[totalUnit].extract().c_str(), percent); } } @@ -111,20 +113,20 @@ void SystemCommands::printHostStatus(boost::shared_ptr<const Common::XmlData> &p float freeMem = packet->get<unsigned long>("freeMem"); if(totalMem && freeMem) { - const std::string units[] = { + const Core::String units[] = { "kB", "MB", "GB", "TB", "" }; unsigned unit = 0; float usedMem = totalMem-freeMem; - while(totalMem >= 1024 && !units[unit+1].empty()) { + while(totalMem >= 1024 && !units[unit+1].isEmpty()) { ++unit; totalMem /= 1024; usedMem /= 1024; } - std::printf("\tMemory usage:\t%.*f/%.*f %s", (usedMem < 10) ? 2 : 1, usedMem, (totalMem < 10) ? 2 : 1, totalMem, units[unit].c_str()); + std::printf("\tMemory usage:\t%.*f/%.*f %s", (usedMem < 10) ? 2 : 1, usedMem, (totalMem < 10) ? 2 : 1, totalMem, units[unit].extract().c_str()); std::printf(" (%.1f%%)\n", usedMem*100.0f/totalMem); totalMem = packet->get<unsigned long>("totalSwap"); @@ -134,13 +136,13 @@ void SystemCommands::printHostStatus(boost::shared_ptr<const Common::XmlData> &p unit = 0; usedMem = totalMem-freeMem; - while(totalMem >= 1024 && !units[unit+1].empty()) { + while(totalMem >= 1024 && !units[unit+1].isEmpty()) { ++unit; totalMem /= 1024; usedMem /= 1024; } - std::printf("\tSwap usage:\t%.*f/%.*f %s", (usedMem < 10) ? 2 : 1, usedMem, (totalMem < 10) ? 2 : 1, totalMem, units[unit].c_str()); + std::printf("\tSwap usage:\t%.*f/%.*f %s", (usedMem < 10) ? 2 : 1, usedMem, (totalMem < 10) ? 2 : 1, totalMem, units[unit].extract().c_str()); std::printf(" (%.1f%%)\n", usedMem*100.0f/totalMem); } @@ -149,7 +151,7 @@ void SystemCommands::printHostStatus(boost::shared_ptr<const Common::XmlData> &p } -void SystemCommands::fsinfoCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void SystemCommands::fsinfoCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { boost::shared_ptr<Common::Request> request; if(args.size() == 1) @@ -180,18 +182,18 @@ void SystemCommands::fsinfoCommand(CommandParser *commandParser, const std::vect } } -void SystemCommands::rebootCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void SystemCommands::rebootCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 2) { std::cerr << args[0] << ": No host given." << std::endl; commandParser->printUsage("reboot"); return; } - std::map<std::string, Common::HostInfo> hosts = commandParser->parseHostList(std::vector<std::string>(args.begin()+1, args.end()), true); + std::map<Core::String, Common::HostInfo> hosts = commandParser->parseHostList(std::vector<Core::String>(args.begin()+1, args.end()), true); std::vector<boost::shared_ptr<Requests::DaemonCommandRequest> > requests; - for(std::map<std::string, Common::HostInfo>::iterator host = hosts.begin(); host != hosts.end(); ++host) { + for(std::map<Core::String, Common::HostInfo>::iterator host = hosts.begin(); host != hosts.end(); ++host) { boost::shared_ptr<Requests::DaemonCommandRequest> request(new Requests::DaemonCommandRequest(commandParser->application, host->first, true)); commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request); @@ -209,18 +211,18 @@ void SystemCommands::rebootCommand(CommandParser *commandParser, const std::vect } } -void SystemCommands::shutdownCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void SystemCommands::shutdownCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 2) { std::cerr << args[0] << ": No host given." << std::endl; commandParser->printUsage("shutdown"); return; } - std::map<std::string, Common::HostInfo> hosts = commandParser->parseHostList(std::vector<std::string>(args.begin()+1, args.end()), true); + std::map<Core::String, Common::HostInfo> hosts = commandParser->parseHostList(std::vector<Core::String>(args.begin()+1, args.end()), true); std::vector<boost::shared_ptr<Requests::DaemonCommandRequest> > requests; - for(std::map<std::string, Common::HostInfo>::iterator host = hosts.begin(); host != hosts.end(); ++host) { + for(std::map<Core::String, Common::HostInfo>::iterator host = hosts.begin(); host != hosts.end(); ++host) { boost::shared_ptr<Requests::DaemonCommandRequest> request(new Requests::DaemonCommandRequest(commandParser->application, host->first, false)); commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request); @@ -238,7 +240,7 @@ void SystemCommands::shutdownCommand(CommandParser *commandParser, const std::ve } } -void SystemCommands::statusCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void SystemCommands::statusCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { boost::shared_ptr<Common::Request> request; if(args.size() == 1) diff --git a/src/Client/SystemCommands.h b/src/Client/SystemCommands.h index ba8c361..fa2b63a 100644 --- a/src/Client/SystemCommands.h +++ b/src/Client/SystemCommands.h @@ -41,10 +41,10 @@ class MAD_CLIENT_EXPORT SystemCommands { static void printHostStatus(boost::shared_ptr<const Common::XmlData> &packet); public: - static void fsinfoCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void rebootCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void shutdownCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void statusCommand(CommandParser *commandParser, const std::vector<std::string> &args); + static void fsinfoCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void rebootCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void shutdownCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void statusCommand(CommandParser *commandParser, const std::vector<Core::String> &args); }; } diff --git a/src/Client/UserCommands.cpp b/src/Client/UserCommands.cpp index a1d190a..5e55534 100644 --- a/src/Client/UserCommands.cpp +++ b/src/Client/UserCommands.cpp @@ -31,7 +31,7 @@ namespace Mad { namespace Client { -std::string UserCommands::getUserName(CommandParser *commandParser, unsigned long uid, bool withId) { +Core::String UserCommands::getUserName(CommandParser *commandParser, unsigned long uid, bool withId) { std::ostringstream stream; try { @@ -47,10 +47,10 @@ std::string UserCommands::getUserName(CommandParser *commandParser, unsigned lon stream << ")"; } - return stream.str(); + return stream.str().c_str(); } -std::string UserCommands::getGroupName(CommandParser *commandParser, unsigned long gid, bool withId) { +Core::String UserCommands::getGroupName(CommandParser *commandParser, unsigned long gid, bool withId) { std::ostringstream stream; try { @@ -66,10 +66,10 @@ std::string UserCommands::getGroupName(CommandParser *commandParser, unsigned lo stream << ")"; } - return stream.str(); + return stream.str().c_str(); } -void UserCommands::listUsersCommand(CommandParser *commandParser, const std::vector<std::string> &/*args*/) { +void UserCommands::listUsersCommand(CommandParser *commandParser, const std::vector<Core::String> &/*args*/) { try { boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > users = commandParser->application->getUserManager()->getUserList(); @@ -93,7 +93,7 @@ void UserCommands::listUsersCommand(CommandParser *commandParser, const std::vec } } -void UserCommands::userInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::userInfoCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() == 1) { std::cerr << args[0] << ": No user id given." << std::endl; commandParser->printUsage("user_info"); @@ -107,11 +107,11 @@ void UserCommands::userInfoCommand(CommandParser *commandParser, const std::vect try { char *endptr; - unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10); + unsigned long uid = std::strtoul(args[1].extract().c_str(), &endptr, 10); boost::shared_ptr<const Common::UserInfo> userInfo; - if(args[1].empty() || *endptr != '\0') { + if(args[1].isEmpty() || *endptr != '\0') { userInfo = commandParser->application->getUserManager()->getUserInfoByName(args[1]); } else @@ -136,7 +136,7 @@ void UserCommands::userInfoCommand(CommandParser *commandParser, const std::vect } } -void UserCommands::listGroupsCommand(CommandParser *commandParser, const std::vector<std::string> &/*args*/) { +void UserCommands::listGroupsCommand(CommandParser *commandParser, const std::vector<Core::String> &/*args*/) { try { boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > groups = commandParser->application->getUserManager()->getGroupList(); @@ -158,31 +158,31 @@ void UserCommands::listGroupsCommand(CommandParser *commandParser, const std::ve } } -void UserCommands::groupInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::groupInfoCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() == 1) { - std::cerr << args[0] << ": No group id given." << std::endl; + std::cerr << args[0].extract() << ": No group id given." << std::endl; commandParser->printUsage("group_info"); return; } if(args.size() > 2) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("group_info"); return; } try { char *endptr; - unsigned long gid = std::strtoul(args[1].c_str(), &endptr, 10); + unsigned long gid = std::strtoul(args[1].extract().c_str(), &endptr, 10); boost::shared_ptr<const Common::GroupInfo> groupInfo; - if(args[1].empty() || *endptr != '\0') { + if(args[1].isEmpty() || *endptr != '\0') { groupInfo = commandParser->application->getUserManager()->getGroupInfoByName(args[1]); } else groupInfo = commandParser->application->getUserManager()->getGroupInfo(gid); - std::cout << " Group name: " << groupInfo->getName() << " (" << groupInfo->getGid() << ")" << std::endl << std::endl; + std::cout << " Group name: " << groupInfo->getName().extract() << " (" << groupInfo->getGid() << ")" << std::endl << std::endl; boost::shared_ptr<const std::set<unsigned long> > users = commandParser->application->getUserManager()->getGroupUserList(groupInfo->getGid()); @@ -191,7 +191,7 @@ void UserCommands::groupInfoCommand(CommandParser *commandParser, const std::vec for(std::set<unsigned long>::const_iterator user = users->begin(); user != users->end(); ++user) - std::cout << " " << getUserName(commandParser, *user, true) << std::endl; + std::cout << " " << getUserName(commandParser, *user, true).extract() << std::endl; std::cout << std::endl; } @@ -201,29 +201,29 @@ void UserCommands::groupInfoCommand(CommandParser *commandParser, const std::vec } } -void UserCommands::addUserCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::addUserCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 5) { - std::cerr << args[0] << ": Too few arguments." << std::endl; + std::cerr << args[0].extract() << ": Too few arguments." << std::endl; commandParser->printUsage("add_user"); return; } if(args.size() > 5) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("add_user"); return; } char *endptr; - unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10); - if(args[1].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse user id." << std::endl; + unsigned long uid = std::strtoul(args[1].extract().c_str(), &endptr, 10); + if(args[1].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse user id." << std::endl; commandParser->printUsage("add_user"); return; } - unsigned long gid = std::strtoul(args[2].c_str(), &endptr, 10); - if(args[2].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse group id." << std::endl; + unsigned long gid = std::strtoul(args[2].extract().c_str(), &endptr, 10); + if(args[2].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse group id." << std::endl; commandParser->printUsage("add_user"); return; } @@ -242,36 +242,36 @@ void UserCommands::addUserCommand(CommandParser *commandParser, const std::vecto } } -void UserCommands::updateUserCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::updateUserCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 6) { - std::cerr << args[0] << ": Too few arguments." << std::endl; + std::cerr << args[0].extract() << ": Too few arguments." << std::endl; commandParser->printUsage("update_user"); return; } if(args.size() > 6) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("update_user"); return; } char *endptr; - unsigned long origUid = std::strtoul(args[1].c_str(), &endptr, 10); - if(args[1].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse the old user id." << std::endl; + unsigned long origUid = std::strtoul(args[1].extract().c_str(), &endptr, 10); + if(args[1].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse the old user id." << std::endl; commandParser->printUsage("update_user"); return; } - unsigned long uid = std::strtoul(args[2].c_str(), &endptr, 10); - if(args[2].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse the new user id." << std::endl; + unsigned long uid = std::strtoul(args[2].extract().c_str(), &endptr, 10); + if(args[2].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse the new user id." << std::endl; commandParser->printUsage("update_user"); return; } - unsigned long gid = std::strtoul(args[3].c_str(), &endptr, 10); - if(args[3].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse group id." << std::endl; + unsigned long gid = std::strtoul(args[3].extract().c_str(), &endptr, 10); + if(args[3].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse group id." << std::endl; commandParser->printUsage("update_user"); return; } @@ -290,22 +290,22 @@ void UserCommands::updateUserCommand(CommandParser *commandParser, const std::ve } } -void UserCommands::deleteUserCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::deleteUserCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 2) { - std::cerr << args[0] << ": No user id given." << std::endl; + std::cerr << args[0].extract() << ": No user id given." << std::endl; commandParser->printUsage("delete_user"); return; } if(args.size() > 2) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("delete_user"); return; } char *endptr; - unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10); - if(args[1].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse user id." << std::endl; + unsigned long uid = std::strtoul(args[1].extract().c_str(), &endptr, 10); + if(args[1].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse user id." << std::endl; commandParser->printUsage("delete_user"); return; } @@ -320,22 +320,22 @@ void UserCommands::deleteUserCommand(CommandParser *commandParser, const std::ve } } -void UserCommands::addGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::addGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 3) { - std::cerr << args[0] << ": Too few arguments." << std::endl; + std::cerr << args[0].extract() << ": Too few arguments." << std::endl; commandParser->printUsage("add_group"); return; } if(args.size() > 3) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("add_group"); return; } char *endptr; - unsigned long gid = std::strtoul(args[1].c_str(), &endptr, 10); - if(args[2].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse group id." << std::endl; + unsigned long gid = std::strtoul(args[1].extract().c_str(), &endptr, 10); + if(args[2].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse group id." << std::endl; commandParser->printUsage("add_group"); return; } @@ -350,29 +350,29 @@ void UserCommands::addGroupCommand(CommandParser *commandParser, const std::vect } } -void UserCommands::updateGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::updateGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 4) { - std::cerr << args[0] << ": Too few arguments." << std::endl; + std::cerr << args[0].extract() << ": Too few arguments." << std::endl; commandParser->printUsage("update_group"); return; } if(args.size() > 4) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("update_group"); return; } char *endptr; - unsigned long origGid = std::strtoul(args[1].c_str(), &endptr, 10); - if(args[1].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse the old group id." << std::endl; + unsigned long origGid = std::strtoul(args[1].extract().c_str(), &endptr, 10); + if(args[1].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse the old group id." << std::endl; commandParser->printUsage("update_group"); return; } - unsigned long gid = std::strtoul(args[2].c_str(), &endptr, 10); - if(args[2].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse the new group id." << std::endl; + unsigned long gid = std::strtoul(args[2].extract().c_str(), &endptr, 10); + if(args[2].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse the new group id." << std::endl; commandParser->printUsage("update_group"); return; } @@ -387,22 +387,22 @@ void UserCommands::updateGroupCommand(CommandParser *commandParser, const std::v } } -void UserCommands::deleteGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::deleteGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 2) { - std::cerr << args[0] << ": No group id given." << std::endl; + std::cerr << args[0].extract() << ": No group id given." << std::endl; commandParser->printUsage("delete_group"); return; } if(args.size() > 2) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("delete_group"); return; } char *endptr; - unsigned long gid = std::strtoul(args[1].c_str(), &endptr, 10); - if(args[1].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse group id." << std::endl; + unsigned long gid = std::strtoul(args[1].extract().c_str(), &endptr, 10); + if(args[1].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse group id." << std::endl; commandParser->printUsage("delete_group"); return; } @@ -417,29 +417,29 @@ void UserCommands::deleteGroupCommand(CommandParser *commandParser, const std::v } } -void UserCommands::addUserToGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::addUserToGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 3) { - std::cerr << args[0] << ": Too few arguments." << std::endl; + std::cerr << args[0].extract() << ": Too few arguments." << std::endl; commandParser->printUsage("add_user_to_group"); return; } if(args.size() > 3) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("add_user_to_group"); return; } char *endptr; - unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10); - if(args[1].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse user id." << std::endl; + unsigned long uid = std::strtoul(args[1].extract().c_str(), &endptr, 10); + if(args[1].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse user id." << std::endl; commandParser->printUsage("add_user_to_group"); return; } - unsigned long gid = std::strtoul(args[2].c_str(), &endptr, 10); - if(args[2].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse group id." << std::endl; + unsigned long gid = std::strtoul(args[2].extract().c_str(), &endptr, 10); + if(args[2].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse group id." << std::endl; commandParser->printUsage("add_user_to_group"); return; } @@ -454,29 +454,29 @@ void UserCommands::addUserToGroupCommand(CommandParser *commandParser, const std } } -void UserCommands::deleteUserFromGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::deleteUserFromGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 3) { - std::cerr << args[0] << ": Too few arguments." << std::endl; + std::cerr << args[0].extract() << ": Too few arguments." << std::endl; commandParser->printUsage("delete_user_from_group"); return; } if(args.size() > 3) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("delete_user_from_group"); return; } char *endptr; - unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10); - if(args[1].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse user id." << std::endl; + unsigned long uid = std::strtoul(args[1].extract().c_str(), &endptr, 10); + if(args[1].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse user id." << std::endl; commandParser->printUsage("delete_user_from_group"); return; } - unsigned long gid = std::strtoul(args[2].c_str(), &endptr, 10); - if(args[2].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse group id." << std::endl; + unsigned long gid = std::strtoul(args[2].extract().c_str(), &endptr, 10); + if(args[2].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse group id." << std::endl; commandParser->printUsage("delete_user_from_group"); return; } @@ -491,28 +491,28 @@ void UserCommands::deleteUserFromGroupCommand(CommandParser *commandParser, cons } } -void UserCommands::setPasswordCommand(CommandParser *commandParser, const std::vector<std::string> &args) { +void UserCommands::setPasswordCommand(CommandParser *commandParser, const std::vector<Core::String> &args) { if(args.size() < 2) { - std::cerr << args[0] << ": Too few arguments." << std::endl; + std::cerr << args[0].extract() << ": Too few arguments." << std::endl; commandParser->printUsage("set_password"); return; } if(args.size() > 2) { - std::cerr << args[0] << ": Too many arguments." << std::endl; + std::cerr << args[0].extract() << ": Too many arguments." << std::endl; commandParser->printUsage("set_password"); return; } char *endptr; - unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10); - if(args[1].empty() || *endptr != '\0') { - std::cerr << args[0] << ": Unable to parse user id." << std::endl; + unsigned long uid = std::strtoul(args[1].extract().c_str(), &endptr, 10); + if(args[1].isEmpty() || *endptr != '\0') { + std::cerr << args[0].extract() << ": Unable to parse user id." << std::endl; commandParser->printUsage("set_password"); return; } - std::string password = PasswordReader::readPassword("Password: "); - std::string password2 = PasswordReader::readPassword("Verify password: "); + Core::String password = PasswordReader::readPassword("Password: "); + Core::String password2 = PasswordReader::readPassword("Verify password: "); if(password != password2) { std::cerr << "Passwords do not match." << std::endl; diff --git a/src/Client/UserCommands.h b/src/Client/UserCommands.h index 640b5b4..34eb84b 100644 --- a/src/Client/UserCommands.h +++ b/src/Client/UserCommands.h @@ -22,7 +22,7 @@ #include "export.h" -#include <string> +#include <Core/String.h> #include <vector> namespace Mad { @@ -34,28 +34,28 @@ class MAD_CLIENT_EXPORT UserCommands { private: UserCommands(); - static std::string getUserName(CommandParser *commandParser, unsigned long uid, bool withId); - static std::string getGroupName(CommandParser *commandParser, unsigned long gid, bool withId); + static Core::String getUserName(CommandParser *commandParser, unsigned long uid, bool withId); + static Core::String getGroupName(CommandParser *commandParser, unsigned long gid, bool withId); public: - static void listUsersCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void userInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args); + static void listUsersCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void userInfoCommand(CommandParser *commandParser, const std::vector<Core::String> &args); - static void listGroupsCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void groupInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args); + static void listGroupsCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void groupInfoCommand(CommandParser *commandParser, const std::vector<Core::String> &args); - static void addUserCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void updateUserCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void deleteUserCommand(CommandParser *commandParser, const std::vector<std::string> &args); + static void addUserCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void updateUserCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void deleteUserCommand(CommandParser *commandParser, const std::vector<Core::String> &args); - static void addGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void updateGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void deleteGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args); + static void addGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void updateGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void deleteGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args); - static void addUserToGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void deleteUserFromGroupCommand(CommandParser *commandParser, const std::vector<std::string> &args); + static void addUserToGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void deleteUserFromGroupCommand(CommandParser *commandParser, const std::vector<Core::String> &args); - static void setPasswordCommand(CommandParser *commandParser, const std::vector<std::string> &args); + static void setPasswordCommand(CommandParser *commandParser, const std::vector<Core::String> &args); }; } 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"; diff --git a/src/Client/UserListCommands.h b/src/Client/UserListCommands.h index 8c77e7f..ab20974 100644 --- a/src/Client/UserListCommands.h +++ b/src/Client/UserListCommands.h @@ -44,21 +44,21 @@ class MAD_CLIENT_EXPORT UserListCommands { UserListCommands(); - static const Command* findCommand(const std::string& command); - static void printUsage(const std::string& command); + static const Command* findCommand(const Core::String& command); + static void printUsage(const Core::String& command); - static void helpCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void listCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void showListCommand(CommandParser *commandParser, const std::vector<std::string> &args); - static void importCommand(CommandParser *commandParser, const std::vector<std::string> &args); + static void helpCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void listCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void showListCommand(CommandParser *commandParser, const std::vector<Core::String> &args); + static void importCommand(CommandParser *commandParser, const std::vector<Core::String> &args); static void printUserList(const Common::UserLists::UserList &list); static void printSheet(const XLSSheet &sheet, unsigned rowCount = 0); - static void printPadded(const std::string &str, unsigned length); - static void printDelimiter(unsigned length); + static void printPadded(const Core::String &str, boost::int32_t length); + static void printDelimiter(boost::int32_t length); public: - static void userListCommand(CommandParser *commandParser, const std::vector<std::string> &args); + static void userListCommand(CommandParser *commandParser, const std::vector<Core::String> &args); }; } diff --git a/src/Client/XLSReader.cpp b/src/Client/XLSReader.cpp index 9bd9dda..27ff2f5 100644 --- a/src/Client/XLSReader.cpp +++ b/src/Client/XLSReader.cpp @@ -27,12 +27,12 @@ namespace Mad { namespace Client { -xmlNodePtr XLSReader::findNode(xmlNodePtr parent, const std::string &name) { +xmlNodePtr XLSReader::findNode(xmlNodePtr parent, const Core::String &name) { if(!parent) return 0; for(xmlNodePtr entry = parent->children; entry != 0; entry = entry->next) { - if(entry->type == XML_ELEMENT_NODE && !xmlStrcmp(entry->name, (xmlChar*)name.c_str())) { + if(entry->type == XML_ELEMENT_NODE && !xmlStrcmp(entry->name, (xmlChar*)name.extractUTF8().c_str())) { return entry; } } diff --git a/src/Client/XLSReader.h b/src/Client/XLSReader.h index 8c7b11a..b5364d9 100644 --- a/src/Client/XLSReader.h +++ b/src/Client/XLSReader.h @@ -41,7 +41,7 @@ class MAD_CLIENT_EXPORT XLSReader : private boost::noncopyable { boost::shared_ptr<xmlDoc> doc; std::list<boost::shared_ptr<XLSSheet> > sheets; - static xmlNodePtr findNode(xmlNodePtr parent, const std::string &name); + static xmlNodePtr findNode(xmlNodePtr parent, const Core::String &name); public: XLSReader(const std::string &filename) throw (Core::Exception); diff --git a/src/Client/XLSSheet.cpp b/src/Client/XLSSheet.cpp index 915234f..9c4b5a9 100644 --- a/src/Client/XLSSheet.cpp +++ b/src/Client/XLSSheet.cpp @@ -26,12 +26,12 @@ namespace Mad { namespace Client { -std::string XLSSheet::getSheetLevelField(const std::string &name) const { +Core::String XLSSheet::getSheetLevelField(const Core::String &name) const { xmlNodePtr entry = XLSReader::findNode(node, name); if(entry) - return std::string((char*)xmlNodeGetContent(entry)); + return Core::String::fromUTF8((char*)xmlNodeGetContent(entry)); else - return std::string(); + return Core::String(); } void XLSSheet::readRows() { @@ -58,7 +58,7 @@ void XLSSheet::readRows() { if(col >= colCount) continue; - colNames[col] = (char*)xmlNodeGetContent(cellEntry); + colNames[col] = Core::String::fromUTF8((char*)xmlNodeGetContent(cellEntry)); } // Skip the first row @@ -71,7 +71,7 @@ void XLSSheet::readRows() { if(rowEntry->type != XML_ELEMENT_NODE || xmlStrcmp(rowEntry->name, (xmlChar*)"row")) continue; - boost::shared_ptr<std::vector<std::string> > rowVector(new std::vector<std::string>(colCount)); + boost::shared_ptr<std::vector<Core::String> > rowVector(new std::vector<Core::String>(colCount)); rows.push_back(rowVector); for(xmlNodePtr cellEntry = rowEntry->children; cellEntry != 0; cellEntry = cellEntry->next) { @@ -86,20 +86,20 @@ void XLSSheet::readRows() { if(col >= colCount) continue; - (*rowVector)[col] = (char*)xmlNodeGetContent(cellEntry); + (*rowVector)[col] = Core::String::fromUTF8((char*)xmlNodeGetContent(cellEntry)); } } } XLSSheet::XLSSheet(boost::shared_ptr<xmlDoc> doc0, xmlNodePtr node0) : doc(doc0), node(node0), firstRowColNames(false) { title = getSheetLevelField("pagetitle"); - colCount = std::strtoul(getSheetLevelField("lastcol").c_str(), 0, 10)+1-std::strtoul(getSheetLevelField("firstcol").c_str(), 0, 10); + colCount = std::strtoul(getSheetLevelField("lastcol").extract().c_str(), 0, 10)+1-std::strtoul(getSheetLevelField("firstcol").extract().c_str(), 0, 10); for(unsigned col = 0; col < colCount; ++col) { std::ostringstream stream; stream << col; - colNames.push_back(stream.str()); + colNames.push_back(stream.str().c_str()); } readRows(); diff --git a/src/Client/XLSSheet.h b/src/Client/XLSSheet.h index 3038fdc..0960fc0 100644 --- a/src/Client/XLSSheet.h +++ b/src/Client/XLSSheet.h @@ -22,9 +22,9 @@ #include "export.h" -#include <string> -#include <vector> +#include <Core/String.h> +#include <vector> #include <boost/noncopyable.hpp> #include <boost/shared_array.hpp> #include <boost/shared_ptr.hpp> @@ -37,7 +37,7 @@ class XLSReader; class MAD_CLIENT_EXPORT XLSSheet : private boost::noncopyable { public: - typedef boost::shared_ptr<const std::vector<std::string> > RowType; + typedef boost::shared_ptr<const std::vector<Core::String> > RowType; private: friend class XLSReader; @@ -45,17 +45,17 @@ class MAD_CLIENT_EXPORT XLSSheet : private boost::noncopyable { boost::shared_ptr<xmlDoc> doc; xmlNodePtr node; - std::string title; + Core::String title; size_t colCount; std::vector<RowType> rows; - std::vector<std::string> colNames; + std::vector<Core::String> colNames; bool firstRowColNames; XLSSheet(boost::shared_ptr<xmlDoc> doc0, xmlNodePtr node0); - std::string getSheetLevelField(const std::string &name) const; + Core::String getSheetLevelField(const Core::String &name) const; void readRows(); @@ -68,7 +68,7 @@ class MAD_CLIENT_EXPORT XLSSheet : private boost::noncopyable { readRows(); } - const std::string& getTitle() const { + const Core::String& getTitle() const { return title; } @@ -76,7 +76,7 @@ class MAD_CLIENT_EXPORT XLSSheet : private boost::noncopyable { return colCount; } - const std::string& getColumnName(unsigned col) const { + const Core::String& getColumnName(unsigned col) const { return colNames[col]; } |