diff options
106 files changed, 1016 insertions, 977 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]; } diff --git a/src/Common/AuthBackend.h b/src/Common/AuthBackend.h index 3fe3840..da40902 100644 --- a/src/Common/AuthBackend.h +++ b/src/Common/AuthBackend.h @@ -38,11 +38,11 @@ class AuthBackend { protected: friend class AuthManager; - virtual const std::string& getMethodName() const = 0; - virtual std::vector<std::string> getSubMethods(boost::shared_ptr<AuthProvider> provider) const = 0; + virtual const Core::String& getMethodName() const = 0; + virtual std::vector<Core::String> getSubMethods(boost::shared_ptr<AuthProvider> provider) const = 0; - virtual boost::shared_ptr<AuthContext> authenticate(boost::shared_ptr<AuthProvider> provider, const std::string &subMethod, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, + virtual boost::shared_ptr<AuthContext> authenticate(boost::shared_ptr<AuthProvider> provider, const Core::String &subMethod, + const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, boost::shared_ptr<AuthContext> context) throw(Core::Exception) = 0; public: diff --git a/src/Common/AuthManager.cpp b/src/Common/AuthManager.cpp index 38ac9e3..5e97fb3 100644 --- a/src/Common/AuthManager.cpp +++ b/src/Common/AuthManager.cpp @@ -48,7 +48,7 @@ void AuthManager::registerBackend(boost::shared_ptr<AuthBackend> backend) { void AuthManager::unregisterBackend(boost::shared_ptr<AuthBackend> backend) { boost::lock_guard<boost::shared_mutex> lock(mutex); - std::map<std::string, boost::shared_ptr<AuthBackend> >::iterator backendIt = backends.find(backend->getMethodName()); + std::map<Core::String, boost::shared_ptr<AuthBackend> >::iterator backendIt = backends.find(backend->getMethodName()); if(backendIt == backends.end() || backendIt->second != backend) return; @@ -56,16 +56,16 @@ void AuthManager::unregisterBackend(boost::shared_ptr<AuthBackend> backend) { backends.erase(backendIt); } -std::set<std::string> AuthManager::getMethods() { +const std::set<Core::String>& AuthManager::getMethods() { boost::shared_lock<boost::shared_mutex> lock(mutex); return methods; } -std::vector<std::string> AuthManager::getSubMethods(const std::string &method) throw(Core::Exception) { +std::vector<Core::String> AuthManager::getSubMethods(const Core::String &method) throw(Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); - std::map<std::string, boost::shared_ptr<AuthBackend> >::iterator backend = backends.find(method); + std::map<Core::String, boost::shared_ptr<AuthBackend> >::iterator backend = backends.find(method); if(backend == backends.end()) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); @@ -75,9 +75,10 @@ std::vector<std::string> AuthManager::getSubMethods(const std::string &method) t return backend->second->getSubMethods(provider); } -boost::shared_ptr<AuthContext> AuthManager::authenticate(const std::string &method, const std::string &subMethod, const std::string &user, - const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, boost::shared_ptr<AuthContext> context) throw(Core::Exception) { - std::map<std::string, boost::shared_ptr<AuthBackend> >::iterator backend; +boost::shared_ptr<AuthContext> AuthManager::authenticate(const Core::String &method, const Core::String &subMethod, + const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, + boost::shared_ptr<AuthContext> context) throw(Core::Exception) { + std::map<Core::String, boost::shared_ptr<AuthBackend> >::iterator backend; { boost::lock_guard<boost::shared_mutex> lock(mutex); diff --git a/src/Common/AuthManager.h b/src/Common/AuthManager.h index e45762a..0c249ad 100644 --- a/src/Common/AuthManager.h +++ b/src/Common/AuthManager.h @@ -48,8 +48,8 @@ class MAD_COMMON_EXPORT AuthManager : private boost::noncopyable { boost::shared_ptr<AuthProvider> provider; - std::set<std::string> methods; - std::map<std::string, boost::shared_ptr<AuthBackend> > backends; + std::set<Core::String> methods; + std::map<Core::String, boost::shared_ptr<AuthBackend> > backends; boost::shared_mutex mutex; @@ -62,11 +62,11 @@ class MAD_COMMON_EXPORT AuthManager : private boost::noncopyable { void registerBackend(boost::shared_ptr<AuthBackend> backend); void unregisterBackend(boost::shared_ptr<AuthBackend> backend); - std::set<std::string> getMethods(); - std::vector<std::string> getSubMethods(const std::string &method) throw(Core::Exception); + const std::set<Core::String>& getMethods(); + std::vector<Core::String> getSubMethods(const Core::String &method) throw(Core::Exception); - boost::shared_ptr<AuthContext> authenticate(const std::string &method, const std::string &subMethod, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, + boost::shared_ptr<AuthContext> authenticate(const Core::String &method, const Core::String &subMethod, + const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, boost::shared_ptr<AuthContext> context = boost::shared_ptr<AuthContext>()) throw(Core::Exception); }; diff --git a/src/Common/AuthProvider.h b/src/Common/AuthProvider.h index aaf8f10..5318e41 100644 --- a/src/Common/AuthProvider.h +++ b/src/Common/AuthProvider.h @@ -31,15 +31,15 @@ namespace Common { class AuthProvider { public: - virtual const std::vector<std::string>& getHashes() const = 0; + virtual const std::vector<Core::String>& getHashes() const = 0; - virtual bool checkPassword(const std::string &user, const std::vector<boost::uint8_t> &data, const std::string &hash) throw(Core::Exception) { + virtual bool checkPassword(const Core::String &user, const std::vector<boost::uint8_t> &data, const Core::String &hash) throw(Core::Exception) { std::vector<boost::uint8_t> password = getPassword(user, hash); return (!password.empty() && data.size() == password.size() && std::equal(data.begin(), data.end(), password.begin())); } - virtual std::vector<boost::uint8_t> getPassword(const std::string& /*user*/, const std::string& /*hash*/) throw(Core::Exception) { + virtual std::vector<boost::uint8_t> getPassword(const Core::String& /*user*/, const Core::String& /*hash*/) throw(Core::Exception) { throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); } diff --git a/src/Common/Backends/NetworkUserBackend.cpp b/src/Common/Backends/NetworkUserBackend.cpp index 1b528ab..87d9b4f 100644 --- a/src/Common/Backends/NetworkUserBackend.cpp +++ b/src/Common/Backends/NetworkUserBackend.cpp @@ -26,14 +26,14 @@ namespace Mad { namespace Common { namespace Backends { -const std::string NetworkUserBackend::name("NetworkUserBackend"); +const Core::String NetworkUserBackend::name("NetworkUserBackend"); void NetworkUserBackend::SimpleUserRequest::sendRequest() { XmlData packet; packet.setType(type); if(!timestamp.is_not_a_date_time()) - packet.set("timestamp", boost::posix_time::to_iso_string(timestamp)); + packet.set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); sendPacket(packet); } @@ -44,7 +44,7 @@ void NetworkUserBackend::IdUserRequest::sendRequest() { packet.set(idType, id); if(!timestamp.is_not_a_date_time()) - packet.set("timestamp", boost::posix_time::to_iso_string(timestamp)); + packet.set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); sendPacket(packet); } @@ -55,7 +55,7 @@ void NetworkUserBackend::NameUserRequest::sendRequest() { packet.set("name", name); if(!timestamp.is_not_a_date_time()) - packet.set("timestamp", boost::posix_time::to_iso_string(timestamp)); + packet.set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); sendPacket(packet); } @@ -138,7 +138,7 @@ boost::shared_ptr<const std::map<unsigned long, UserInfo> > NetworkUserBackend:: if(timestamp) { try { - *timestamp = boost::posix_time::from_iso_string(result.first->get<const std::string&>("timestamp")); + *timestamp = boost::posix_time::from_iso_string(result.first->get<const Core::String&>("timestamp").extract()); } catch(...) {} } @@ -148,9 +148,9 @@ boost::shared_ptr<const std::map<unsigned long, UserInfo> > NetworkUserBackend:: boost::shared_ptr<std::map<unsigned long, UserInfo> > userList(new std::map<unsigned long, UserInfo>); for(XmlData::List::const_iterator user = users->begin(); user != users->end(); ++user) { - UserInfo userInfo(user->get<unsigned long>("uid"), user->get<const std::string&>("username")); + UserInfo userInfo(user->get<unsigned long>("uid"), user->get<const Core::String&>("username")); userInfo.setGid(user->get<unsigned long>("gid")); - userInfo.setFullName(user->get<const std::string&>("fullName")); + userInfo.setFullName(user->get<const Core::String&>("fullName")); userList->insert(std::make_pair(userInfo.getUid(), userInfo)); } @@ -174,7 +174,7 @@ boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfo(unsigned long if(timestamp) { try { - *timestamp = boost::posix_time::from_iso_string(result.first->get<const std::string&>("timestamp")); + *timestamp = boost::posix_time::from_iso_string(result.first->get<const Core::String&>("timestamp").extract()); } catch(...) {} } @@ -182,10 +182,10 @@ boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfo(unsigned long unsigned long uid2 = result.first->get<unsigned long>("uid"); if(uid2) { - boost::shared_ptr<UserInfo> userInfo(new UserInfo(uid2, result.first->get<const std::string&>("username"))); + boost::shared_ptr<UserInfo> userInfo(new UserInfo(uid2, result.first->get<const Core::String&>("username"))); userInfo->setGid(result.first->get<unsigned long>("gid")); - userInfo->setFullName(result.first->get<const std::string&>("fullName")); + userInfo->setFullName(result.first->get<const Core::String&>("fullName")); return userInfo; } @@ -193,7 +193,7 @@ boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfo(unsigned long return boost::shared_ptr<const UserInfo>(); } -boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { +boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { application->getThreadManager()->detach(); boost::shared_ptr<NameUserRequest> request(new NameUserRequest(application, "GetUserInfo", name, timestamp)); @@ -206,7 +206,7 @@ boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfoByName(const st if(timestamp) { try { - *timestamp = boost::posix_time::from_iso_string(result.first->get<const std::string&>("timestamp")); + *timestamp = boost::posix_time::from_iso_string(result.first->get<const Core::String&>("timestamp").extract()); } catch(...) {} } @@ -214,10 +214,10 @@ boost::shared_ptr<const UserInfo> NetworkUserBackend::getUserInfoByName(const st unsigned long uid = result.first->get<unsigned long>("uid"); if(uid) { - boost::shared_ptr<UserInfo> userInfo(new UserInfo(uid, result.first->get<const std::string&>("username"))); + boost::shared_ptr<UserInfo> userInfo(new UserInfo(uid, result.first->get<const Core::String&>("username"))); userInfo->setGid(result.first->get<unsigned long>("gid")); - userInfo->setFullName(result.first->get<const std::string&>("fullName")); + userInfo->setFullName(result.first->get<const Core::String&>("fullName")); return userInfo; } @@ -238,7 +238,7 @@ boost::shared_ptr<const std::set<unsigned long> > NetworkUserBackend::getUserGro if(timestamp) { try { - *timestamp = boost::posix_time::from_iso_string(result.first->get<const std::string&>("timestamp")); + *timestamp = boost::posix_time::from_iso_string(result.first->get<const Core::String&>("timestamp").extract()); } catch(...) {} } @@ -270,7 +270,7 @@ boost::shared_ptr<const std::map<unsigned long, GroupInfo> > NetworkUserBackend: if(timestamp) { try { - *timestamp = boost::posix_time::from_iso_string(result.first->get<const std::string&>("timestamp")); + *timestamp = boost::posix_time::from_iso_string(result.first->get<const Core::String&>("timestamp").extract()); } catch(...) {} } @@ -280,7 +280,7 @@ boost::shared_ptr<const std::map<unsigned long, GroupInfo> > NetworkUserBackend: boost::shared_ptr<std::map<unsigned long, GroupInfo> > groupList(new std::map<unsigned long, GroupInfo>); for(XmlData::List::const_iterator group = groups->begin(); group != groups->end(); ++group) { - GroupInfo groupInfo(group->get<unsigned long>("gid"), group->get<const std::string&>("name")); + GroupInfo groupInfo(group->get<unsigned long>("gid"), group->get<const Core::String&>("name")); groupList->insert(std::make_pair(groupInfo.getGid(), groupInfo)); } @@ -303,7 +303,7 @@ boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfo(unsigned lon if(timestamp) { try { - *timestamp = boost::posix_time::from_iso_string(result.first->get<const std::string&>("timestamp")); + *timestamp = boost::posix_time::from_iso_string(result.first->get<const Core::String&>("timestamp").extract()); } catch(...) {} } @@ -311,12 +311,12 @@ boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfo(unsigned lon unsigned long gid2 = result.first->get<unsigned long>("gid"); if(gid2) - return boost::shared_ptr<GroupInfo>(new GroupInfo(gid2, result.first->get<const std::string&>("name"))); + return boost::shared_ptr<GroupInfo>(new GroupInfo(gid2, result.first->get<const Core::String&>("name"))); return boost::shared_ptr<const GroupInfo>(); } -boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { +boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { application->getThreadManager()->detach(); boost::shared_ptr<NameUserRequest> request(new NameUserRequest(application, "GetGroupInfo", name, timestamp)); @@ -329,7 +329,7 @@ boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfoByName(const if(timestamp) { try { - *timestamp = boost::posix_time::from_iso_string(result.first->get<const std::string&>("timestamp")); + *timestamp = boost::posix_time::from_iso_string(result.first->get<const Core::String&>("timestamp").extract()); } catch(...) {} } @@ -337,7 +337,7 @@ boost::shared_ptr<const GroupInfo> NetworkUserBackend::getGroupInfoByName(const unsigned long gid = result.first->get<unsigned long>("gid"); if(gid) - return boost::shared_ptr<GroupInfo>(new GroupInfo(gid, result.first->get<const std::string&>("name"))); + return boost::shared_ptr<GroupInfo>(new GroupInfo(gid, result.first->get<const Core::String&>("name"))); return boost::shared_ptr<const GroupInfo>(); } @@ -355,7 +355,7 @@ boost::shared_ptr<const std::set<unsigned long> > NetworkUserBackend::getGroupUs if(timestamp) { try { - *timestamp = boost::posix_time::from_iso_string(result.first->get<const std::string&>("timestamp")); + *timestamp = boost::posix_time::from_iso_string(result.first->get<const Core::String&>("timestamp").extract()); } catch(...) {} } @@ -387,7 +387,7 @@ boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > NetworkUse if(timestamp) { try { - *timestamp = boost::posix_time::from_iso_string(result.first->get<const std::string&>("timestamp")); + *timestamp = boost::posix_time::from_iso_string(result.first->get<const Core::String&>("timestamp").extract()); } catch(...) {} } @@ -529,7 +529,7 @@ void NetworkUserBackend::deleteUserFromGroup(unsigned long uid, unsigned long gi } -void NetworkUserBackend::setPassword(unsigned long uid, const std::string &password) throw(Core::Exception) { +void NetworkUserBackend::setPassword(unsigned long uid, const Core::String &password) throw(Core::Exception) { application->getThreadManager()->detach(); boost::shared_ptr<PasswordRequest> request(new PasswordRequest(application, uid, password)); diff --git a/src/Common/Backends/NetworkUserBackend.h b/src/Common/Backends/NetworkUserBackend.h index 6ae9747..9b52443 100644 --- a/src/Common/Backends/NetworkUserBackend.h +++ b/src/Common/Backends/NetworkUserBackend.h @@ -33,21 +33,21 @@ class MAD_COMMON_EXPORT NetworkUserBackend : public UserDBBackend { private: class MAD_COMMON_EXPORT SimpleUserRequest : public Request { private: - std::string type; + Core::String type; boost::posix_time::ptime timestamp; protected: virtual void sendRequest(); public: - SimpleUserRequest(Application *application, const std::string &type0, boost::posix_time::ptime *timestamp0) + SimpleUserRequest(Application *application, const Core::String &type0, boost::posix_time::ptime *timestamp0) : Request(application), type(type0), timestamp(timestamp0 ? *timestamp0 : boost::posix_time::not_a_date_time) {} }; class MAD_COMMON_EXPORT IdUserRequest : public Request { private: - std::string type; - std::string idType; + Core::String type; + Core::String idType; unsigned long id; boost::posix_time::ptime timestamp; @@ -55,21 +55,21 @@ class MAD_COMMON_EXPORT NetworkUserBackend : public UserDBBackend { virtual void sendRequest(); public: - IdUserRequest(Application *application, const std::string &type0, const std::string &idType0, unsigned long id0, boost::posix_time::ptime *timestamp0 = 0) + IdUserRequest(Application *application, const Core::String &type0, const Core::String &idType0, unsigned long id0, boost::posix_time::ptime *timestamp0 = 0) : Request(application), type(type0), idType(idType0), id(id0), timestamp(timestamp0 ? *timestamp0 : boost::posix_time::not_a_date_time) {} }; class MAD_COMMON_EXPORT NameUserRequest : public Request { private: - std::string type; - std::string name; + Core::String type; + Core::String name; boost::posix_time::ptime timestamp; protected: virtual void sendRequest(); public: - NameUserRequest(Application *application, const std::string &type0, const std::string &name0, boost::posix_time::ptime *timestamp0) + NameUserRequest(Application *application, const Core::String &type0, const Core::String &name0, boost::posix_time::ptime *timestamp0) : Request(application), type(type0), name(name0), timestamp(timestamp0 ? *timestamp0 : boost::posix_time::not_a_date_time) {} }; @@ -127,7 +127,7 @@ class MAD_COMMON_EXPORT NetworkUserBackend : public UserDBBackend { class MAD_COMMON_EXPORT UserGroupRequest : public Request { private: - std::string type; + Core::String type; unsigned long uid; unsigned long gid; @@ -135,24 +135,24 @@ class MAD_COMMON_EXPORT NetworkUserBackend : public UserDBBackend { virtual void sendRequest(); public: - UserGroupRequest(Application *application, const std::string &type0, unsigned long uid0, unsigned long gid0) + UserGroupRequest(Application *application, const Core::String &type0, unsigned long uid0, unsigned long gid0) : Request(application), type(type0), uid(uid0), gid(gid0) {} }; class MAD_COMMON_EXPORT PasswordRequest : public Request { private: unsigned long uid; - std::string password; + Core::String password; protected: virtual void sendRequest(); public: - PasswordRequest(Application *application, unsigned long uid0, const std::string &password0) + PasswordRequest(Application *application, unsigned long uid0, const Core::String &password0) : Request(application), uid(uid0), password(password0) {} }; - static const std::string name; + static const Core::String name; Application *application; Connection *connection; @@ -160,12 +160,12 @@ class MAD_COMMON_EXPORT NetworkUserBackend : public UserDBBackend { protected: virtual boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const Common::UserInfo> getUserInfo(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception); - virtual boost::shared_ptr<const Common::UserInfo> getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); + virtual boost::shared_ptr<const Common::UserInfo> getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::set<unsigned long> > getUserGroupList(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > getGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfo(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception); - virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); + virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::set<unsigned long> > getGroupUserList(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception); @@ -183,12 +183,12 @@ class MAD_COMMON_EXPORT NetworkUserBackend : public UserDBBackend { virtual void addUserToGroup(unsigned long uid, unsigned long gid) throw(Core::Exception); virtual void deleteUserFromGroup(unsigned long uid, unsigned long gid) throw(Core::Exception); - virtual void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception); + virtual void setPassword(unsigned long uid, const Core::String &password) throw(Core::Exception); public: NetworkUserBackend(Application *application0, Connection *connection0) : application(application0), connection(connection0) {} - virtual const std::string& getName() { + virtual const Core::String& getName() { return name; } }; diff --git a/src/Common/GroupInfo.h b/src/Common/GroupInfo.h index c1a2274..cae12f0 100644 --- a/src/Common/GroupInfo.h +++ b/src/Common/GroupInfo.h @@ -22,7 +22,7 @@ #include "export.h" -#include <string> +#include <Core/String.h> namespace Mad { namespace Common { @@ -30,16 +30,16 @@ namespace Common { class GroupInfo { private: unsigned long gid; - std::string name; + Core::String name; public: - GroupInfo(unsigned long gid0 = 0, const std::string& name0 = std::string()) : gid(gid0), name(name0) {} + GroupInfo(unsigned long gid0 = 0, const Core::String& name0 = Core::String()) : gid(gid0), name(name0) {} void setGid(unsigned long newGid) {gid = newGid;} unsigned long getGid() const {return gid;} - void setName(const std::string& newName) {name = newName;} - const std::string& getName() const {return name;} + void setName(const Core::String& newName) {name = newName;} + const Core::String& getName() const {return name;} }; } diff --git a/src/Common/Hash.h b/src/Common/Hash.h index db581b7..f92779e 100644 --- a/src/Common/Hash.h +++ b/src/Common/Hash.h @@ -40,20 +40,23 @@ class MAD_COMMON_EXPORT Hash { class MAD_COMMON_EXPORT Hashes { private: - std::map<std::string, unsigned int> map; - std::vector<std::string> list; + std::map<Core::String, unsigned int> map; + std::vector<Core::String> list; - void addHash(const std::string &name, unsigned id) { - map.insert(std::make_pair(boost::algorithm::to_lower_copy(name), id)); + void addHash(const Core::String &name, unsigned id) { + Core::String lowerName = name; + lowerName.toLower(); + + map.insert(std::make_pair(lowerName, id)); list.push_back(name); } public: - const std::vector<std::string>& getList() const { + const std::vector<Core::String>& getList() const { return list; } - const std::map<std::string, unsigned int>& getMap() const { + const std::map<Core::String, unsigned int>& getMap() const { return map; } @@ -63,30 +66,38 @@ class MAD_COMMON_EXPORT Hash { static const Hashes hashes; public: - static const std::vector<std::string>& getHashList() { + static const std::vector<Core::String>& getHashList() { return hashes.getList(); } - static bool isHashSupported(const std::string &method) { - return (hashes.getMap().find(boost::algorithm::to_lower_copy(method)) != hashes.getMap().end()); + static bool isHashSupported(const Core::String &method) { + Core::String lowerMethod = method; + lowerMethod.toLower(); + + return (hashes.getMap().find(lowerMethod) != hashes.getMap().end()); } static std::vector<boost::uint8_t> hash(const std::vector<boost::uint8_t> &in, unsigned int method) throw (Core::Exception); - static std::vector<boost::uint8_t> hash(const std::vector<boost::uint8_t> &in, const std::string &method) throw (Core::Exception) { - std::map<std::string, unsigned int>::const_iterator methodIt = hashes.getMap().find(boost::algorithm::to_lower_copy(method)); + static std::vector<boost::uint8_t> hash(const std::vector<boost::uint8_t> &in, const Core::String &method) throw (Core::Exception) { + Core::String lowerMethod = method; + lowerMethod.toLower(); + + std::map<Core::String, unsigned int>::const_iterator methodIt = hashes.getMap().find(lowerMethod); if(methodIt == hashes.getMap().end()) throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); return hash(in, methodIt->second); } - static std::vector<boost::uint8_t> hash(const std::string &in, unsigned int method) throw (Core::Exception) { - return hash(std::vector<boost::uint8_t>(in.begin(), in.end()), method); + static std::vector<boost::uint8_t> hash(const Core::String &in, unsigned int method) throw (Core::Exception) { + std::string str = in.extractUTF8(); + return hash(std::vector<boost::uint8_t>(str.begin(), str.end()), method); } - static std::vector<boost::uint8_t> hash(const std::string &in, const std::string &method) throw (Core::Exception) { - return hash(std::vector<boost::uint8_t>(in.begin(), in.end()), method); + static std::vector<boost::uint8_t> hash(const Core::String &in, const Core::String &method) throw (Core::Exception) { + std::string str = in.extractUTF8(); + return hash(std::vector<boost::uint8_t>(str.begin(), str.end()), method); } }; diff --git a/src/Common/HostInfo.h b/src/Common/HostInfo.h index 4a6c3f3..bd4afba 100644 --- a/src/Common/HostInfo.h +++ b/src/Common/HostInfo.h @@ -22,7 +22,7 @@ #include "export.h" -#include <string> +#include <Core/String.h> namespace Mad { namespace Common { @@ -34,16 +34,16 @@ class HostInfo { }; private: - std::string name; + Core::String name; std::string ip; State state; public: - HostInfo(const std::string& name0 = std::string()) : name(name0), state(INACTIVE) {} + HostInfo(const Core::String& name0 = Core::String()) : name(name0), state(INACTIVE) {} - void setName(const std::string &newName) {name = newName;} - const std::string& getName() const {return name;} + void setName(const Core::String &newName) {name = newName;} + const Core::String& getName() const {return name;} void setIP(const std::string& newIp) {ip = newIp;} const std::string& getIP() const {return ip;} diff --git a/src/Common/Request.cpp b/src/Common/Request.cpp index 0edfcfd..f7ad600 100644 --- a/src/Common/Request.cpp +++ b/src/Common/Request.cpp @@ -24,7 +24,7 @@ namespace Common { void Request::handlePacket(boost::shared_ptr<const 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; } diff --git a/src/Common/RequestHandlerGroup.h b/src/Common/RequestHandlerGroup.h index d1b7b25..ff21797 100644 --- a/src/Common/RequestHandlerGroup.h +++ b/src/Common/RequestHandlerGroup.h @@ -23,9 +23,9 @@ #include "export.h" #include "RequestHandler.h" +#include <Core/String.h> #include <set> -#include <string> namespace Mad { namespace Common { @@ -35,9 +35,9 @@ class RequestHandlerGroup { RequestHandlerGroup() {} public: - virtual const std::set<std::string>& getPacketTypes() = 0; + virtual const std::set<Core::String>& getPacketTypes() = 0; - virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const std::string &type) = 0; + virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const Core::String &type) = 0; virtual ~RequestHandlerGroup() {} }; diff --git a/src/Common/RequestHandlers/FSInfoRequestHandler.cpp b/src/Common/RequestHandlers/FSInfoRequestHandler.cpp index af4bf50..36ae515 100644 --- a/src/Common/RequestHandlers/FSInfoRequestHandler.cpp +++ b/src/Common/RequestHandlers/FSInfoRequestHandler.cpp @@ -37,8 +37,8 @@ void FSInfoRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlData for(std::vector<SystemManager::FSInfo>::const_iterator fs = fsInfo.begin(); fs != fsInfo.end(); ++fs) { XmlData::List::iterator entry = list->addEntry(); - entry->set("name", fs->fsName); - entry->set("mountedOn", fs->mountedOn); + entry->set("name", fs->fsName.c_str()); + entry->set("mountedOn", fs->mountedOn.c_str()); entry->set("totalSize", fs->total); entry->set("usedSize", fs->used); entry->set("availableSize", fs->available); diff --git a/src/Common/RequestHandlers/SimpleRequestHandler.cpp b/src/Common/RequestHandlers/SimpleRequestHandler.cpp index 86edca6..71a8b3a 100644 --- a/src/Common/RequestHandlers/SimpleRequestHandler.cpp +++ b/src/Common/RequestHandlers/SimpleRequestHandler.cpp @@ -49,7 +49,7 @@ void SimpleRequestHandler::handlePacket(boost::shared_ptr<const XmlData> packet) ret.set("ErrorCode", e.getErrorCode()); ret.set("SubCode", e.getSubCode()); ret.set("SubSubCode", e.getSubSubCode()); - ret.set("Where", e.getWhere()); + ret.set("Where", e.getWhere().c_str()); } sendPacket(ret); diff --git a/src/Common/RequestHandlers/SimpleRequestHandler.h b/src/Common/RequestHandlers/SimpleRequestHandler.h index 85cbd4c..5ccb1f4 100644 --- a/src/Common/RequestHandlers/SimpleRequestHandler.h +++ b/src/Common/RequestHandlers/SimpleRequestHandler.h @@ -30,13 +30,13 @@ namespace RequestHandlers { class MAD_COMMON_EXPORT SimpleRequestHandler : public RequestHandler { private: - std::string type; + Core::String type; boost::function2<void, boost::shared_ptr<const XmlData>, XmlData*> handler; protected: virtual void handlePacket(boost::shared_ptr<const XmlData> packet); - SimpleRequestHandler(Application *application, const std::string &type0, const boost::function2<void, boost::shared_ptr<const XmlData>, XmlData*> &handler0) + SimpleRequestHandler(Application *application, const Core::String &type0, const boost::function2<void, boost::shared_ptr<const XmlData>, XmlData*> &handler0) : RequestHandler(application), type(type0), handler(handler0) {} }; diff --git a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp index a7debc3..a3ed286 100644 --- a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp +++ b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.cpp @@ -50,15 +50,15 @@ void SimpleRequestHandlerGroup::GroupRequestHandler::handlePacket(boost::shared_ ret.set("ErrorCode", e.getErrorCode()); ret.set("SubCode", e.getSubCode()); ret.set("SubSubCode", e.getSubSubCode()); - ret.set("Where", e.getWhere()); + ret.set("Where", e.getWhere().c_str()); } sendPacket(ret); signalFinished(); } -boost::shared_ptr<RequestHandler> SimpleRequestHandlerGroup::createRequestHandler(Application *application, const std::string &type) { - std::map<std::string, boost::function3<void, boost::shared_ptr<const XmlData>, XmlData*, Connection*> >::iterator handler = handlers.find(type); +boost::shared_ptr<RequestHandler> SimpleRequestHandlerGroup::createRequestHandler(Application *application, const Core::String &type) { + std::map<Core::String, boost::function3<void, boost::shared_ptr<const XmlData>, XmlData*, Connection*> >::iterator handler = handlers.find(type); if(handler == handlers.end()) return boost::shared_ptr<RequestHandler>(); diff --git a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h index 2022705..53f8516 100644 --- a/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h +++ b/src/Common/RequestHandlers/SimpleRequestHandlerGroup.h @@ -32,22 +32,22 @@ class MAD_COMMON_EXPORT SimpleRequestHandlerGroup : public RequestHandlerGroup { private: class MAD_COMMON_EXPORT GroupRequestHandler : public RequestHandler { private: - std::string type; + Core::String type; boost::function3<void, boost::shared_ptr<const XmlData>, XmlData*, Connection*> handler; protected: virtual void handlePacket(boost::shared_ptr<const XmlData> packet); public: - GroupRequestHandler(Application *application, const std::string &type0, const boost::function3<void, boost::shared_ptr<const XmlData>, XmlData*, Connection*> &handler0) + GroupRequestHandler(Application *application, const Core::String &type0, const boost::function3<void, boost::shared_ptr<const XmlData>, XmlData*, Connection*> &handler0) : RequestHandler(application), type(type0), handler(handler0) {} }; - std::set<std::string> types; - std::map<std::string, boost::function3<void, boost::shared_ptr<const XmlData>, XmlData*, Connection*> > handlers; + std::set<Core::String> types; + std::map<Core::String, boost::function3<void, boost::shared_ptr<const XmlData>, XmlData*, Connection*> > handlers; protected: - void registerHandler(const std::string &type, const boost::function3<void, boost::shared_ptr<const XmlData>, XmlData*, Connection*> &handler) { + void registerHandler(const Core::String &type, const boost::function3<void, boost::shared_ptr<const XmlData>, XmlData*, Connection*> &handler) { types.insert(type); handlers.insert(std::make_pair(type, handler)); } @@ -55,11 +55,11 @@ class MAD_COMMON_EXPORT SimpleRequestHandlerGroup : public RequestHandlerGroup { SimpleRequestHandlerGroup() {} public: - virtual const std::set<std::string>& getPacketTypes() { + virtual const std::set<Core::String>& getPacketTypes() { return types; } - virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const std::string &type); + virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const Core::String &type); }; } diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp index 12134e0..fa767c5 100644 --- a/src/Common/RequestManager.cpp +++ b/src/Common/RequestManager.cpp @@ -104,7 +104,7 @@ void RequestManager::receiveHandler(Connection *connection, boost::shared_ptr<co return; } - std::map<std::string, boost::shared_ptr<RequestHandlerGroup> >::iterator rgh = requestHandlerGroups.find(packet->getType()); + std::map<Core::String, boost::shared_ptr<RequestHandlerGroup> >::iterator rgh = requestHandlerGroups.find(packet->getType()); if(rgh != requestHandlerGroups.end()) { request = rgh->second->createRequestHandler(application, packet->getType()); diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h index aef6b90..48472d5 100644 --- a/src/Common/RequestManager.h +++ b/src/Common/RequestManager.h @@ -72,37 +72,37 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable { template<typename T> class RequestHandlerFactory0 : public RequestHandlerGroup { private: - std::set<std::string> types; + std::set<Core::String> types; public: - RequestHandlerFactory0(const std::string &type) { + RequestHandlerFactory0(const Core::String &type) { types.insert(type); } - virtual const std::set<std::string>& getPacketTypes() { + virtual const std::set<Core::String>& getPacketTypes() { return types; } - virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const std::string& /*type*/) { + virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const Core::String& /*type*/) { return boost::shared_ptr<RequestHandler>(new T(application)); } }; template<typename T, typename T1> class RequestHandlerFactory1 : public RequestHandlerGroup { private: - std::set<std::string> types; + std::set<Core::String> types; T1 arg1; public: - RequestHandlerFactory1(const std::string &type, T1 argT1) : arg1(argT1) { + RequestHandlerFactory1(const Core::String &type, T1 argT1) : arg1(argT1) { types.insert(type); } - virtual const std::set<std::string>& getPacketTypes() { + virtual const std::set<Core::String>& getPacketTypes() { return types; } - virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const std::string& /*type*/) { + virtual boost::shared_ptr<RequestHandler> createRequestHandler(Application *application, const Core::String& /*type*/) { return boost::shared_ptr<RequestHandler>(new T(application, arg1)); } }; @@ -115,7 +115,7 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable { boost::uint16_t lastRequestId; - std::map<std::string, boost::shared_ptr<RequestHandlerGroup> > requestHandlerGroups; + std::map<Core::String, boost::shared_ptr<RequestHandlerGroup> > requestHandlerGroups; boost::uint16_t _getRequestId() { return lastRequestId+=2; @@ -145,17 +145,17 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable { void registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerGroup> requestHandlerGroup) { boost::lock_guard<boost::shared_mutex> lock(mutex); - const std::set<std::string> &types = requestHandlerGroup->getPacketTypes(); - for(std::set<std::string>::const_iterator type = types.begin(); type != types.end(); ++type) + const std::set<Core::String> &types = requestHandlerGroup->getPacketTypes(); + for(std::set<Core::String>::const_iterator type = types.begin(); type != types.end(); ++type) requestHandlerGroups.insert(std::make_pair(*type, requestHandlerGroup)); } void unregisterRequestHandlerGroup(boost::shared_ptr<RequestHandlerGroup> requestHandlerGroup) { boost::lock_guard<boost::shared_mutex> lock(mutex); - const std::set<std::string> &types = requestHandlerGroup->getPacketTypes(); - for(std::set<std::string>::const_iterator type = types.begin(); type != types.end(); ++type) { - std::map<std::string, boost::shared_ptr<RequestHandlerGroup> >::iterator it = requestHandlerGroups.find(*type); + const std::set<Core::String> &types = requestHandlerGroup->getPacketTypes(); + for(std::set<Core::String>::const_iterator type = types.begin(); type != types.end(); ++type) { + std::map<Core::String, boost::shared_ptr<RequestHandlerGroup> >::iterator it = requestHandlerGroups.find(*type); if(it == requestHandlerGroups.end() || it->second != requestHandlerGroup) continue; @@ -164,15 +164,15 @@ class MAD_COMMON_EXPORT RequestManager : private boost::noncopyable { } } - template <class T> void registerPacketType(const std::string &type) { + template <class T> void registerPacketType(const Core::String &type) { registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerFactory0<T> >(new RequestHandlerFactory0<T>(type))); } - template <class T, class T1> void registerPacketType(const std::string &type, T1 arg1) { + template <class T, class T1> void registerPacketType(const Core::String &type, T1 arg1) { registerRequestHandlerGroup(boost::shared_ptr<RequestHandlerFactory1<T, T1> >(new RequestHandlerFactory1<T, T1>(type, arg1))); } - void unregisterPacketType(const std::string &type) { + void unregisterPacketType(const Core::String &type) { boost::lock_guard<boost::shared_mutex> lock(mutex); requestHandlerGroups.erase(type); } diff --git a/src/Common/Requests/DisconnectRequest.cpp b/src/Common/Requests/DisconnectRequest.cpp index c2b7b71..676c9e1 100644 --- a/src/Common/Requests/DisconnectRequest.cpp +++ b/src/Common/Requests/DisconnectRequest.cpp @@ -32,7 +32,7 @@ void DisconnectRequest::sendRequest() { void DisconnectRequest::handlePacket(boost::shared_ptr<const 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; } diff --git a/src/Common/Requests/IdentifyRequest.cpp b/src/Common/Requests/IdentifyRequest.cpp index 98868ef..a9e566a 100644 --- a/src/Common/Requests/IdentifyRequest.cpp +++ b/src/Common/Requests/IdentifyRequest.cpp @@ -27,8 +27,7 @@ void IdentifyRequest::sendRequest() { Common::XmlData packet; packet.setType("Identify"); - if(!hostname.empty()) - packet.set("hostname", hostname); + packet.set("hostname", hostname); sendPacket(packet); } diff --git a/src/Common/Requests/IdentifyRequest.h b/src/Common/Requests/IdentifyRequest.h index 51b24dd..b0e9669 100644 --- a/src/Common/Requests/IdentifyRequest.h +++ b/src/Common/Requests/IdentifyRequest.h @@ -32,13 +32,13 @@ namespace Requests { class MAD_COMMON_EXPORT IdentifyRequest : public Common::Request { private: - std::string hostname; + Core::String hostname; protected: virtual void sendRequest(); public: - IdentifyRequest(Application *application, const std::string &hostname0) : Request(application), hostname(hostname0) {} + IdentifyRequest(Application *application, const Core::String &hostname0) : Request(application), hostname(hostname0) {} }; } diff --git a/src/Common/Requests/SimpleRequest.h b/src/Common/Requests/SimpleRequest.h index 4bff997..ff0c3c1 100644 --- a/src/Common/Requests/SimpleRequest.h +++ b/src/Common/Requests/SimpleRequest.h @@ -24,7 +24,7 @@ #include "../Request.h" -#include <string> +#include <Core/String.h> namespace Mad { namespace Common { @@ -32,11 +32,11 @@ namespace Requests { class MAD_COMMON_EXPORT SimpleRequest : public Request { protected: - const std::string type; + const Core::String type; virtual void sendRequest(); - SimpleRequest(Application *application, const std::string &type0) : Request(application), type(type0) {} + SimpleRequest(Application *application, const Core::String &type0) : Request(application), type(type0) {} }; } diff --git a/src/Common/StorageBackend.h b/src/Common/StorageBackend.h index 24bb437..13d9f5f 100644 --- a/src/Common/StorageBackend.h +++ b/src/Common/StorageBackend.h @@ -35,19 +35,19 @@ class StorageBackend { protected: friend class StorageManager; - virtual std::set<std::string> listTypes() throw (Core::Exception) = 0; - virtual std::set<std::string> list(const std::string &type) throw (Core::Exception) = 0; + virtual std::set<Core::String> listTypes() throw (Core::Exception) = 0; + virtual std::set<Core::String> list(const Core::String &type) throw (Core::Exception) = 0; - virtual bool exists(const std::string &type, const std::string &name) throw (Core::Exception) { + virtual bool exists(const Core::String &type, const Core::String &name) throw (Core::Exception) { return (list(type).count(name) > 0); } - virtual void store(const std::string &type, const std::string &name, const XmlData *data) throw (Core::Exception) = 0; - virtual boost::shared_ptr<XmlData> load(const std::string &type, const std::string &name) throw (Core::Exception) = 0; + virtual void store(const Core::String &type, const Core::String &name, const XmlData *data) throw (Core::Exception) = 0; + virtual boost::shared_ptr<XmlData> load(const Core::String &type, const Core::String &name) throw (Core::Exception) = 0; - virtual void copy(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception) = 0; - virtual void rename(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception) = 0; - virtual void remove(const std::string &type, const std::string &name) throw (Core::Exception) = 0; + virtual void copy(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) = 0; + virtual void rename(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) = 0; + virtual void remove(const Core::String &type, const Core::String &name) throw (Core::Exception) = 0; public: virtual ~StorageBackend() {} diff --git a/src/Common/StorageManager.cpp b/src/Common/StorageManager.cpp index 5b5fc65..d15d110 100644 --- a/src/Common/StorageManager.cpp +++ b/src/Common/StorageManager.cpp @@ -36,7 +36,7 @@ void StorageManager::unsetBackend(boost::shared_ptr<StorageBackend> oldBackend) backend.reset(); } -std::set<std::string> StorageManager::listTypes() throw (Core::Exception) { +std::set<Core::String> StorageManager::listTypes() throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); @@ -44,7 +44,7 @@ std::set<std::string> StorageManager::listTypes() throw (Core::Exception) { return backend->listTypes(); } -std::set<std::string> StorageManager::list(const std::string &type) throw (Core::Exception) { +std::set<Core::String> StorageManager::list(const Core::String &type) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); @@ -52,7 +52,7 @@ std::set<std::string> StorageManager::list(const std::string &type) throw (Core: return backend->list(type); } -bool StorageManager::exists(const std::string &type, const std::string &name) throw (Core::Exception) { +bool StorageManager::exists(const Core::String &type, const Core::String &name) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); @@ -60,7 +60,7 @@ bool StorageManager::exists(const std::string &type, const std::string &name) th return backend->exists(type, name); } -void StorageManager::store(const std::string &type, const std::string &name, const XmlData *data) throw (Core::Exception) { +void StorageManager::store(const Core::String &type, const Core::String &name, const XmlData *data) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); @@ -68,7 +68,7 @@ void StorageManager::store(const std::string &type, const std::string &name, con backend->store(type, name, data); } -boost::shared_ptr<XmlData> StorageManager::load(const std::string &type, const std::string &name) throw (Core::Exception) { +boost::shared_ptr<XmlData> StorageManager::load(const Core::String &type, const Core::String &name) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); @@ -76,7 +76,7 @@ boost::shared_ptr<XmlData> StorageManager::load(const std::string &type, const s return backend->load(type, name); } -void StorageManager::copy(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception) { +void StorageManager::copy(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); @@ -84,7 +84,7 @@ void StorageManager::copy(const std::string &type, const std::string &name, cons backend->copy(type, name, newName); } -void StorageManager::rename(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception) { +void StorageManager::rename(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); @@ -92,7 +92,7 @@ void StorageManager::rename(const std::string &type, const std::string &name, co backend->rename(type, name, newName); } -void StorageManager::remove(const std::string &type, const std::string &name) throw (Core::Exception) { +void StorageManager::remove(const Core::String &type, const Core::String &name) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!backend) throw Core::Exception(Core::Exception::NOT_IMPLEMENTED); diff --git a/src/Common/StorageManager.h b/src/Common/StorageManager.h index d6cb5f5..a28f7a4 100644 --- a/src/Common/StorageManager.h +++ b/src/Common/StorageManager.h @@ -51,17 +51,17 @@ class MAD_COMMON_EXPORT StorageManager { void setBackend(boost::shared_ptr<StorageBackend> newBackend); void unsetBackend(boost::shared_ptr<StorageBackend> oldBackend); - std::set<std::string> listTypes() throw (Core::Exception); - std::set<std::string> list(const std::string &type) throw (Core::Exception); + std::set<Core::String> listTypes() throw (Core::Exception); + std::set<Core::String> list(const Core::String &type) throw (Core::Exception); - bool exists(const std::string &type, const std::string &name) throw (Core::Exception); + bool exists(const Core::String &type, const Core::String &name) throw (Core::Exception); - void store(const std::string &type, const std::string &name, const XmlData *data) throw (Core::Exception); - boost::shared_ptr<XmlData> load(const std::string &type, const std::string &name) throw (Core::Exception); + void store(const Core::String &type, const Core::String &name, const XmlData *data) throw (Core::Exception); + boost::shared_ptr<XmlData> load(const Core::String &type, const Core::String &name) throw (Core::Exception); - void copy(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception); - void rename(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception); - void remove(const std::string &type, const std::string &name) throw (Core::Exception); + void copy(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception); + void rename(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception); + void remove(const Core::String &type, const Core::String &name) throw (Core::Exception); }; } diff --git a/src/Common/UserCache.cpp b/src/Common/UserCache.cpp index e2bb575..7682fb1 100644 --- a/src/Common/UserCache.cpp +++ b/src/Common/UserCache.cpp @@ -36,7 +36,7 @@ boost::shared_ptr<const std::map<unsigned long, UserInfo> > UserCache::getUserLi userException = Core::Exception(); userTime = newTime; - userNames.reset(new std::map<std::string, unsigned long>); + userNames.reset(new std::map<Core::String, unsigned long>); for(std::map<unsigned long, UserInfo>::const_iterator user = users->begin(); user != users->end(); ++user) userNames->insert(std::make_pair(user->second.getUsername(), user->first)); } @@ -82,13 +82,13 @@ boost::shared_ptr<const UserInfo> UserCache::getUserInfo(unsigned long uid, boos return boost::shared_ptr<UserInfo>(new UserInfo(user->second)); } -boost::shared_ptr<const UserInfo> UserCache::getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { +boost::shared_ptr<const UserInfo> UserCache::getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::lock_guard<boost::recursive_mutex> lock(mutex); if(!getUserList(timestamp)) return boost::shared_ptr<const UserInfo>(); - std::map<std::string, unsigned long>::const_iterator uid = userNames->find(name); + std::map<Core::String, unsigned long>::const_iterator uid = userNames->find(name); if(uid == userNames->end()) throw Core::Exception(Core::Exception::NOT_FOUND); @@ -127,7 +127,7 @@ boost::shared_ptr<const std::map<unsigned long, GroupInfo> > UserCache::getGroup groupException = Core::Exception(); groupTime = newTime; - groupNames.reset(new std::map<std::string, unsigned long>); + groupNames.reset(new std::map<Core::String, unsigned long>); for(std::map<unsigned long, GroupInfo>::const_iterator group = groups->begin(); group != groups->end(); ++group) groupNames->insert(std::make_pair(group->second.getName(), group->first)); } @@ -173,13 +173,13 @@ boost::shared_ptr<const GroupInfo> UserCache::getGroupInfo(unsigned long gid, bo return boost::shared_ptr<GroupInfo>(new GroupInfo(group->second)); } -boost::shared_ptr<const GroupInfo> UserCache::getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { +boost::shared_ptr<const GroupInfo> UserCache::getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::lock_guard<boost::recursive_mutex> lock(mutex); if(!getGroupList(timestamp)) return boost::shared_ptr<const GroupInfo>(); - std::map<std::string, unsigned long>::const_iterator gid = groupNames->find(name); + std::map<Core::String, unsigned long>::iterator gid = groupNames->find(name); if(gid == groupNames->end()) throw Core::Exception(Core::Exception::NOT_FOUND); diff --git a/src/Common/UserCache.h b/src/Common/UserCache.h index c579221..6981172 100644 --- a/src/Common/UserCache.h +++ b/src/Common/UserCache.h @@ -45,12 +45,12 @@ class MAD_COMMON_EXPORT UserCache : public UserDBBackend, private boost::noncopy boost::recursive_mutex mutex; boost::shared_ptr<const std::map<unsigned long, UserInfo> > users; - boost::shared_ptr<std::map<std::string, unsigned long> > userNames; + boost::shared_ptr<std::map<Core::String, unsigned long> > userNames; Core::Exception userException; boost::posix_time::ptime userTime; boost::shared_ptr<const std::map<unsigned long, GroupInfo> > groups; - boost::shared_ptr<std::map<std::string, unsigned long> > groupNames; + boost::shared_ptr<std::map<Core::String, unsigned long> > groupNames; Core::Exception groupException; boost::posix_time::ptime groupTime; @@ -62,12 +62,12 @@ class MAD_COMMON_EXPORT UserCache : public UserDBBackend, private boost::noncopy protected: virtual boost::shared_ptr<const std::map<unsigned long, UserInfo> > getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const UserInfo> getUserInfo(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception); - virtual boost::shared_ptr<const UserInfo> getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); + virtual boost::shared_ptr<const UserInfo> getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::set<unsigned long> > getUserGroupList(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::map<unsigned long, GroupInfo> > getGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const GroupInfo> getGroupInfo(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception); - virtual boost::shared_ptr<const GroupInfo> getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); + virtual boost::shared_ptr<const GroupInfo> getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::set<unsigned long> > getGroupUserList(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception); @@ -115,7 +115,7 @@ class MAD_COMMON_EXPORT UserCache : public UserDBBackend, private boost::noncopy } - virtual void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception) { + virtual void setPassword(unsigned long uid, const Core::String &password) throw(Core::Exception) { backend->setPassword(uid, password); } @@ -124,7 +124,7 @@ class MAD_COMMON_EXPORT UserCache : public UserDBBackend, private boost::noncopy userGroupTime(boost::posix_time::not_a_date_time) {} public: - virtual const std::string& getName() { + virtual const Core::String& getName() { return backend->getName(); } }; diff --git a/src/Common/UserConfigBackend.h b/src/Common/UserConfigBackend.h index e7c6245..26f3438 100644 --- a/src/Common/UserConfigBackend.h +++ b/src/Common/UserConfigBackend.h @@ -51,7 +51,7 @@ class UserConfigBackend { virtual void addUserToGroup(const UserInfo &/*userInfo*/, const GroupInfo &/*groupInfo*/) throw(Core::Exception) {} virtual void deleteUserFromGroup(const UserInfo &/*userInfo*/, const GroupInfo &/*groupInfo*/) throw(Core::Exception) {} - virtual void setPassword(const Common::UserInfo &/*userInfo*/, const std::string &/*password*/) throw(Core::Exception) { + virtual void setPassword(const Common::UserInfo &/*userInfo*/, const Core::String &/*password*/) throw(Core::Exception) { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } }; diff --git a/src/Common/UserDBBackend.h b/src/Common/UserDBBackend.h index 8d4c95a..7ac0ba3 100644 --- a/src/Common/UserDBBackend.h +++ b/src/Common/UserDBBackend.h @@ -29,7 +29,6 @@ #include <map> #include <set> -#include <string> #include <boost/date_time/posix_time/posix_time_types.hpp> #include <boost/smart_ptr.hpp> @@ -56,7 +55,7 @@ class UserDBBackend { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } - virtual boost::shared_ptr<const UserInfo> getUserInfoByName(const std::string& /*name*/, boost::posix_time::ptime* /*timestamp*/) throw(Core::Exception) { + virtual boost::shared_ptr<const UserInfo> getUserInfoByName(const Core::String& /*name*/, boost::posix_time::ptime* /*timestamp*/) throw(Core::Exception) { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } @@ -73,7 +72,7 @@ class UserDBBackend { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } - virtual boost::shared_ptr<const GroupInfo> getGroupInfoByName(const std::string& /*name*/, boost::posix_time::ptime* /*timestamp*/) throw(Core::Exception) { + virtual boost::shared_ptr<const GroupInfo> getGroupInfoByName(const Core::String& /*name*/, boost::posix_time::ptime* /*timestamp*/) throw(Core::Exception) { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } @@ -125,14 +124,14 @@ class UserDBBackend { } - virtual void setPassword(unsigned long /*uid*/, const std::string& /*password*/) throw(Core::Exception) { + virtual void setPassword(unsigned long /*uid*/, const Core::String& /*password*/) throw(Core::Exception) { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } public: virtual ~UserDBBackend() {} - virtual const std::string& getName() = 0; + virtual const Core::String& getName() = 0; }; } diff --git a/src/Common/UserInfo.h b/src/Common/UserInfo.h index 6859904..f85b9d8 100644 --- a/src/Common/UserInfo.h +++ b/src/Common/UserInfo.h @@ -22,7 +22,7 @@ #include "export.h" -#include <string> +#include <Core/String.h> namespace Mad { namespace Common { @@ -32,11 +32,11 @@ class UserInfo { unsigned long uid; unsigned long gid; - std::string username; - std::string fullName; + Core::String username; + Core::String fullName; public: - UserInfo(unsigned long uid0 = 0, const std::string& username0 = std::string()) : uid(uid0), gid(0), username(username0) {} + UserInfo(unsigned long uid0 = 0, const Core::String& username0 = Core::String()) : uid(uid0), gid(0), username(username0) {} void setUid(unsigned long newUid) {uid = newUid;} unsigned long getUid() const {return uid;} @@ -44,11 +44,11 @@ class UserInfo { void setGid(unsigned long newGid) {gid = newGid;} unsigned long getGid() const {return gid;} - void setUsername(const std::string& newUsername) {username = newUsername;} - const std::string& getUsername() const {return username;} + void setUsername(const Core::String& newUsername) {username = newUsername;} + const Core::String& getUsername() const {return username;} - void setFullName(const std::string& newFullName) {fullName = newFullName;} - const std::string& getFullName() const {return fullName;} + void setFullName(const Core::String& newFullName) {fullName = newFullName;} + const Core::String& getFullName() const {return fullName;} }; } diff --git a/src/Common/UserLists/UserList.cpp b/src/Common/UserLists/UserList.cpp index a14111d..2fb47cd 100644 --- a/src/Common/UserLists/UserList.cpp +++ b/src/Common/UserLists/UserList.cpp @@ -23,7 +23,7 @@ namespace Mad { namespace Common { namespace UserLists { -std::list<UserListEntry>::iterator UserList::findEntry(const std::string &name) { +std::list<UserListEntry>::iterator UserList::findEntry(const Core::String &name) { for(std::list<UserListEntry>::iterator it = list.begin(); it != list.end(); ++it) { if(it->getName() == name) { return it; @@ -33,7 +33,7 @@ std::list<UserListEntry>::iterator UserList::findEntry(const std::string &name) return list.end(); } -std::list<UserListEntry>::const_iterator UserList::findEntry(const std::string &name) const { +std::list<UserListEntry>::const_iterator UserList::findEntry(const Core::String &name) const { for(std::list<UserListEntry>::const_iterator it = list.begin(); it != list.end(); ++it) { if(it->getName() == name) { return it; @@ -43,14 +43,14 @@ std::list<UserListEntry>::const_iterator UserList::findEntry(const std::string & return list.end(); } -UserList::iterator UserList::find(const std::string &name) { +UserList::iterator UserList::find(const Core::String &name) { if(!names.count(name)) return end(); return iterator(findEntry(name)); } -UserList::const_iterator UserList::find(const std::string &name) const { +UserList::const_iterator UserList::find(const Core::String &name) const { if(!names.count(name)) return end(); @@ -58,22 +58,22 @@ UserList::const_iterator UserList::find(const std::string &name) const { } void UserList::registerEntry(const UserListEntry &entry) { - std::set<std::string> details = entry.getDetailList(); + std::set<Core::String> details = entry.getDetailList(); - for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) { - std::map<std::string, unsigned>::iterator it = detailCounts.find(*detail); + for(std::set<Core::String>::iterator detail = details.begin(); detail != details.end(); ++detail) { + std::map<Core::String, unsigned>::iterator it = detailCounts.find(*detail); if(it == detailCounts.end()) - detailCounts.insert(make_pair(*detail, 1)); + detailCounts.insert(std::make_pair(*detail, 1)); else ++it->second; } } void UserList::unregisterEntry(const UserListEntry &entry) { - std::set<std::string> details = entry.getDetailList(); + std::set<Core::String> details = entry.getDetailList(); - for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) { - std::map<std::string, unsigned>::iterator it = detailCounts.find(*detail); + for(std::set<Core::String>::iterator detail = details.begin(); detail != details.end(); ++detail) { + std::map<Core::String, unsigned>::iterator it = detailCounts.find(*detail); // TODO Assert if(it == detailCounts.end()) continue; @@ -99,7 +99,7 @@ bool UserList::insertUser(const UserListEntry &entry, iterator after) { return true; } -bool UserList::removeUser(const std::string &name) { +bool UserList::removeUser(const Core::String &name) { if(!names.erase(name)) return false; diff --git a/src/Common/UserLists/UserList.h b/src/Common/UserLists/UserList.h index 9c5985d..4e782bf 100644 --- a/src/Common/UserLists/UserList.h +++ b/src/Common/UserLists/UserList.h @@ -89,23 +89,23 @@ class MAD_COMMON_EXPORT UserList { } }; - std::set<std::string> names; + std::set<Core::String> names; std::list<UserListEntry> list; - std::map<std::string, unsigned> detailCounts; + std::map<Core::String, unsigned> detailCounts; void registerEntry(const UserListEntry &entry); void unregisterEntry(const UserListEntry &entry); - std::list<UserListEntry>::iterator findEntry(const std::string &name); - std::list<UserListEntry>::const_iterator findEntry(const std::string &name) const; + std::list<UserListEntry>::iterator findEntry(const Core::String &name); + std::list<UserListEntry>::const_iterator findEntry(const Core::String &name) const; public: typedef iterator_base<const UserListEntry, std::list<UserListEntry>::iterator> iterator; typedef iterator_base<const UserListEntry, std::list<UserListEntry>::const_iterator> const_iterator; - iterator find(const std::string &name); - const_iterator find(const std::string &name) const; + iterator find(const Core::String &name); + const_iterator find(const Core::String &name) const; iterator begin() { return iterator(list.begin()); @@ -131,17 +131,17 @@ class MAD_COMMON_EXPORT UserList { return list.size(); } - std::set<std::string> getDetails() const { - std::set<std::string> ret; + std::set<Core::String> getDetails() const { + std::set<Core::String> ret; - for(std::map<std::string, unsigned>::const_iterator it = detailCounts.begin(); it != detailCounts.end(); ++it) + for(std::map<Core::String, unsigned>::const_iterator it = detailCounts.begin(); it != detailCounts.end(); ++it) ret.insert(it->first); return ret; } - unsigned getDetailUsage(const std::string &detail) const { - std::map<std::string, unsigned>::const_iterator it = detailCounts.find(detail); + unsigned getDetailUsage(const Core::String &detail) const { + std::map<Core::String, unsigned>::const_iterator it = detailCounts.find(detail); if(it == detailCounts.end()) return 0; else @@ -150,7 +150,7 @@ class MAD_COMMON_EXPORT UserList { bool addUser(const UserListEntry &entry); bool insertUser(const UserListEntry &entry, iterator after); - bool removeUser(const std::string &name); + bool removeUser(const Core::String &name); bool updateUser(const UserListEntry &entry); UserList() {} diff --git a/src/Common/UserLists/UserListEntry.h b/src/Common/UserLists/UserListEntry.h index 8642275..acfe445 100644 --- a/src/Common/UserLists/UserListEntry.h +++ b/src/Common/UserLists/UserListEntry.h @@ -20,9 +20,10 @@ #ifndef MAD_COMMON_USERLISTS_USERLISTENTRY_H_ #define MAD_COMMON_USERLISTS_USERLISTENTRY_H_ +#include <Core/String.h> + #include <map> #include <set> -#include <string> namespace Mad { @@ -31,53 +32,53 @@ namespace UserLists { class UserListEntry { private: - std::string name; - std::string group; + Core::String name; + Core::String group; - std::map<std::string, std::string> details; + std::map<Core::String, Core::String> details; public: - UserListEntry(const std::string &name0 = std::string(), const std::string &group0 = std::string()) : name(name0), group(group0) {} + UserListEntry(const Core::String &name0 = Core::String(), const Core::String &group0 = Core::String()) : name(name0), group(group0) {} - const std::string& getName() const { + const Core::String& getName() const { return name; } - void setName(const std::string &newName) { + void setName(const Core::String &newName) { name = newName; } - const std::string& getGroup() const { + const Core::String& getGroup() const { return group; } - void setGroup(const std::string &newGroup) { + void setGroup(const Core::String &newGroup) { group = newGroup; } - std::set<std::string> getDetailList() const { - std::set<std::string> ret; + std::set<Core::String> getDetailList() const { + std::set<Core::String> ret; - for(std::map<std::string, std::string>::const_iterator it = details.begin(); it != details.end(); ++it) + for(std::map<Core::String, Core::String>::const_iterator it = details.begin(); it != details.end(); ++it) ret.insert(it->first); return ret; } - std::string getDetail(const std::string &name) const { - std::map<std::string, std::string>::const_iterator it = details.find(name); + Core::String getDetail(const Core::String &name) const { + std::map<Core::String, Core::String>::const_iterator it = details.find(name); if(it != details.end()) return it->second; else - return std::string(); + return Core::String(); } - void setDetail(const std::string &name, const std::string &value) { + void setDetail(const Core::String &name, const Core::String &value) { details.erase(name); details.insert(std::make_pair(name, value)); } - void unsetDetail(const std::string &name) { + void unsetDetail(const Core::String &name) { details.erase(name); } diff --git a/src/Common/UserLists/Util.cpp b/src/Common/UserLists/Util.cpp index 3c15956..cf04218 100644 --- a/src/Common/UserLists/Util.cpp +++ b/src/Common/UserLists/Util.cpp @@ -26,8 +26,8 @@ namespace Common { namespace UserLists { void Util::serializeUserListEntry(const UserListEntry *user, XmlData::List::iterator entry) { - std::set<std::string> details = user->getDetailList(); - for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) + std::set<Core::String> details = user->getDetailList(); + for(std::set<Core::String>::iterator detail = details.begin(); detail != details.end(); ++detail) entry->set(*detail, user->getDetail(*detail)); entry->set("name", user->getName()); @@ -35,14 +35,14 @@ void Util::serializeUserListEntry(const UserListEntry *user, XmlData::List::iter } UserListEntry Util::deserializeUserListEntry(XmlData::List::const_iterator entry) { - UserListEntry user(entry->get<const std::string&>("name"), entry->get<const std::string&>("group")); + UserListEntry user(entry->get<const Core::String&>("name"), entry->get<const Core::String&>("group")); - std::set<std::string> details = entry->getChildren(); - for(std::set<std::string>::iterator detail = details.begin(); detail != details.end(); ++detail) { + std::set<Core::String> details = entry->getChildren(); + for(std::set<Core::String>::iterator detail = details.begin(); detail != details.end(); ++detail) { if(*detail == "name" || *detail == "group") continue; - user.setDetail(*detail, entry->get<const std::string&>(*detail)); + user.setDetail(*detail, entry->get<const Core::String&>(*detail)); } return user; diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp index f14dbcc..5fb5d15 100644 --- a/src/Common/UserManager.cpp +++ b/src/Common/UserManager.cpp @@ -98,7 +98,7 @@ bool UserManager::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handl void UserManager::registerBackend(boost::shared_ptr<UserDBBackend> backend) { boost::lock_guard<boost::shared_mutex> lock(mutex); - const std::string &name = backend->getName(); + const Core::String &name = backend->getName(); dbBackends.insert(std::make_pair(backend, std::make_pair(backend, name))); dbBackendNames.insert(std::make_pair(name, backend)); @@ -110,7 +110,7 @@ void UserManager::registerBackend(boost::shared_ptr<UserDBBackend> backend) { void UserManager::registerBackendCached(boost::shared_ptr<UserDBBackend> backend) { boost::lock_guard<boost::shared_mutex> lock(mutex); - const std::string &name = backend->getName(); + const Core::String &name = backend->getName(); boost::shared_ptr<UserCache> cache(new UserCache(application, backend)); @@ -140,7 +140,7 @@ boost::shared_ptr<const UserInfo> UserManager::getUserInfo(unsigned long uid, bo return dbBackend->getUserInfo(uid, timestamp); } -boost::shared_ptr<const UserInfo> UserManager::getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { +boost::shared_ptr<const UserInfo> UserManager::getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!dbBackend) @@ -176,7 +176,7 @@ boost::shared_ptr<const GroupInfo> UserManager::getGroupInfo(unsigned long gid, return dbBackend->getGroupInfo(gid, timestamp); } -boost::shared_ptr<const GroupInfo> UserManager::getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { +boost::shared_ptr<const GroupInfo> UserManager::getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!dbBackend) @@ -418,7 +418,7 @@ void UserManager::deleteUserFromGroup(unsigned long uid, unsigned long gid) thro } } -void UserManager::setPassword(unsigned long uid, const std::string &password) throw(Core::Exception) { +void UserManager::setPassword(unsigned long uid, const Core::String &password) throw(Core::Exception) { boost::lock_guard<boost::shared_mutex> lock(mutex); if(!dbBackend) diff --git a/src/Common/UserManager.h b/src/Common/UserManager.h index 6da5af4..0cf7fca 100644 --- a/src/Common/UserManager.h +++ b/src/Common/UserManager.h @@ -46,14 +46,14 @@ class MAD_COMMON_EXPORT UserManager : public Core::Configurable, private boost:: private: friend class Application; - typedef std::map<boost::shared_ptr<UserDBBackend>, std::pair<boost::shared_ptr<UserDBBackend>, std::string> > BackendMap; + typedef std::map<boost::shared_ptr<UserDBBackend>, std::pair<boost::shared_ptr<UserDBBackend>, Core::String> > BackendMap; Application *application; std::set<boost::shared_ptr<UserConfigBackend> > configBackends; BackendMap dbBackends; - std::map<std::string, boost::shared_ptr<UserDBBackend> > dbBackendNames; + std::map<Core::String, boost::shared_ptr<UserDBBackend> > dbBackendNames; boost::shared_ptr<UserDBBackend> dbBackend; @@ -80,7 +80,7 @@ class MAD_COMMON_EXPORT UserManager : public Core::Configurable, private boost:: boost::shared_ptr<UserDBBackend> oldBackend = it->second.first; - std::map<std::string, boost::shared_ptr<UserDBBackend> >::iterator it2 = dbBackendNames.find(it->second.second); + std::map<Core::String, boost::shared_ptr<UserDBBackend> >::iterator it2 = dbBackendNames.find(it->second.second); if(it2->second == backend) dbBackendNames.erase(it2); @@ -107,12 +107,12 @@ class MAD_COMMON_EXPORT UserManager : public Core::Configurable, private boost:: boost::shared_ptr<const std::map<unsigned long, UserInfo> > getUserList(boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); boost::shared_ptr<const UserInfo> getUserInfo(unsigned long uid, boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); - boost::shared_ptr<const UserInfo> getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); + boost::shared_ptr<const UserInfo> getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); boost::shared_ptr<const std::set<unsigned long> > getUserGroupList(unsigned long uid, boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); boost::shared_ptr<const std::map<unsigned long, GroupInfo> > getGroupList(boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); boost::shared_ptr<const GroupInfo> getGroupInfo(unsigned long gid, boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); - boost::shared_ptr<const GroupInfo> getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); + boost::shared_ptr<const GroupInfo> getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); boost::shared_ptr<const std::set<unsigned long> > getGroupUserList(unsigned long gid, boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > getFullUserGroupList(boost::posix_time::ptime *timestamp = 0) throw(Core::Exception); @@ -130,7 +130,7 @@ class MAD_COMMON_EXPORT UserManager : public Core::Configurable, private boost:: void addUserToGroup(unsigned long uid, unsigned long gid) throw(Core::Exception); void deleteUserFromGroup(unsigned long uid, unsigned long gid) throw(Core::Exception); - void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception); + void setPassword(unsigned long uid, const Core::String &password) throw(Core::Exception); }; } diff --git a/src/Common/XmlData.cpp b/src/Common/XmlData.cpp index aa3fcdf..de9588a 100644 --- a/src/Common/XmlData.cpp +++ b/src/Common/XmlData.cpp @@ -29,13 +29,13 @@ namespace Mad { namespace Common { void XmlData::Element::updateStr() { - std::string typeStr; + Core::String typeStr; if(type == NONE) { str = ""; } else if(type == BINARY) { - str = Base64Encoder::encode(boost::get<std::vector<boost::uint8_t> >(value)); + str = Base64Encoder::encode(boost::get<std::vector<boost::uint8_t> >(value)).c_str(); typeStr = "binary"; } else if(type != STRING) { @@ -73,18 +73,18 @@ void XmlData::Element::updateStr() { break; } - str = buf.str(); + str = buf.str().c_str(); } else typeStr = "string"; - xmlNodePtr newNode = xmlNewText((xmlChar*)str.c_str()); + xmlNodePtr newNode = xmlNewText((xmlChar*)str.extractUTF8().c_str()); xmlNodePtr oldNode = elementNode->children; xmlReplaceNode(oldNode, newNode); xmlFreeNode(oldNode); - xmlSetProp(elementNode, (xmlChar*)"type", (xmlChar*)typeStr.c_str()); + xmlSetProp(elementNode, (xmlChar*)"type", (xmlChar*)typeStr.extractUTF8().c_str()); } XmlData::Element::Element(xmlNodePtr node) : elementNode(node), type(NONE) { @@ -101,13 +101,13 @@ XmlData::Element::Element(xmlNodePtr node) : elementNode(node), type(NONE) { return; } - str = (char*)content; - std::istringstream buf(str); + str = Core::String::fromUTF8((char*)content); + std::istringstream buf(str.extract()); if(!xmlStrcmp(typestr, (xmlChar*)"binary")) { type = BINARY; - value = Base64Encoder::decode(str); + value = Base64Encoder::decode(str.extract()); } else if(!xmlStrcmp(typestr, (xmlChar*)"int")) { type = INT; @@ -180,9 +180,9 @@ XmlData::Entry::Entry(xmlNodePtr node) : entryNode(node) { xmlChar *name = xmlGetProp(element, (xmlChar*)"name"); if(!xmlStrcmp(element->name, (xmlChar*)"list")) - lists.insert(std::make_pair(std::string((char*)name), new List(element))); + lists.insert(std::make_pair(Core::String::fromUTF8((char*)name), new List(element))); else if(!xmlStrcmp(element->name, (xmlChar*)"value")) - elements.insert(std::make_pair(std::string((char*)name), new Element(element))); + elements.insert(std::make_pair(Core::String::fromUTF8((char*)name), new Element(element))); xmlFree(name); } @@ -191,17 +191,17 @@ XmlData::Entry::Entry(xmlNodePtr node) : entryNode(node) { template <> -std::string XmlData::Entry::get<std::string>(const std::string &name) const { +Core::String XmlData::Entry::get<Core::String>(const Core::String &name) const { Element *element = getElement(name); if(!element) - return std::string(); + return Core::String(); return element->str; } template <> -const std::string& XmlData::Entry::get<const std::string&>(const std::string &name) const { - static std::string empty; +const Core::String& XmlData::Entry::get<const Core::String&>(const Core::String &name) const { + static const Core::String empty; Element *element = getElement(name); if(!element) @@ -211,7 +211,7 @@ const std::string& XmlData::Entry::get<const std::string&>(const std::string &na } template <> -std::vector<boost::uint8_t> XmlData::Entry::get<std::vector<unsigned char> >(const std::string &name) const { +std::vector<boost::uint8_t> XmlData::Entry::get<std::vector<unsigned char> >(const Core::String &name) const { Element *element = getElement(name); if(!element) return std::vector<boost::uint8_t>(); @@ -225,8 +225,8 @@ std::vector<boost::uint8_t> XmlData::Entry::get<std::vector<unsigned char> >(con } template <> -const std::vector<boost::uint8_t>& XmlData::Entry::get<const std::vector<unsigned char>&>(const std::string &name) const { - static std::vector<boost::uint8_t> empty; +const std::vector<boost::uint8_t>& XmlData::Entry::get<const std::vector<unsigned char>&>(const Core::String &name) const { + static const std::vector<boost::uint8_t> empty; Element *element = getElement(name); if(!element) @@ -290,18 +290,18 @@ XmlData& XmlData::operator=(const XmlData &o) { return *this; } -std::string XmlData::getType() const { +Core::String XmlData::getType() const { xmlChar *type = xmlGetProp(rootNode, (xmlChar*)"type"); - std::string ret(type ? (char*)type : ""); + Core::String ret(type ? Core::String::fromUTF8((char*)type) : ""); xmlFree(type); return ret; } -void XmlData::setType(const std::string &type) { - xmlSetProp(rootNode, (xmlChar*)"type", (xmlChar*)type.c_str()); +void XmlData::setType(const Core::String &type) { + xmlSetProp(rootNode, (xmlChar*)"type", (xmlChar*)type.extractUTF8().c_str()); } Net::Packet XmlData::toPacket(boost::uint16_t requestId) const { diff --git a/src/Common/XmlData.h b/src/Common/XmlData.h index b7e8ec1..1861b71 100644 --- a/src/Common/XmlData.h +++ b/src/Common/XmlData.h @@ -27,7 +27,6 @@ #include <map> #include <set> -#include <string> #include <sstream> #include <vector> @@ -69,7 +68,7 @@ class MAD_COMMON_EXPORT XmlData { Type type; Variant value; - std::string str; + Core::String str; void updateStr(); @@ -119,7 +118,7 @@ class MAD_COMMON_EXPORT XmlData { set(val, LONGDOUBLE); } - void set(const std::string &val) { + void set(const Core::String &val) { type = STRING; value = Element::Variant(); str = val; @@ -139,11 +138,11 @@ class MAD_COMMON_EXPORT XmlData { xmlNodePtr entryNode; - std::map<std::string, Element*> elements; - std::map<std::string, List*> lists; + std::map<Core::String, Element*> elements; + std::map<Core::String, List*> lists; - Element* getElement(const std::string &name) { - std::map<std::string, Element*>::iterator element = elements.find(name); + Element* getElement(const Core::String &name) { + std::map<Core::String, Element*>::iterator element = elements.find(name); if(element != elements.end()) return element->second; @@ -152,7 +151,7 @@ class MAD_COMMON_EXPORT XmlData { return 0; xmlNodePtr newNode = xmlNewTextChild(entryNode, 0, (xmlChar*)"value", (xmlChar*)""); - xmlSetProp(newNode, (xmlChar*)"name", (xmlChar*)name.c_str()); + xmlSetProp(newNode, (xmlChar*)"name", (xmlChar*)name.extractUTF8().c_str()); xmlSetProp(newNode, (xmlChar*)"type", (xmlChar*)""); Element* newElement = new Element(newNode); @@ -162,8 +161,8 @@ class MAD_COMMON_EXPORT XmlData { return newElement; } - Element* getElement(const std::string &name) const { - std::map<std::string, Element*>::const_iterator element = elements.find(name); + Element* getElement(const Core::String &name) const { + std::map<Core::String, Element*>::const_iterator element = elements.find(name); if(element != elements.end()) return element->second; @@ -173,16 +172,16 @@ class MAD_COMMON_EXPORT XmlData { Entry(xmlNodePtr node); ~Entry() { - for(std::map<std::string, Element*>::iterator element = elements.begin(); element != elements.end(); ++element) + for(std::map<Core::String, Element*>::iterator element = elements.begin(); element != elements.end(); ++element) delete element->second; - for(std::map<std::string, List*>::iterator list = lists.begin(); list != lists.end(); ++list) + for(std::map<Core::String, List*>::iterator list = lists.begin(); list != lists.end(); ++list) delete list->second; } public: template <typename T> - bool set(const std::string &name, T val) { + bool set(const Core::String &name, T val) { Element *element = getElement(name); if(!element) return false; @@ -193,7 +192,7 @@ class MAD_COMMON_EXPORT XmlData { } template <typename T> - T get(const std::string &name) const { + T get(const Core::String &name) const { Element *element = getElement(name); if(!element) return T(); @@ -218,8 +217,8 @@ class MAD_COMMON_EXPORT XmlData { } } - List* createList(const std::string &name, bool unique = false) { - std::map<std::string, List*>::iterator list = lists.find(name); + List* createList(const Core::String &name, bool unique = false) { + std::map<Core::String, List*>::iterator list = lists.find(name); if(list != lists.end()) return unique ? 0 : list->second; @@ -228,7 +227,7 @@ class MAD_COMMON_EXPORT XmlData { return 0; xmlNodePtr newNode = xmlNewChild(entryNode, 0, (xmlChar*)"list", 0); - xmlSetProp(newNode, (xmlChar*)"name", (xmlChar*)name.c_str()); + xmlSetProp(newNode, (xmlChar*)"name", (xmlChar*)name.extractUTF8().c_str()); List *newList = new List(newNode); @@ -237,8 +236,8 @@ class MAD_COMMON_EXPORT XmlData { return newList; } - List* getList(const std::string &name) { - std::map<std::string, List*>::iterator list = lists.find(name); + List* getList(const Core::String &name) { + std::map<Core::String, List*>::iterator list = lists.find(name); if(list == lists.end()) return 0; @@ -246,8 +245,8 @@ class MAD_COMMON_EXPORT XmlData { return list->second; } - const List* getList(const std::string &name) const { - std::map<std::string, List*>::const_iterator list = lists.find(name); + const List* getList(const Core::String &name) const { + std::map<Core::String, List*>::const_iterator list = lists.find(name); if(list == lists.end()) return 0; @@ -255,8 +254,8 @@ class MAD_COMMON_EXPORT XmlData { return list->second; } - void unset(const std::string &name) { - std::map<std::string, Element*>::iterator element = elements.find(name); + void unset(const Core::String &name) { + std::map<Core::String, Element*>::iterator element = elements.find(name); if(element != elements.end()) { xmlUnlinkNode(element->second->elementNode); @@ -269,7 +268,7 @@ class MAD_COMMON_EXPORT XmlData { return; } - std::map<std::string, List*>::iterator list = lists.find(name); + std::map<Core::String, List*>::iterator list = lists.find(name); if(list != lists.end()) { xmlUnlinkNode(list->second->elementNode); @@ -285,19 +284,19 @@ class MAD_COMMON_EXPORT XmlData { return; } - std::set<std::string> getChildren() const { - std::set<std::string> childNames; + std::set<Core::String> getChildren() const { + std::set<Core::String> childNames; - for(std::map<std::string, Element*>::const_iterator it = elements.begin(); it != elements.end(); ++it) + for(std::map<Core::String, Element*>::const_iterator it = elements.begin(); it != elements.end(); ++it) childNames.insert(it->first); return childNames; } - std::set<std::string> getLists() const { - std::set<std::string> listNames; + std::set<Core::String> getLists() const { + std::set<Core::String> listNames; - for(std::map<std::string, List*>::const_iterator it = lists.begin(); it != lists.end(); ++it) + for(std::map<Core::String, List*>::const_iterator it = lists.begin(); it != lists.end(); ++it) listNames.insert(it->first); return listNames; @@ -468,32 +467,32 @@ class MAD_COMMON_EXPORT XmlData { xmlFreeDoc(doc); } - std::string getType() const; - void setType(const std::string &type); + Core::String getType() const; + void setType(const Core::String &type); template <typename T> - bool set(const std::string &name, T val) { + bool set(const Core::String &name, T val) { return entry->set(name, val); } template <typename T> - T get(const std::string &name) const { + T get(const Core::String &name) const { return entry->get<T>(name); } - List* createList(const std::string &name, bool unique = false) { + List* createList(const Core::String &name, bool unique = false) { return entry->createList(name, unique); } - List* getList(const std::string &name) { + List* getList(const Core::String &name) { return entry->getList(name); } - const List* getList(const std::string &name) const { + const List* getList(const Core::String &name) const { return entry->getList(name); } - void unset(const std::string &name) { + void unset(const Core::String &name) { entry->unset(name); } @@ -502,11 +501,11 @@ class MAD_COMMON_EXPORT XmlData { void toFile(const std::string &filename) const throw (Core::Exception); }; -template <> MAD_COMMON_EXPORT std::string XmlData::Entry::get<std::string>(const std::string &name) const; -template <> MAD_COMMON_EXPORT const std::string& XmlData::Entry::get<const std::string&>(const std::string &name) const; +template <> MAD_COMMON_EXPORT Core::String XmlData::Entry::get<Core::String>(const Core::String &name) const; +template <> MAD_COMMON_EXPORT const Core::String& XmlData::Entry::get<const Core::String&>(const Core::String &name) const; -template <> MAD_COMMON_EXPORT std::vector<boost::uint8_t> XmlData::Entry::get<std::vector<unsigned char> >(const std::string &name) const; -template <> MAD_COMMON_EXPORT const std::vector<boost::uint8_t>& XmlData::Entry::get<const std::vector<unsigned char>&>(const std::string &name) const; +template <> MAD_COMMON_EXPORT std::vector<boost::uint8_t> XmlData::Entry::get<std::vector<unsigned char> >(const Core::String &name) const; +template <> MAD_COMMON_EXPORT const std::vector<boost::uint8_t>& XmlData::Entry::get<const std::vector<unsigned char>&>(const Core::String &name) const; } } diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 9828f61..60a5a25 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -20,7 +20,7 @@ mad_library(Core LogManager.cpp LogManager.h Signals.h ThreadManager.cpp ThreadManager.h + String.cpp String.h Tokenizer.cpp Tokenizer.h - UnicodeString.cpp UnicodeString.h ) target_link_libraries(Core ${Boost_LIBRARIES} ${ICU_LIBRARIES}) diff --git a/src/Core/ConfigEntry.cpp b/src/Core/ConfigEntry.cpp index b587043..04ed08f 100644 --- a/src/Core/ConfigEntry.cpp +++ b/src/Core/ConfigEntry.cpp @@ -22,7 +22,7 @@ namespace Mad { namespace Core { -ConfigEntry::String& ConfigEntry::Entry::operator[] (std::size_t i) { +String& ConfigEntry::Entry::operator[] (std::size_t i) { try { return value.at(i); } @@ -32,7 +32,7 @@ ConfigEntry::String& ConfigEntry::Entry::operator[] (std::size_t i) { } } -const ConfigEntry::String& ConfigEntry::Entry::operator[] (std::size_t i) const { +const String& ConfigEntry::Entry::operator[] (std::size_t i) const { try { return value.at(i); } diff --git a/src/Core/ConfigEntry.h b/src/Core/ConfigEntry.h index d4cacc9..26e77d2 100644 --- a/src/Core/ConfigEntry.h +++ b/src/Core/ConfigEntry.h @@ -22,7 +22,7 @@ #include "export.h" -#include "UnicodeString.h" +#include "String.h" #include <stdexcept> #include <vector> @@ -32,16 +32,6 @@ namespace Core { class MAD_CORE_EXPORT ConfigEntry { public: - class String : public UnicodeString { - public: - String() {} - String(const UnicodeString &str) : UnicodeString(str) {} - - bool matches(const UnicodeString &str) const { - return (str.caseCompare(*this, 0) == 0); - } - }; - class MAD_CORE_EXPORT Entry { private: String key; @@ -51,7 +41,7 @@ class MAD_CORE_EXPORT ConfigEntry { public: Entry() {} - Entry(const std::vector<UnicodeString> &args) { + Entry(const std::vector<String> &args) { if(args.empty()) return; diff --git a/src/Core/ConfigManager.cpp b/src/Core/ConfigManager.cpp index 51d8647..d79ce32 100644 --- a/src/Core/ConfigManager.cpp +++ b/src/Core/ConfigManager.cpp @@ -26,6 +26,8 @@ #include <fstream> #include <stdexcept> +#include <iostream> + namespace Mad { namespace Core { @@ -55,9 +57,9 @@ bool ConfigManager::loadFile(const std::string &filename) { std::ifstream file(filename.c_str()); ConfigEntry entry; - UnicodeString line, input; + String line, input; UChar delim; - std::vector<UnicodeString> splitLine, lastConfigLine; + std::vector<String> splitLine, lastConfigLine; if(!file.good()) return false; diff --git a/src/Core/Exception.h b/src/Core/Exception.h index f12b3df..8e0342d 100644 --- a/src/Core/Exception.h +++ b/src/Core/Exception.h @@ -22,6 +22,8 @@ #include "export.h" +#include "String.h" + #include <exception> #include <string> diff --git a/src/Core/LogManager.cpp b/src/Core/LogManager.cpp index 4a4cc0d..c2a90de 100644 --- a/src/Core/LogManager.cpp +++ b/src/Core/LogManager.cpp @@ -42,13 +42,13 @@ void LogManager::ConsoleLogger::logMessageDirect(MessageCategory /*category*/, M } -LogManager::MessageLevel LogManager::parseLevel(const UnicodeString &str) throw (Exception) { - static const UnicodeString DEBUG_LEVEL("debug"); - static const UnicodeString VERBOSE_LEVEL("verbose"); - static const UnicodeString DEFAULT_LEVEL("default"); - static const UnicodeString WARNING_LEVEL("warning"); - static const UnicodeString ERROR_LEVEL("error"); - static const UnicodeString CRITICAL_LEVEL("critical"); +LogManager::MessageLevel LogManager::parseLevel(const String &str) throw (Exception) { + static const String DEBUG_LEVEL("debug"); + static const String VERBOSE_LEVEL("verbose"); + static const String DEFAULT_LEVEL("default"); + static const String WARNING_LEVEL("warning"); + static const String ERROR_LEVEL("error"); + static const String CRITICAL_LEVEL("critical"); if(str.isEmpty()) return Logger::LOG_DEFAULT; diff --git a/src/Core/LogManager.h b/src/Core/LogManager.h index 9b47a7e..4f7c500 100644 --- a/src/Core/LogManager.h +++ b/src/Core/LogManager.h @@ -25,7 +25,7 @@ #include "Configurable.h" #include "Exception.h" #include "Logger.h" -#include "UnicodeString.h" +#include "String.h" #include <queue> #include <set> @@ -100,7 +100,7 @@ class MAD_CORE_EXPORT LogManager : public Configurable { virtual void configFinished(); public: - static MessageLevel parseLevel(const UnicodeString &str) throw (Exception); + static MessageLevel parseLevel(const String &str) throw (Exception); void log(MessageCategory category, MessageLevel level, boost::posix_time::ptime timestamp, const std::string &message, const std::string &source = std::string()); diff --git a/src/Core/UnicodeString.cpp b/src/Core/String.cpp index ccace47..d9d357e 100644 --- a/src/Core/UnicodeString.cpp +++ b/src/Core/String.cpp @@ -1,5 +1,5 @@ /* - * UnicodeString.cpp + * String.cpp * * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> * @@ -17,12 +17,12 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "UnicodeString.h" +#include "String.h" namespace Mad { namespace Core { -boost::int32_t UnicodeString::findFirstOf(const UnicodeString &chars, boost::int32_t start) const { +boost::int32_t String::findFirstOf(const String &chars, boost::int32_t start) const { for(boost::int32_t i = start; i < length(); ++i) { if(chars.indexOf(charAt(i)) >= 0) return i; @@ -31,7 +31,7 @@ boost::int32_t UnicodeString::findFirstOf(const UnicodeString &chars, boost::int return -1; } -boost::int32_t UnicodeString::findFirstNotOf(const UnicodeString &chars, boost::int32_t start) const { +boost::int32_t String::findFirstNotOf(const String &chars, boost::int32_t start) const { for(boost::int32_t i = start; i < length(); ++i) { if(chars.indexOf(charAt(i)) < 0) return i; diff --git a/src/Core/String.h b/src/Core/String.h new file mode 100644 index 0000000..1c93902 --- /dev/null +++ b/src/Core/String.h @@ -0,0 +1,88 @@ +/* + * String.h + * + * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MAD_CORE_STRING_H_ +#define MAD_CORE_STRING_H_ + +#include "export.h" + +#include <ostream> +#include <string> +#include <boost/cstdint.hpp> +#include <boost/scoped_array.hpp> + +#define U_USING_ICU_NAMESPACE 0 +#include <unicode/unistr.h> + +namespace Mad { +namespace Core { + +class MAD_CORE_EXPORT String : public icu::UnicodeString { + private: + std::string extractCodepage(const char *codepage) const { + boost::uint32_t len = static_cast<boost::uint32_t>(icu::UnicodeString::extract(0, length(), 0, codepage)); + + boost::scoped_array<char> buf(new char[len]); + icu::UnicodeString::extract(0, length(), buf.get(), len, codepage); + + return std::string(buf.get(), len); + } + + public: + String() {} + String(const icu::UnicodeString &str) : icu::UnicodeString(str) {} + String(const char *str) : icu::UnicodeString(str, -1, US_INV) {} + + String substr(boost::int32_t start, boost::int32_t length = -1) const { + if(length < 0) + return icu::UnicodeString(*this, start); + else + return icu::UnicodeString(*this, start, length); + } + + bool matches(const String &str) const { + return (str.caseCompare(*this, 0) == 0); + } + + boost::int32_t findFirstOf(const String &chars, boost::int32_t start = 0) const; + boost::int32_t findFirstNotOf(const String &chars, boost::int32_t start = 0) const; + + std::string extract() const { + return extractCodepage(0); + } + + std::string extractUTF8() const { + return extractCodepage("UTF-8"); + } + + static String fromUTF8(const char *str) { + return icu::UnicodeString(str, "UTF-8"); + } +}; + +template<typename ElemType, typename Traits> +std::basic_ostream<ElemType, Traits>& operator<<(std::basic_ostream<ElemType, Traits> &stream, const String &string) { + stream << string.extract(); + return stream; +} + +} +} + +#endif /* MAD_CORE_STRING_H_ */ diff --git a/src/Core/Tokenizer.cpp b/src/Core/Tokenizer.cpp index 93c853a..9e0553e 100644 --- a/src/Core/Tokenizer.cpp +++ b/src/Core/Tokenizer.cpp @@ -24,11 +24,11 @@ namespace Mad { namespace Core { -const UnicodeString Tokenizer::delimiters(" \t\n\"'\\"); +const String Tokenizer::delimiters(" \t\n\"'\\"); -std::vector<UnicodeString> Tokenizer::split(const UnicodeString &str) { - std::vector<UnicodeString> ret; +std::vector<String> Tokenizer::split(const String &str) { + std::vector<String> ret; for(boost::int32_t s = 0; s < str.length();) { boost::int32_t index = str.findFirstOf(delimiters, s); @@ -55,16 +55,16 @@ std::vector<UnicodeString> Tokenizer::split(const UnicodeString &str) { return ret; } -bool Tokenizer::tokenize(const UnicodeString &str, std::vector<UnicodeString> &out) { - std::vector<UnicodeString> splitString = split(str); +bool Tokenizer::tokenize(const String &str, std::vector<String> &out) { + std::vector<String> splitString = split(str); bool singleQuotes = false, doubleQuotes = false, escape = false; - UnicodeString token; + String token; bool forceToken = false; out.clear(); - for(std::vector<UnicodeString>::iterator s = splitString.begin(); s != splitString.end(); ++s) { + for(std::vector<String>::iterator s = splitString.begin(); s != splitString.end(); ++s) { token += *s; escape = false; diff --git a/src/Core/Tokenizer.h b/src/Core/Tokenizer.h index f65d44c..fbeeeda 100644 --- a/src/Core/Tokenizer.h +++ b/src/Core/Tokenizer.h @@ -22,7 +22,7 @@ #include "export.h" -#include "UnicodeString.h" +#include "String.h" #include <vector> namespace Mad { @@ -30,14 +30,14 @@ namespace Core { class MAD_CORE_EXPORT Tokenizer { private: - static const UnicodeString delimiters; + static const String delimiters; Tokenizer(); - static std::vector<UnicodeString> split(const UnicodeString &str); + static std::vector<String> split(const String &str); public: - static bool tokenize(const UnicodeString &str, std::vector<UnicodeString> &out); + static bool tokenize(const String &str, std::vector<String> &out); }; } diff --git a/src/Core/UnicodeString.h b/src/Core/UnicodeString.h deleted file mode 100644 index aed53b6..0000000 --- a/src/Core/UnicodeString.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * UnicodeString.h - * - * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de> - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef MAD_CORE_UNICODESTRING_H_ -#define MAD_CORE_UNICODESTRING_H_ - -#include "export.h" - -#include <string> -#include <boost/cstdint.hpp> -#include <boost/scoped_array.hpp> - -#define U_USING_ICU_NAMESPACE 0 -#include <unicode/unistr.h> - -namespace Mad { -namespace Core { - -class MAD_CORE_EXPORT UnicodeString : public icu::UnicodeString { - public: - UnicodeString() {} - UnicodeString(const icu::UnicodeString &str) : icu::UnicodeString(str) {} - UnicodeString(const char *str) : icu::UnicodeString(str) {} - - UnicodeString substr(boost::int32_t start, boost::int32_t length = -1) const { - if(length < 0) - return icu::UnicodeString(*this, start); - else - return icu::UnicodeString(*this, start, length); - } - - boost::int32_t findFirstOf(const UnicodeString &chars, boost::int32_t start = 0) const; - boost::int32_t findFirstNotOf(const UnicodeString &chars, boost::int32_t start = 0) const; - - std::string extract() const { - boost::uint32_t len = (boost::uint32_t)icu::UnicodeString::extract(0, length(), (char*)0, 0u); - - boost::scoped_array<char> buf(new char[len]); - icu::UnicodeString::extract(0, length(), buf.get(), len); - - return std::string(buf.get(), len); - } -}; - -} -} - -#endif /* MAD_CORE_UNICODESTRING_H_ */ diff --git a/src/Daemon/Backends/NetworkLogger.h b/src/Daemon/Backends/NetworkLogger.h index 8c93036..2ee9fcf 100644 --- a/src/Daemon/Backends/NetworkLogger.h +++ b/src/Daemon/Backends/NetworkLogger.h @@ -36,7 +36,7 @@ class NetworkLogger : public Core::Logger { protected: virtual void logMessage(Core::Logger::MessageCategory category, Core::Logger::MessageLevel level, boost::posix_time::ptime messageTimestamp, const std::string &message, const std::string &source) { - boost::shared_ptr<Requests::LogRequest> request(new Requests::LogRequest(application, category, level, messageTimestamp, message, source)); + boost::shared_ptr<Requests::LogRequest> request(new Requests::LogRequest(application, category, level, messageTimestamp, message.c_str(), source.c_str())); application->getRequestManager()->sendRequest(connection, request); } diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp index e3d34e5..d0203e8 100644 --- a/src/Daemon/RequestHandlers/CommandRequestHandler.cpp +++ b/src/Daemon/RequestHandlers/CommandRequestHandler.cpp @@ -28,7 +28,7 @@ void CommandRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlDat if(!getConnection()->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - std::string command = packet->get<const std::string&>("command"); + Core::String command = packet->get<const Core::String&>("command"); if(command == "reboot") getApplication()->getSystemManager()->reboot(); diff --git a/src/Daemon/Requests/LogRequest.cpp b/src/Daemon/Requests/LogRequest.cpp index 0282649..1f1fdc8 100644 --- a/src/Daemon/Requests/LogRequest.cpp +++ b/src/Daemon/Requests/LogRequest.cpp @@ -32,7 +32,7 @@ void LogRequest::sendRequest() { packet.set("category", category); packet.set("level", level); - packet.set("timestamp", boost::posix_time::to_iso_string(messageTimestamp)); + packet.set("timestamp", boost::posix_time::to_iso_string(messageTimestamp).c_str()); packet.set("message", message); packet.set("source", source); diff --git a/src/Daemon/Requests/LogRequest.h b/src/Daemon/Requests/LogRequest.h index 2d8c91f..8630b45 100644 --- a/src/Daemon/Requests/LogRequest.h +++ b/src/Daemon/Requests/LogRequest.h @@ -34,14 +34,14 @@ class MAD_DAEMON_EXPORT LogRequest : public Common::Request { Core::Logger::MessageCategory category; Core::Logger::MessageLevel level; boost::posix_time::ptime messageTimestamp; - std::string message, source; + Core::String message, source; protected: virtual void sendRequest(); public: - LogRequest(Common::Application *application, Core::Logger::MessageCategory category0, Core::Logger::MessageLevel level0, boost::posix_time::ptime messageTimestamp0, const std::string &message0, - const std::string &source0) + LogRequest(Common::Application *application, Core::Logger::MessageCategory category0, Core::Logger::MessageLevel level0, boost::posix_time::ptime messageTimestamp0, const Core::String &message0, + const Core::String &source0) : Common::Request(application), category(category0), level(level0), messageTimestamp(messageTimestamp0), message(message0), source(source0) {} }; diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index 5836b32..f09f9e3 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -57,8 +57,8 @@ bool ConnectionManager::ServerConnection::disconnect() { return true; } -boost::shared_ptr<const Common::AuthContext> ConnectionManager::ServerConnection::authenticate(const std::string &method, - const std::string &subMethod, const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response) { +boost::shared_ptr<const Common::AuthContext> ConnectionManager::ServerConnection::authenticate(const Core::String &method, + const Core::String &subMethod, const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response) { if(!isIdentified()) type = CLIENT; @@ -151,12 +151,12 @@ bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool h else if(entry[0].getKey().matches("Daemon")) { if(entry[0].getSize() == 1) { if(entry[1].isEmpty()) { - daemonInfo.insert(std::make_pair(entry[0][0].extract(), Common::HostInfo(entry[0][0].extract()))); + daemonInfo.insert(std::make_pair(entry[0][0], Common::HostInfo(entry[0][0]))); return true; } else if(entry[1].getKey().matches("IpAddress") && entry[2].isEmpty()) { - daemonInfo[entry[0][0].extract()].setIP(entry[1][0].extract()); + daemonInfo[entry[0][0]].setIP(entry[1][0].extract()); return true; } @@ -231,10 +231,10 @@ ConnectionManager::~ConnectionManager() { application->getRequestManager()->unregisterPacketType("GetStatus"); } -boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(const std::string &name) const throw (Core::Exception) { +boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(const Core::String &name) const throw (Core::Exception) { - std::map<std::string, Common::HostInfo>::const_iterator hostIt = daemonInfo.find(name); + std::map<Core::String, Common::HostInfo>::const_iterator hostIt = daemonInfo.find(name); if(hostIt == daemonInfo.end()) throw Core::Exception(Core::Exception::UNKNOWN_DAEMON); @@ -251,7 +251,7 @@ boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(con throw Core::Exception(Core::Exception::NOT_AVAILABLE); } -std::string ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Core::Exception) { +Core::String ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Core::Exception) { const ServerConnection *connection = dynamic_cast<const ServerConnection*>(con); if(connection && connection->getConnectionType() == ServerConnection::DAEMON) @@ -260,7 +260,7 @@ std::string ConnectionManager::getDaemonName(const Common::Connection *con) cons throw Core::Exception(Core::Exception::UNKNOWN_DAEMON); } -void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Core::Exception) { +void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const Core::String &name) throw (Core::Exception) { // TODO Logging ServerConnection *connection = dynamic_cast<ServerConnection*>(con); @@ -288,8 +288,8 @@ void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const updateState(hostInfo, Common::HostInfo::RUNNING); } -boost::shared_ptr<const Common::AuthContext> ConnectionManager::authenticateConnection(Common::Connection *con, const std::string &method, - const std::string &subMethod, const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response) { +boost::shared_ptr<const Common::AuthContext> ConnectionManager::authenticateConnection(Common::Connection *con, const Core::String &method, + const Core::String &subMethod, const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response) { // TODO Logging ServerConnection *connection = dynamic_cast<ServerConnection*>(con); @@ -306,7 +306,7 @@ boost::shared_ptr<const Common::AuthContext> ConnectionManager::authenticateConn std::vector<Common::HostInfo> ConnectionManager::getDaemonList() const { std::vector<Common::HostInfo> ret; - for(std::map<std::string,Common::HostInfo>::const_iterator daemon = daemonInfo.begin(); daemon != daemonInfo.end(); ++daemon) { + for(std::map<Core::String,Common::HostInfo>::const_iterator daemon = daemonInfo.begin(); daemon != daemonInfo.end(); ++daemon) { ret.push_back(daemon->second); } diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h index 8c989b9..dab1892 100644 --- a/src/Server/ConnectionManager.h +++ b/src/Server/ConnectionManager.h @@ -99,8 +99,8 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b return (authContext.get() != 0 && authContext->isAuthenticated()); } - boost::shared_ptr<const Common::AuthContext> authenticate(const std::string &method, const std::string &subMethod, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response); + boost::shared_ptr<const Common::AuthContext> authenticate(const Core::String &method, const Core::String &subMethod, + const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response); }; friend class Application; @@ -114,7 +114,7 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b std::set<boost::shared_ptr<ServerConnection> > connections; - std::map<std::string, Common::HostInfo> daemonInfo; + std::map<Core::String, Common::HostInfo> daemonInfo; boost::shared_ptr<Common::RequestHandlerGroup> connectionRequestHandlerGroup; boost::shared_ptr<Common::RequestHandlerGroup> daemonRequestHandlerGroup; @@ -135,13 +135,13 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b virtual void configFinished(); public: - boost::shared_ptr<Common::Connection> getDaemonConnection(const std::string &name) const throw (Core::Exception); - std::string getDaemonName(const Common::Connection *con) const throw (Core::Exception); + boost::shared_ptr<Common::Connection> getDaemonConnection(const Core::String &name) const throw (Core::Exception); + Core::String getDaemonName(const Common::Connection *con) const throw (Core::Exception); - void identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Core::Exception); + void identifyDaemonConnection(Common::Connection *con, const Core::String &name) throw (Core::Exception); - boost::shared_ptr<const Common::AuthContext> authenticateConnection(Common::Connection *con, const std::string &method, const std::string &subMethod, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response); + boost::shared_ptr<const Common::AuthContext> authenticateConnection(Common::Connection *con, const Core::String &method, const Core::String &subMethod, + const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response); std::vector<Common::HostInfo> getDaemonList() const; }; diff --git a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp index 1348541..d446485 100644 --- a/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/ConnectionRequestHandlerGroup.cpp @@ -37,17 +37,17 @@ void ConnectionRequestHandlerGroup::handleAuthMethodRequest(boost::shared_ptr<co Common::XmlData::List *list = ret->createList("methods"); - std::set<std::string> methods = application->getAuthManager()->getMethods(); + std::set<Core::String> methods = application->getAuthManager()->getMethods(); - for(std::set<std::string>::iterator method = methods.begin(); method != methods.end(); ++method) { + for(std::set<Core::String>::iterator method = methods.begin(); method != methods.end(); ++method) { Common::XmlData::List::iterator entry = list->addEntry(); entry->set("name", *method); Common::XmlData::List *subList = entry->createList("subMethods"); - std::vector<std::string> subMethods = application->getAuthManager()->getSubMethods(*method); + std::vector<Core::String> subMethods = application->getAuthManager()->getSubMethods(*method); - for(std::vector<std::string>::iterator subMethod = subMethods.begin(); subMethod != subMethods.end(); ++subMethod) { + for(std::vector<Core::String>::iterator subMethod = subMethods.begin(); subMethod != subMethods.end(); ++subMethod) { Common::XmlData::List::iterator subEntry = subList->addEntry(); subEntry->set("name", *subMethod); @@ -59,8 +59,8 @@ void ConnectionRequestHandlerGroup::handleAuthRequest(boost::shared_ptr<const Co std::vector<boost::uint8_t> response; boost::shared_ptr<const Common::AuthContext> authContext = application->getConnectionManager()->authenticateConnection(connection, - packet->get<const std::string&>("method"), packet->get<const std::string&>("subMethod"), - packet->get<const std::string&>("user"), packet->get<const std::vector<boost::uint8_t>&>("data"), + packet->get<const Core::String&>("method"), packet->get<const Core::String&>("subMethod"), + packet->get<const Core::String&>("user"), packet->get<const std::vector<boost::uint8_t>&>("data"), response); if(!response.empty()) @@ -86,13 +86,13 @@ void ConnectionRequestHandlerGroup::handleDaemonListRequest(boost::shared_ptr<co Common::XmlData::List::iterator entry = list->addEntry(); entry->set("name", daemon->getName()); - entry->set("address", daemon->getIP()); + entry->set("address", daemon->getIP().c_str()); entry->set("state", daemon->getState()); } } void ConnectionRequestHandlerGroup::handleIdentifyRequest(boost::shared_ptr<const Common::XmlData> packet, Common::XmlData *ret, Common::Connection *connection) { - application->getConnectionManager()->identifyDaemonConnection(connection, packet->get<const std::string&>("hostname")); + application->getConnectionManager()->identifyDaemonConnection(connection, packet->get<const Core::String&>("hostname")); ret->setType("OK"); } @@ -102,10 +102,10 @@ void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptr<const Com boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - const std::string ×tr = packet->get<const std::string&>("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get<const Core::String&>("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -115,8 +115,8 @@ void ConnectionRequestHandlerGroup::handleLogRequest(boost::shared_ptr<const Com static_cast<Core::Logger::MessageCategory>(packet->get<long>("category")), static_cast<Core::Logger::MessageLevel>(packet->get<long>("level")), timestamp, - packet->get<const std::string&>("message"), - application->getConnectionManager()->getDaemonName(connection)); + packet->get<const Core::String&>("message").extract(), + application->getConnectionManager()->getDaemonName(connection).extract()); } catch(Core::Exception &e) { application->logf(Core::Logger::LOG_ERROR, "Can't determine daemon name: %s", e.what()); diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp index e258b89..8f6909e 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp @@ -50,11 +50,11 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared try { ConnectionManager *connectionManager = dynamic_cast<Application&>(*getApplication()).getConnectionManager(); - boost::shared_ptr<Common::Connection> daemonCon = connectionManager->getDaemonConnection(packet->get<const std::string&>("daemon")); + boost::shared_ptr<Common::Connection> daemonCon = connectionManager->getDaemonConnection(packet->get<const Core::String&>("daemon")); boost::shared_ptr<Common::Request> request; if(type == "DaemonCommand") - request.reset(new Requests::CommandRequest(getApplication(), (packet->get<const std::string&>("command") == "reboot"))); + request.reset(new Requests::CommandRequest(getApplication(), packet->get<const Core::String&>("command").matches("reboot"))); else if(type == "DaemonFSInfo") request.reset(new Common::Requests::FSInfoRequest(getApplication())); else // type == "GetDaemonStatus" @@ -69,7 +69,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared ret.set("ErrorCode", e.getErrorCode()); ret.set("SubCode", e.getSubCode()); ret.set("SubSubCode", e.getSubSubCode()); - ret.set("Where", e.getWhere()); + ret.set("Where", e.getWhere().c_str()); sendPacket(ret); signalFinished(); @@ -83,7 +83,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::requestFinished(boost::sha ret.set("ErrorCode", error.getErrorCode()); ret.set("SubCode", error.getSubCode()); ret.set("SubSubCode", error.getSubSubCode()); - ret.set("Where", error.getWhere()); + ret.set("Where", error.getWhere().c_str()); sendPacket(ret); } @@ -101,7 +101,7 @@ DaemonRequestHandlerGroup::DaemonRequestHandlerGroup() { types.insert("GetDaemonStatus"); } -boost::shared_ptr<Common::RequestHandler> DaemonRequestHandlerGroup::createRequestHandler(Common::Application *application, const std::string &type) { +boost::shared_ptr<Common::RequestHandler> DaemonRequestHandlerGroup::createRequestHandler(Common::Application *application, const Core::String &type) { if(types.find(type) == types.end()) return boost::shared_ptr<Common::RequestHandler>(); else diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h index 48d8e2c..613e8f3 100644 --- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h +++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h @@ -35,7 +35,7 @@ class MAD_SERVER_EXPORT DaemonRequestHandlerGroup : public Common::RequestHandle private: class DaemonRequestHandler : public Common::RequestHandler { private: - std::string type; + Core::String type; void requestFinished(boost::shared_ptr<const Common::XmlData> packet, Core::Exception error); @@ -43,20 +43,20 @@ class MAD_SERVER_EXPORT DaemonRequestHandlerGroup : public Common::RequestHandle virtual void handlePacket(boost::shared_ptr<const Common::XmlData> packet); public: - DaemonRequestHandler(Common::Application *application, const std::string &type0) + DaemonRequestHandler(Common::Application *application, const Core::String &type0) : Common::RequestHandler(application), type(type0) {} }; - std::set<std::string> types; + std::set<Core::String> types; public: DaemonRequestHandlerGroup(); - virtual const std::set<std::string>& getPacketTypes() { + virtual const std::set<Core::String>& getPacketTypes() { return types; } - virtual boost::shared_ptr<Common::RequestHandler> createRequestHandler(Common::Application *application, const std::string &type); + virtual boost::shared_ptr<Common::RequestHandler> createRequestHandler(Common::Application *application, const Core::String &type); }; } diff --git a/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp index 05aadf8..be9cc58 100644 --- a/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp +++ b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.cpp @@ -56,11 +56,11 @@ void UserListDiffUploadRequestHandler::handlePacket(boost::shared_ptr<const Comm UserListManager *userListManager = dynamic_cast<Application*>(getApplication())->getUserListManager(); - if(name.empty()) { // Request - name = packet->get<const std::string&>("name"); + if(name.isEmpty()) { // Request + name = packet->get<const Core::String&>("name"); - if(name.empty()) - name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()); + if(name.isEmpty()) + name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()).c_str(); Common::XmlData ret; ret.setType("Continue"); diff --git a/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h index 3d74253..15196b5 100644 --- a/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h +++ b/src/Server/RequestHandlers/UserListDiffUploadRequestHandler.h @@ -31,7 +31,7 @@ namespace RequestHandlers { class UserListDiffUploadRequestHandler : public Common::RequestHandler { private: - std::string name; + Core::String name; protected: virtual void handlePacket(boost::shared_ptr<const Common::XmlData> packet); diff --git a/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp index bb18194..cfe2a28 100644 --- a/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserListRequestHandlerGroup.cpp @@ -31,12 +31,12 @@ void UserListRequestHandlerGroup::handleUserListListRequest(boost::shared_ptr<co if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - const std::set<std::string> &userLists = application->getUserListManager()->getUserLists(); + const std::set<Core::String> &userLists = application->getUserListManager()->getUserLists(); ret->setType("OK"); Common::XmlData::List *list = ret->createList("userLists"); - for(std::set<std::string>::const_iterator userList = userLists.begin(); userList != userLists.end(); ++userList) { + for(std::set<Core::String>::const_iterator userList = userLists.begin(); userList != userLists.end(); ++userList) { Common::XmlData::List::iterator entry = list->addEntry(); entry->set("name", *userList); @@ -48,7 +48,7 @@ void UserListRequestHandlerGroup::handleUserListDownloadRequest(boost::shared_pt if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::shared_ptr<Common::UserLists::UserList> userList = application->getUserListManager()->loadUserList(packet->get<const std::string&>("name")); + boost::shared_ptr<Common::UserLists::UserList> userList = application->getUserListManager()->loadUserList(packet->get<const Core::String&>("name")); if(!userList) throw(Core::Exception(Core::Exception::NOT_FOUND)); @@ -60,7 +60,7 @@ void UserListRequestHandlerGroup::handleUserListCopyRequest(boost::shared_ptr<co if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->copyUserList(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); + application->getUserListManager()->copyUserList(packet->get<const Core::String&>("fromName"), packet->get<const Core::String&>("toName")); ret->setType("OK"); } @@ -69,7 +69,7 @@ void UserListRequestHandlerGroup::handleUserListRenameRequest(boost::shared_ptr< if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->renameUserList(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); + application->getUserListManager()->renameUserList(packet->get<const Core::String&>("fromName"), packet->get<const Core::String&>("toName")); ret->setType("OK"); } @@ -78,7 +78,7 @@ void UserListRequestHandlerGroup::handleUserListRemoveRequest(boost::shared_ptr< if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->removeUserList(packet->get<const std::string&>("name")); + application->getUserListManager()->removeUserList(packet->get<const Core::String&>("name")); ret->setType("OK"); } @@ -88,12 +88,12 @@ void UserListRequestHandlerGroup::handleUserListDiffListRequest(boost::shared_pt if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - const std::set<std::string> &userListDiffs = application->getUserListManager()->getUserListDiffs(); + const std::set<Core::String> &userListDiffs = application->getUserListManager()->getUserListDiffs(); ret->setType("OK"); Common::XmlData::List *list = ret->createList("userListDiffs"); - for(std::set<std::string>::const_iterator diff = userListDiffs.begin(); diff != userListDiffs.end(); ++diff) { + for(std::set<Core::String>::const_iterator diff = userListDiffs.begin(); diff != userListDiffs.end(); ++diff) { Common::XmlData::List::iterator entry = list->addEntry(); entry->set("name", *diff); @@ -105,7 +105,7 @@ void UserListRequestHandlerGroup::handleUserListDiffDownloadRequest(boost::share if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - boost::shared_ptr<Common::UserLists::UserListDiff> diff = application->getUserListManager()->loadUserListDiff(packet->get<const std::string&>("name")); + boost::shared_ptr<Common::UserLists::UserListDiff> diff = application->getUserListManager()->loadUserListDiff(packet->get<const Core::String&>("name")); if(!diff) throw(Core::Exception(Core::Exception::NOT_FOUND)); @@ -117,7 +117,7 @@ void UserListRequestHandlerGroup::handleUserListDiffCopyRequest(boost::shared_pt if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->copyUserListDiff(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); + application->getUserListManager()->copyUserListDiff(packet->get<const Core::String&>("fromName"), packet->get<const Core::String&>("toName")); ret->setType("OK"); } @@ -126,7 +126,7 @@ void UserListRequestHandlerGroup::handleUserListDiffRenameRequest(boost::shared_ if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->renameUserListDiff(packet->get<const std::string&>("fromName"), packet->get<const std::string&>("toName")); + application->getUserListManager()->renameUserListDiff(packet->get<const Core::String&>("fromName"), packet->get<const Core::String&>("toName")); ret->setType("OK"); } @@ -135,7 +135,7 @@ void UserListRequestHandlerGroup::handleUserListDiffRemoveRequest(boost::shared_ if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserListManager()->removeUserListDiff(packet->get<const std::string&>("name")); + application->getUserListManager()->removeUserListDiff(packet->get<const Core::String&>("name")); ret->setType("OK"); } diff --git a/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp b/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp index 307863a..9de6257 100644 --- a/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp +++ b/src/Server/RequestHandlers/UserListUploadRequestHandler.cpp @@ -57,11 +57,11 @@ void UserListUploadRequestHandler::handlePacket(boost::shared_ptr<const Common:: UserListManager *userListManager = dynamic_cast<Application*>(getApplication())->getUserListManager(); - if(name.empty()) { // Request - name = packet->get<const std::string&>("name"); + if(name.isEmpty()) { // Request + name = packet->get<const Core::String&>("name"); - if(name.empty()) - name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()); + if(name.isEmpty()) + name = boost::posix_time::to_simple_string(boost::posix_time::second_clock::universal_time()).c_str(); Common::XmlData ret; ret.setType("Continue"); diff --git a/src/Server/RequestHandlers/UserListUploadRequestHandler.h b/src/Server/RequestHandlers/UserListUploadRequestHandler.h index 4a20a4c..46672a5 100644 --- a/src/Server/RequestHandlers/UserListUploadRequestHandler.h +++ b/src/Server/RequestHandlers/UserListUploadRequestHandler.h @@ -31,7 +31,7 @@ namespace RequestHandlers { class UserListUploadRequestHandler : public Common::RequestHandler { private: - std::string name; + Core::String name; protected: virtual void handlePacket(boost::shared_ptr<const Common::XmlData> packet); diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index 1d99c2e..f43ec86 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -36,10 +36,10 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Comm boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - const std::string ×tr = packet->get<const std::string&>("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get<const Core::String&>("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -49,7 +49,7 @@ void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Comm ret->setType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(users) { Common::XmlData::List *list = ret->createList("users"); @@ -72,10 +72,10 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - const std::string ×tr = packet->get<const std::string&>("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get<const Core::String&>("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -86,12 +86,12 @@ void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Comm if(uid) info = application->getUserManager()->getUserInfo(uid, ×tamp); else - info = application->getUserManager()->getUserInfoByName(packet->get<const std::string&>("name"), ×tamp); + info = application->getUserManager()->getUserInfoByName(packet->get<const Core::String&>("name"), ×tamp); ret->setType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(info) { ret->set("uid", info->getUid()); @@ -108,10 +108,10 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - const std::string ×tr = packet->get<const std::string&>("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get<const Core::String&>("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -121,7 +121,7 @@ void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const ret->setType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(groups) { Common::XmlData::List *list = ret->createList("groups"); @@ -141,10 +141,10 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Com boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - const std::string ×tr = packet->get<const std::string&>("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get<const Core::String&>("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -154,7 +154,7 @@ void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Com ret->setType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(groups) { Common::XmlData::List *list = ret->createList("groups"); @@ -175,10 +175,10 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Com boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - const std::string ×tr = packet->get<const std::string&>("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get<const Core::String&>("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -189,12 +189,12 @@ void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Com if(gid) info = application->getUserManager()->getGroupInfo(gid, ×tamp); else - info = application->getUserManager()->getGroupInfoByName(packet->get<const std::string&>("name"), ×tamp); + info = application->getUserManager()->getGroupInfoByName(packet->get<const Core::String&>("name"), ×tamp); ret->setType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(info) { ret->set("gid", info->getGid()); @@ -209,10 +209,10 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - const std::string ×tr = packet->get<const std::string&>("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get<const Core::String&>("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -222,7 +222,7 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const ret->setType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); Common::XmlData::List *list = ret->createList("users"); @@ -240,10 +240,10 @@ void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptr<c boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time); - const std::string ×tr = packet->get<const std::string&>("timestamp"); - if(!timestr.empty()) { + const Core::String ×tr = packet->get<const Core::String&>("timestamp"); + if(!timestr.isEmpty()) { try { - timestamp = boost::posix_time::from_iso_string(timestr); + timestamp = boost::posix_time::from_iso_string(timestr.extract()); } catch(...) {} } @@ -253,7 +253,7 @@ void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptr<c ret->setType("OK"); if(!timestamp.is_not_a_date_time()) - ret->set("timestamp", boost::posix_time::to_iso_string(timestamp)); + ret->set("timestamp", boost::posix_time::to_iso_string(timestamp).c_str()); if(userGroups) { Common::XmlData::List *list = ret->createList("userGroupList"); @@ -273,9 +273,9 @@ void UserRequestHandlerGroup::handleUserInfoCheckRequest(boost::shared_ptr<const if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - Common::UserInfo userInfo(packet->get<unsigned long>("uid"), packet->get<const std::string&>("username")); + Common::UserInfo userInfo(packet->get<unsigned long>("uid"), packet->get<const Core::String&>("username")); userInfo.setGid(packet->get<unsigned long>("gid")); - userInfo.setFullName(packet->get<const std::string&>("fullName")); + userInfo.setFullName(packet->get<const Core::String&>("fullName")); application->getUserManager()->checkUserInfo(userInfo); @@ -287,9 +287,9 @@ void UserRequestHandlerGroup::handleUserAddRequest(boost::shared_ptr<const Commo if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - Common::UserInfo userInfo(packet->get<unsigned long>("uid"), packet->get<const std::string&>("username")); + Common::UserInfo userInfo(packet->get<unsigned long>("uid"), packet->get<const Core::String&>("username")); userInfo.setGid(packet->get<unsigned long>("gid")); - userInfo.setFullName(packet->get<const std::string&>("fullName")); + userInfo.setFullName(packet->get<const Core::String&>("fullName")); application->getUserManager()->addUser(userInfo); @@ -301,9 +301,9 @@ void UserRequestHandlerGroup::handleUserUpdateRequest(boost::shared_ptr<const Co if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - Common::UserInfo userInfo(packet->get<unsigned long>("uid"), packet->get<const std::string&>("username")); + Common::UserInfo userInfo(packet->get<unsigned long>("uid"), packet->get<const Core::String&>("username")); userInfo.setGid(packet->get<unsigned long>("gid")); - userInfo.setFullName(packet->get<const std::string&>("fullName")); + userInfo.setFullName(packet->get<const Core::String&>("fullName")); application->getUserManager()->updateUser(packet->get<unsigned long>("origUid"), userInfo); @@ -326,7 +326,7 @@ void UserRequestHandlerGroup::handleGroupInfoCheckRequest(boost::shared_ptr<cons if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserManager()->checkGroupInfo(Common::GroupInfo(packet->get<unsigned long>("gid"), packet->get<const std::string&>("name"))); + application->getUserManager()->checkGroupInfo(Common::GroupInfo(packet->get<unsigned long>("gid"), packet->get<const Core::String&>("name"))); ret->setType("OK"); } @@ -336,7 +336,7 @@ void UserRequestHandlerGroup::handleGroupAddRequest(boost::shared_ptr<const Comm if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserManager()->addGroup(Common::GroupInfo(packet->get<unsigned long>("gid"), packet->get<const std::string&>("name"))); + application->getUserManager()->addGroup(Common::GroupInfo(packet->get<unsigned long>("gid"), packet->get<const Core::String&>("name"))); ret->setType("OK"); } @@ -347,7 +347,7 @@ void UserRequestHandlerGroup::handleGroupUpdateRequest(boost::shared_ptr<const C throw(Core::Exception(Core::Exception::PERMISSION)); application->getUserManager()->updateGroup(packet->get<unsigned long>("origGid"), - Common::GroupInfo(packet->get<unsigned long>("gid"), packet->get<const std::string&>("name"))); + Common::GroupInfo(packet->get<unsigned long>("gid"), packet->get<const Core::String&>("name"))); ret->setType("OK"); } @@ -388,7 +388,7 @@ void UserRequestHandlerGroup::handlePasswordSetRequest(boost::shared_ptr<const C if(!connection->isAuthenticated()) throw(Core::Exception(Core::Exception::PERMISSION)); - application->getUserManager()->setPassword(packet->get<unsigned long>("uid"), packet->get<const std::string&>("password")); + application->getUserManager()->setPassword(packet->get<unsigned long>("uid"), packet->get<const Core::String&>("password")); ret->setType("OK"); } diff --git a/src/Server/Requests/DaemonStateUpdateRequest.h b/src/Server/Requests/DaemonStateUpdateRequest.h index 862e8ac..2fd3242 100644 --- a/src/Server/Requests/DaemonStateUpdateRequest.h +++ b/src/Server/Requests/DaemonStateUpdateRequest.h @@ -31,14 +31,14 @@ namespace Requests { class MAD_SERVER_EXPORT DaemonStateUpdateRequest : public Common::Request { private: - std::string name; + Core::String name; Common::HostInfo::State state; protected: virtual void sendRequest(); public: - DaemonStateUpdateRequest(Common::Application *application, const std::string &name0, Common::HostInfo::State state0) + DaemonStateUpdateRequest(Common::Application *application, const Core::String &name0, Common::HostInfo::State state0) : Common::Request(application), name(name0), state(state0) {} }; diff --git a/src/Server/UserListManager.cpp b/src/Server/UserListManager.cpp index d520c96..a8794fe 100644 --- a/src/Server/UserListManager.cpp +++ b/src/Server/UserListManager.cpp @@ -54,11 +54,11 @@ void UserListManager::configFinished() { application->getRequestManager()->registerPacketType<RequestHandlers::UserListDiffUploadRequestHandler>("UploadUserListDiff"); } -bool UserListManager::existsUserList(const std::string &name) { +bool UserListManager::existsUserList(const Core::String &name) { return application->getStorageManager()->exists("UserList", name); } -boost::shared_ptr<Common::UserLists::UserList> UserListManager::loadUserList(const std::string &name) { +boost::shared_ptr<Common::UserLists::UserList> UserListManager::loadUserList(const Core::String &name) { boost::shared_ptr<Common::XmlData> data = application->getStorageManager()->load("UserList", name); if(!data) @@ -67,31 +67,31 @@ boost::shared_ptr<Common::UserLists::UserList> UserListManager::loadUserList(con return Common::UserLists::Util::deserializeUserList(data.get()); } -void UserListManager::storeUserList(const std::string &name, const Common::UserLists::UserList *list) { +void UserListManager::storeUserList(const Core::String &name, const Common::UserLists::UserList *list) { Common::XmlData data; Common::UserLists::Util::serializeUserList(list, &data); application->getStorageManager()->store("UserList", name, &data); } -void UserListManager::copyUserList(const std::string &fromName, const std::string &toName) { +void UserListManager::copyUserList(const Core::String &fromName, const Core::String &toName) { application->getStorageManager()->copy("UserList", fromName, toName); } -void UserListManager::renameUserList(const std::string &fromName, const std::string &toName) { +void UserListManager::renameUserList(const Core::String &fromName, const Core::String &toName) { application->getStorageManager()->rename("UserList", fromName, toName); } -void UserListManager::removeUserList(const std::string &name) { +void UserListManager::removeUserList(const Core::String &name) { application->getStorageManager()->remove("UserList", name); } -bool UserListManager::existsUserListDiff(const std::string &name) { +bool UserListManager::existsUserListDiff(const Core::String &name) { return application->getStorageManager()->exists("UserListDiff", name); } -boost::shared_ptr<Common::UserLists::UserListDiff> UserListManager::loadUserListDiff(const std::string &name) { +boost::shared_ptr<Common::UserLists::UserListDiff> UserListManager::loadUserListDiff(const Core::String &name) { boost::shared_ptr<Common::XmlData> data = application->getStorageManager()->load("UserListDiff", name); if(!data) @@ -100,22 +100,22 @@ boost::shared_ptr<Common::UserLists::UserListDiff> UserListManager::loadUserList return Common::UserLists::Util::deserializeUserListDiff(data.get()); } -void UserListManager::storeUserListDiff(const std::string &name, const Common::UserLists::UserListDiff *list) { +void UserListManager::storeUserListDiff(const Core::String &name, const Common::UserLists::UserListDiff *list) { Common::XmlData data; Common::UserLists::Util::serializeUserListDiff(list, &data); application->getStorageManager()->store("UserListDiff", name, &data); } -void UserListManager::copyUserListDiff(const std::string &fromName, const std::string &toName) { +void UserListManager::copyUserListDiff(const Core::String &fromName, const Core::String &toName) { application->getStorageManager()->copy("UserListDiff", fromName, toName); } -void UserListManager::renameUserListDiff(const std::string &fromName, const std::string &toName) { +void UserListManager::renameUserListDiff(const Core::String &fromName, const Core::String &toName) { application->getStorageManager()->rename("UserListDiff", fromName, toName); } -void UserListManager::removeUserListDiff(const std::string &name) { +void UserListManager::removeUserListDiff(const Core::String &name) { application->getStorageManager()->remove("UserListDiff", name); } @@ -127,7 +127,7 @@ boost::shared_ptr<Common::UserLists::UserList> UserListManager::getCurrentUserLi for(std::map<unsigned long, Common::UserInfo>::const_iterator user = userList->begin(); user != userList->end(); ++user) { std::map<unsigned long, Common::GroupInfo>::const_iterator group = groupList->find(user->second.getGid()); - std::string groupname; + Core::String groupname; if(group != groupList->end()) { groupname = group->second.getName(); @@ -135,7 +135,7 @@ boost::shared_ptr<Common::UserLists::UserList> UserListManager::getCurrentUserLi else { std::ostringstream stream; stream << user->second.getGid(); - groupname = stream.str(); + groupname = stream.str().c_str(); } Common::UserLists::UserListEntry entry(user->second.getUsername(), groupname); diff --git a/src/Server/UserListManager.h b/src/Server/UserListManager.h index 1651d42..65e8fdf 100644 --- a/src/Server/UserListManager.h +++ b/src/Server/UserListManager.h @@ -23,6 +23,7 @@ #include "export.h" #include <Core/Configurable.h> +#include <Core/String.h> #include <boost/noncopyable.hpp> #include <boost/shared_ptr.hpp> @@ -52,8 +53,8 @@ class MAD_SERVER_EXPORT UserListManager : private Core::Configurable, private bo boost::shared_ptr<RequestHandlers::UserListRequestHandlerGroup> requestHandlerGroup; - std::set<std::string> userLists; - std::set<std::string> userListDiffs; + std::set<Core::String> userLists; + std::set<Core::String> userListDiffs; protected: virtual void configFinished(); @@ -64,27 +65,27 @@ class MAD_SERVER_EXPORT UserListManager : private Core::Configurable, private bo UserListManager(Application *application0); virtual ~UserListManager(); - const std::set<std::string>& getUserLists() const { + const std::set<Core::String>& getUserLists() const { return userLists; } - bool existsUserList(const std::string &name); - boost::shared_ptr<Common::UserLists::UserList> loadUserList(const std::string &name); - void storeUserList(const std::string &name, const Common::UserLists::UserList *list); - void copyUserList(const std::string &fromName, const std::string &toName); - void renameUserList(const std::string &fromName, const std::string &toName); - void removeUserList(const std::string &name); + bool existsUserList(const Core::String &name); + boost::shared_ptr<Common::UserLists::UserList> loadUserList(const Core::String &name); + void storeUserList(const Core::String &name, const Common::UserLists::UserList *list); + void copyUserList(const Core::String &fromName, const Core::String &toName); + void renameUserList(const Core::String &fromName, const Core::String &toName); + void removeUserList(const Core::String &name); - const std::set<std::string>& getUserListDiffs() const { + const std::set<Core::String>& getUserListDiffs() const { return userListDiffs; } - bool existsUserListDiff(const std::string &name); - boost::shared_ptr<Common::UserLists::UserListDiff> loadUserListDiff(const std::string &name); - void storeUserListDiff(const std::string &name, const Common::UserLists::UserListDiff *list); - void copyUserListDiff(const std::string &fromName, const std::string &toName); - void renameUserListDiff(const std::string &fromName, const std::string &toName); - void removeUserListDiff(const std::string &name); + bool existsUserListDiff(const Core::String &name); + boost::shared_ptr<Common::UserLists::UserListDiff> loadUserListDiff(const Core::String &name); + void storeUserListDiff(const Core::String &name, const Common::UserLists::UserListDiff *list); + void copyUserListDiff(const Core::String &fromName, const Core::String &toName); + void renameUserListDiff(const Core::String &fromName, const Core::String &toName); + void removeUserListDiff(const Core::String &name); boost::shared_ptr<Common::UserLists::UserList> getCurrentUserList(); }; diff --git a/src/madc.cpp b/src/madc.cpp index eaa1613..88060e9 100644 --- a/src/madc.cpp +++ b/src/madc.cpp @@ -95,20 +95,21 @@ int main(int argc, char *argv[]) { std::cerr << " connected." << std::endl << std::endl; { - std::string username, password; + std::string username; + Core::String password; std::cerr << "Login: " << std::flush; std::getline(std::cin, username); password = Client::PasswordReader::readPassword("Password: "); try { - Client::Authenticators::ChallengeResponseAuthenticator::authenticate(&application, connection, username, password); + Client::Authenticators::ChallengeResponseAuthenticator::authenticate(&application, connection, username.c_str(), password); } catch(Core::Exception e) { if(e.getErrorCode() != Core::Exception::NOT_AVAILABLE) throw e; - Client::Authenticators::PasswordAuthenticator::authenticate(&application, connection, username, password); + Client::Authenticators::PasswordAuthenticator::authenticate(&application, connection, username.c_str(), password); } } @@ -143,7 +144,8 @@ int main(int argc, char *argv[]) { commandParser.requestDisconnect(); } else if(*cmd) { - commandParser.parse(cmd); + // TODO Use locale + commandParser.parse(Core::String::fromUTF8(cmd)); history(hist, &histEv, H_ENTER, cmd); } else continue; diff --git a/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.cpp b/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.cpp index fc6bd47..0785b7d 100644 --- a/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.cpp +++ b/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.cpp @@ -27,7 +27,7 @@ namespace Mad { namespace Modules { namespace AuthBackendChallengeResponse { -const std::string AuthBackendChallengeResponse::methodName = "Challenge-Response"; +const Core::String AuthBackendChallengeResponse::methodName = "Challenge-Response"; AuthBackendChallengeResponse::AuthContextChallengeResponse::AuthContextChallengeResponse(AuthBackendChallengeResponse *backend) : authenticated(false) { challenge.reserve(32); @@ -38,13 +38,13 @@ AuthBackendChallengeResponse::AuthContextChallengeResponse::AuthContextChallenge challenge.push_back(backend->randomGenerator()); } -boost::shared_ptr<Common::AuthContext> AuthBackendChallengeResponse::authenticate(boost::shared_ptr<Common::AuthProvider> provider, const std::string &subMethod, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, +boost::shared_ptr<Common::AuthContext> AuthBackendChallengeResponse::authenticate(boost::shared_ptr<Common::AuthProvider> provider, const Core::String &subMethod, + const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, boost::shared_ptr<Common::AuthContext> context) throw(Core::Exception) { if(context && dynamic_cast<AuthContextChallengeResponse*>(context.get()) == 0) throw(Core::Exception(Core::Exception::INVALID_INPUT)); - std::vector<std::string> allowedMethods = getSubMethods(provider); + std::vector<Core::String> allowedMethods = getSubMethods(provider); if(std::find(allowedMethods.begin(), allowedMethods.end(), subMethod) == allowedMethods.end()) throw(Core::Exception(Core::Exception::INVALID_INPUT)); diff --git a/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.h b/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.h index dc1b60a..0d69eba 100644 --- a/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.h +++ b/src/modules/AuthBackendChallengeResponse/AuthBackendChallengeResponse.h @@ -56,7 +56,7 @@ class MAD_MODULE_EXPORT AuthBackendChallengeResponse : public Common::AuthBacken } }; - static const std::string methodName; + static const Core::String methodName; Common::Application *application; @@ -68,19 +68,19 @@ class MAD_MODULE_EXPORT AuthBackendChallengeResponse : public Common::AuthBacken protected: - virtual const std::string& getMethodName() const { + virtual const Core::String& getMethodName() const { return methodName; } - virtual std::vector<std::string> getSubMethods(boost::shared_ptr<Common::AuthProvider> provider) const { - std::vector<std::string> ret; + virtual std::vector<Core::String> getSubMethods(boost::shared_ptr<Common::AuthProvider> provider) const { + std::vector<Core::String> ret; ret.push_back(provider->getHashes().front()); return ret; } - virtual boost::shared_ptr<Common::AuthContext> authenticate(boost::shared_ptr<Common::AuthProvider> provider, const std::string &subMethod, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, + virtual boost::shared_ptr<Common::AuthContext> authenticate(boost::shared_ptr<Common::AuthProvider> provider, const Core::String &subMethod, + const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, boost::shared_ptr<Common::AuthContext> context) throw(Core::Exception); public: diff --git a/src/modules/AuthBackendPassword/AuthBackendPassword.cpp b/src/modules/AuthBackendPassword/AuthBackendPassword.cpp index 1b38002..9701f04 100644 --- a/src/modules/AuthBackendPassword/AuthBackendPassword.cpp +++ b/src/modules/AuthBackendPassword/AuthBackendPassword.cpp @@ -23,15 +23,15 @@ namespace Mad { namespace Modules { namespace AuthBackendPassword { -const std::string AuthBackendPassword::methodName = "Password"; +const Core::String AuthBackendPassword::methodName = "Password"; -boost::shared_ptr<Common::AuthContext> AuthBackendPassword::authenticate(boost::shared_ptr<Common::AuthProvider> provider, const std::string &subMethod, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t>& /*response*/, +boost::shared_ptr<Common::AuthContext> AuthBackendPassword::authenticate(boost::shared_ptr<Common::AuthProvider> provider, const Core::String &subMethod, + const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t>& /*response*/, boost::shared_ptr<Common::AuthContext> context) throw(Core::Exception) { if(context && dynamic_cast<AuthContextPassword*>(context.get()) == 0) throw(Core::Exception(Core::Exception::INVALID_INPUT)); - std::vector<std::string> allowedMethods = getSubMethods(provider); + std::vector<Core::String> allowedMethods = getSubMethods(provider); if(std::find(allowedMethods.begin(), allowedMethods.end(), subMethod) == allowedMethods.end()) throw(Core::Exception(Core::Exception::INVALID_INPUT)); diff --git a/src/modules/AuthBackendPassword/AuthBackendPassword.h b/src/modules/AuthBackendPassword/AuthBackendPassword.h index ac100c1..aed11e8 100644 --- a/src/modules/AuthBackendPassword/AuthBackendPassword.h +++ b/src/modules/AuthBackendPassword/AuthBackendPassword.h @@ -42,22 +42,22 @@ class MAD_MODULE_EXPORT AuthBackendPassword : public Common::AuthBackend, privat Common::Application *application; - static const std::string methodName; + static const Core::String methodName; protected: - virtual const std::string& getMethodName() const { + virtual const Core::String& getMethodName() const { return methodName; } - virtual std::vector<std::string> getSubMethods(boost::shared_ptr<Common::AuthProvider> provider) const { - std::vector<std::string> ret; + virtual std::vector<Core::String> getSubMethods(boost::shared_ptr<Common::AuthProvider> provider) const { + std::vector<Core::String> ret; ret.push_back(provider->getHashes().front()); return ret; } - virtual boost::shared_ptr<Common::AuthContext> authenticate(boost::shared_ptr<Common::AuthProvider> provider, const std::string &subMethod, - const std::string &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, + virtual boost::shared_ptr<Common::AuthContext> authenticate(boost::shared_ptr<Common::AuthProvider> provider, const Core::String &subMethod, + const Core::String &user, const std::vector<boost::uint8_t> &data, std::vector<boost::uint8_t> &response, boost::shared_ptr<Common::AuthContext> context) throw(Core::Exception); public: diff --git a/src/modules/AuthProviderFile/AuthProviderFile.cpp b/src/modules/AuthProviderFile/AuthProviderFile.cpp index b1e1e52..b006cdc 100644 --- a/src/modules/AuthProviderFile/AuthProviderFile.cpp +++ b/src/modules/AuthProviderFile/AuthProviderFile.cpp @@ -54,17 +54,19 @@ void AuthProviderFile::readFile(const std::string &name) { continue; } - std::string password = match[2].str(); + Core::String password = match[2].str().c_str(); + + if(filehash.isEmpty()) { + std::string utf8pass = password.extractUTF8(); - if(filehash.empty()) { boost::lock_guard<boost::mutex> lock(mutex); - userMap.insert(std::make_pair(match[1].str(), std::vector<boost::uint8_t>(password.begin(), password.end()))); + userMap.insert(std::make_pair(match[1].str().c_str(), std::vector<boost::uint8_t>(utf8pass.begin(), utf8pass.end()))); } else { std::vector<boost::uint8_t> data; - data.reserve(password.size()/2); + data.reserve(password.length()/2); - for(size_t c = 0; c < password.size()-1; c += 2) { + for(boost::int32_t c = 0; c < password.length()-1; c += 2) { char buffer[3] = {password[c], password[c+1], 0}; unsigned char byte; @@ -79,7 +81,7 @@ void AuthProviderFile::readFile(const std::string &name) { if(!data.empty()) { boost::lock_guard<boost::mutex> lock(mutex); - userMap.insert(std::make_pair(match[1].str(), data)); + userMap.insert(std::make_pair(match[1].str().c_str(), data)); } } } @@ -94,15 +96,15 @@ bool AuthProviderFile::handleConfigEntry(const Core::ConfigEntry &entry, bool /* if(entry[1].getKey().matches("Hash")) { if(entry[2].isEmpty()) { - filehash = entry[1][0].extract(); + filehash = entry[1][0]; if(!Common::Hash::isHashSupported(filehash)) - application->logf(Core::Logger::LOG_WARNING, "AuthProviderFile: Unsupported hash '%s'", filehash.c_str()); + application->logf(Core::Logger::LOG_WARNING, "AuthProviderFile: Unsupported hash '%s'", filehash.extract().c_str()); } } else if(entry[1].getKey().matches("File")) { if(entry[2].isEmpty()) { - files.push_back(entry[1][0].extract()); + files.push_back(entry[1][0]); } } else if(!entry[2].isEmpty()) @@ -112,9 +114,9 @@ bool AuthProviderFile::handleConfigEntry(const Core::ConfigEntry &entry, bool /* } void AuthProviderFile::configFinished() { - if(filehash.empty() || boost::algorithm::to_lower_copy(filehash) == "clear") { + if(filehash.isEmpty() || filehash.matches("clear")) { hashes = Common::Hash::getHashList(); - filehash.clear(); + filehash.remove(); } else { hashes.clear(); @@ -123,12 +125,12 @@ void AuthProviderFile::configFinished() { hashes.push_back("Clear"); - for(std::vector<std::string>::iterator file = files.begin(); file != files.end(); ++file) - readFile(*file); + for(std::vector<Core::String>::iterator file = files.begin(); file != files.end(); ++file) + readFile(file->extract()); } -bool AuthProviderFile::checkPassword(const std::string &user, const std::vector<boost::uint8_t> &data, const std::string &hash) throw(Core::Exception) { - if((hash.empty() || boost::algorithm::to_lower_copy(hash) == "clear") && !filehash.empty()) { +bool AuthProviderFile::checkPassword(const Core::String &user, const std::vector<boost::uint8_t> &data, const Core::String &hash) throw(Core::Exception) { + if((hash.isEmpty() || hash.matches("clear")) && !filehash.isEmpty()) { std::vector<boost::uint8_t> password = getPassword(user, filehash); std::vector<boost::uint8_t> hashdata = Common::Hash::hash(data, filehash); @@ -140,20 +142,20 @@ bool AuthProviderFile::checkPassword(const std::string &user, const std::vector< } } -std::vector<boost::uint8_t> AuthProviderFile::getPassword(const std::string &user, const std::string &hash) throw(Core::Exception) { +std::vector<boost::uint8_t> AuthProviderFile::getPassword(const Core::String &user, const Core::String &hash) throw(Core::Exception) { boost::lock_guard<boost::mutex> lock(mutex); - std::map<std::string, std::vector<boost::uint8_t> >::iterator userIt = userMap.find(user); + std::map<Core::String, std::vector<boost::uint8_t> >::iterator userIt = userMap.find(user); if(userIt == userMap.end()) return std::vector<boost::uint8_t>(); - if(filehash.empty()) { - if(boost::algorithm::to_lower_copy(hash) == "clear") + if(filehash.isEmpty()) { + if(hash.matches("clear")) return userIt->second; else return Common::Hash::hash(userIt->second, hash); } - else if(boost::algorithm::to_lower_copy(filehash) == boost::algorithm::to_lower_copy(hash)) { + else if(filehash.matches(hash)) { return userIt->second; } else diff --git a/src/modules/AuthProviderFile/AuthProviderFile.h b/src/modules/AuthProviderFile/AuthProviderFile.h index 63f3d28..6ca907f 100644 --- a/src/modules/AuthProviderFile/AuthProviderFile.h +++ b/src/modules/AuthProviderFile/AuthProviderFile.h @@ -42,23 +42,23 @@ class MAD_MODULE_EXPORT AuthProviderFile : public Common::AuthProvider, private boost::mutex mutex; - std::map<std::string, std::vector<boost::uint8_t> > userMap; + std::map<Core::String, std::vector<boost::uint8_t> > userMap; - std::vector<std::string> files; - std::string filehash; + std::vector<Core::String> files; + Core::String filehash; - std::vector<std::string> hashes; + std::vector<Core::String> hashes; protected: virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/); virtual void configFinished(); - virtual const std::vector<std::string>& getHashes() const { + virtual const std::vector<Core::String>& getHashes() const { return hashes; } - virtual bool checkPassword(const std::string &user, const std::vector<boost::uint8_t> &data, const std::string &hash) throw(Core::Exception); - virtual std::vector<boost::uint8_t> getPassword(const std::string &user, const std::string &hash) throw(Core::Exception); + virtual bool checkPassword(const Core::String &user, const std::vector<boost::uint8_t> &data, const Core::String &hash) throw(Core::Exception); + virtual std::vector<boost::uint8_t> getPassword(const Core::String &user, const Core::String &hash) throw(Core::Exception); public: AuthProviderFile(Common::Application *application0) : application(application0) { diff --git a/src/modules/StorageBackendFile/StorageBackendFile.cpp b/src/modules/StorageBackendFile/StorageBackendFile.cpp index aae7e03..0affc2c 100644 --- a/src/modules/StorageBackendFile/StorageBackendFile.cpp +++ b/src/modules/StorageBackendFile/StorageBackendFile.cpp @@ -62,29 +62,29 @@ void StorageBackendFile::configFinished() { configured = true; } -boost::filesystem::path StorageBackendFile::getFileName(const std::string &type, const std::string &name) { +boost::filesystem::path StorageBackendFile::getFileName(const Core::String &type, const Core::String &name) { boost::filesystem::path path(storageRoot); - path /= type; - path /= (name + ".xml"); + path /= type.extract(); + path /= Core::String(name + ".xml").extract(); return path; } -std::set<std::string> StorageBackendFile::listTypes() throw (Core::Exception) { +std::set<Core::String> StorageBackendFile::listTypes() throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!configured) throw Core::Exception(Core::Exception::NOT_AVAILABLE); - std::set<std::string> ret; + std::set<Core::String> ret; try { for(boost::filesystem::directory_iterator it(storageRoot); it != boost::filesystem::directory_iterator(); ++it) { boost::filesystem::path path = *it; if(boost::filesystem::is_directory(path)) - ret.insert(path.filename()); + ret.insert(path.filename().c_str()); } } catch(...) {} // Don't throw if we can't iterate over the dirs @@ -92,23 +92,23 @@ std::set<std::string> StorageBackendFile::listTypes() throw (Core::Exception) { return ret; } -std::set<std::string> StorageBackendFile::list(const std::string &type) throw (Core::Exception) { +std::set<Core::String> StorageBackendFile::list(const Core::String &type) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!configured) throw Core::Exception(Core::Exception::NOT_AVAILABLE); - std::set<std::string> ret; + std::set<Core::String> ret; boost::filesystem::path path(storageRoot); - path /= type; + path /= type.extract(); try { for(boost::filesystem::directory_iterator it(path); it != boost::filesystem::directory_iterator(); ++it) { boost::filesystem::path filePath = *it; if(boost::filesystem::is_regular_file(filePath) && filePath.extension() == ".xml") - ret.insert(filePath.replace_extension().filename()); + ret.insert(filePath.replace_extension().filename().c_str()); } } catch(...) {} // Don't throw if we can't iterate over the dirs @@ -117,7 +117,7 @@ std::set<std::string> StorageBackendFile::list(const std::string &type) throw (C } -bool StorageBackendFile::exists(const std::string &type, const std::string &name) throw (Core::Exception) { +bool StorageBackendFile::exists(const Core::String &type, const Core::String &name) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!configured) @@ -128,7 +128,7 @@ bool StorageBackendFile::exists(const std::string &type, const std::string &name return boost::filesystem::is_regular_file(path); } -void StorageBackendFile::store(const std::string &type, const std::string &name, const Common::XmlData *data) throw (Core::Exception) { +void StorageBackendFile::store(const Core::String &type, const Core::String &name, const Common::XmlData *data) throw (Core::Exception) { boost::lock_guard<boost::shared_mutex> lock(mutex); if(!configured) @@ -140,7 +140,7 @@ void StorageBackendFile::store(const std::string &type, const std::string &name, data->toFile(path.file_string()); } -boost::shared_ptr<Common::XmlData> StorageBackendFile::load(const std::string &type, const std::string &name) throw (Core::Exception) { +boost::shared_ptr<Common::XmlData> StorageBackendFile::load(const Core::String &type, const Core::String &name) throw (Core::Exception) { boost::shared_lock<boost::shared_mutex> lock(mutex); if(!configured) @@ -153,7 +153,7 @@ boost::shared_ptr<Common::XmlData> StorageBackendFile::load(const std::string &t return boost::shared_ptr<Common::XmlData>(new Common::XmlData(path.file_string())); } -void StorageBackendFile::copy(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception) { +void StorageBackendFile::copy(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) { boost::lock_guard<boost::shared_mutex> lock(mutex); if(!configured) @@ -164,7 +164,7 @@ void StorageBackendFile::copy(const std::string &type, const std::string &name, boost::filesystem::copy_file(path, newPath); } -void StorageBackendFile::rename(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception) { +void StorageBackendFile::rename(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception) { boost::lock_guard<boost::shared_mutex> lock(mutex); if(!configured) @@ -175,7 +175,7 @@ void StorageBackendFile::rename(const std::string &type, const std::string &name boost::filesystem::rename(path, newPath); } -void StorageBackendFile::remove(const std::string &type, const std::string &name) throw (Core::Exception) { +void StorageBackendFile::remove(const Core::String &type, const Core::String &name) throw (Core::Exception) { boost::lock_guard<boost::shared_mutex> lock(mutex); if(!configured) diff --git a/src/modules/StorageBackendFile/StorageBackendFile.h b/src/modules/StorageBackendFile/StorageBackendFile.h index 9994500..f38e674 100644 --- a/src/modules/StorageBackendFile/StorageBackendFile.h +++ b/src/modules/StorageBackendFile/StorageBackendFile.h @@ -42,23 +42,23 @@ class StorageBackendFile : public Common::StorageBackend, private Core::Configur boost::shared_mutex mutex; - boost::filesystem::path getFileName(const std::string &type, const std::string &name); + boost::filesystem::path getFileName(const Core::String &type, const Core::String &name); protected: virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled); virtual void configFinished(); - virtual std::set<std::string> listTypes() throw (Core::Exception); - virtual std::set<std::string> list(const std::string &type) throw (Core::Exception); + virtual std::set<Core::String> listTypes() throw (Core::Exception); + virtual std::set<Core::String> list(const Core::String &type) throw (Core::Exception); - virtual bool exists(const std::string &type, const std::string &name) throw (Core::Exception); + virtual bool exists(const Core::String &type, const Core::String &name) throw (Core::Exception); - virtual void store(const std::string &type, const std::string &name, const Common::XmlData *data) throw (Core::Exception); - virtual boost::shared_ptr<Common::XmlData> load(const std::string &type, const std::string &name) throw (Core::Exception); + virtual void store(const Core::String &type, const Core::String &name, const Common::XmlData *data) throw (Core::Exception); + virtual boost::shared_ptr<Common::XmlData> load(const Core::String &type, const Core::String &name) throw (Core::Exception); - virtual void copy(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception); - virtual void rename(const std::string &type, const std::string &name, const std::string &newName) throw (Core::Exception); - virtual void remove(const std::string &type, const std::string &name) throw (Core::Exception); + virtual void copy(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception); + virtual void rename(const Core::String &type, const Core::String &name, const Core::String &newName) throw (Core::Exception); + virtual void remove(const Core::String &type, const Core::String &name) throw (Core::Exception); public: StorageBackendFile(Common::Application *application0) : application(application0), configured(false) { diff --git a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp index d47e03b..e1db3b9 100644 --- a/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp +++ b/src/modules/UserConfigBackendHome/UserConfigBackendHome.cpp @@ -35,11 +35,11 @@ bool UserConfigBackendHome::handleConfigEntry(const Core::ConfigEntry &entry, bo if(entry[0].getKey().matches("UserManager")) { if(entry[1].getKey().matches("Skeleton")) { if(entry[2].isEmpty()) - skeleton = entry[1][0].extract(); + skeleton = entry[1][0]; } else if(entry[1].getKey().matches("HomeDir")) { if(entry[2].isEmpty()) - homeDir = entry[1][0].extract(); + homeDir = entry[1][0]; } else if(entry[1].getKey().matches("UserDirMode")) { if(entry[2].isEmpty()) { @@ -104,8 +104,8 @@ void UserConfigBackendHome::migrateOwner(const std::string &path, const Common:: } void UserConfigBackendHome::addUser(const Common::UserInfo &userInfo) throw(Core::Exception) { - boost::filesystem::path path(homeDir); - path /= userInfo.getUsername(); + boost::filesystem::path path(homeDir.extract()); + path /= userInfo.getUsername().extract(); boost::filesystem::create_directories(path); @@ -118,7 +118,7 @@ void UserConfigBackendHome::addUser(const Common::UserInfo &userInfo) throw(Core // TODO Error } - boost::filesystem::path skeletonPath(skeleton); + boost::filesystem::path skeletonPath(skeleton.extract()); if(!boost::filesystem::is_directory(skeletonPath)) return; @@ -161,11 +161,11 @@ void UserConfigBackendHome::addUser(const Common::UserInfo &userInfo) throw(Core } void UserConfigBackendHome::updateUser(const Common::UserInfo &oldUserInfo, const Common::UserInfo &userInfo) throw(Core::Exception) { - boost::filesystem::path oldPath(homeDir); - oldPath /= oldUserInfo.getUsername(); + boost::filesystem::path oldPath(homeDir.extract()); + oldPath /= oldUserInfo.getUsername().extract(); - boost::filesystem::path path(homeDir); - path /= userInfo.getUsername(); + boost::filesystem::path path(homeDir.extract()); + path /= userInfo.getUsername().extract(); if(oldPath != path) { try { @@ -202,8 +202,8 @@ void UserConfigBackendHome::updateUser(const Common::UserInfo &oldUserInfo, cons } void UserConfigBackendHome::deleteUser(const Common::UserInfo &userInfo) throw(Core::Exception) { - boost::filesystem::path path(homeDir); - path /= userInfo.getUsername(); + boost::filesystem::path path(homeDir.extract()); + path /= userInfo.getUsername().extract(); boost::filesystem::remove_all(path); } diff --git a/src/modules/UserConfigBackendHome/UserConfigBackendHome.h b/src/modules/UserConfigBackendHome/UserConfigBackendHome.h index f115d9e..e82795c 100644 --- a/src/modules/UserConfigBackendHome/UserConfigBackendHome.h +++ b/src/modules/UserConfigBackendHome/UserConfigBackendHome.h @@ -36,8 +36,8 @@ class UserConfigBackendHome : public Common::UserConfigBackend, private Core::Co private: Common::Application *application; - std::string skeleton; - std::string homeDir; + Core::String skeleton; + Core::String homeDir; unsigned long dirMode; boost::mutex mutex; diff --git a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp index 475a689..7d53e55 100644 --- a/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp +++ b/src/modules/UserConfigBackendKrb5/UserConfigBackendKrb5.cpp @@ -133,7 +133,9 @@ void UserConfigBackendKrb5::configFinished() { void UserConfigBackendKrb5::checkUserInfo(const Common::UserInfo &userInfo) throw(Core::Exception) { - if(std::strcspn(userInfo.getUsername().c_str(), "/@") != userInfo.getUsername().length()) + std::string username = userInfo.getUsername().extract(); + + if(std::strcspn(username.c_str(), "/@") != username.length()) throw Core::Exception(Core::Exception::INVALID_INPUT); } @@ -145,7 +147,7 @@ void UserConfigBackendKrb5::addUser(const Common::UserInfo &userInfo) throw(Core if(!context || !handle) throw Core::Exception(Core::Exception::NOT_AVAILABLE); - std::string princStr = userInfo.getUsername() + "@" + realm; + std::string princStr = userInfo.getUsername().extract() + "@" + realm; kadm5_principal_ent_rec princ; @@ -228,7 +230,7 @@ void UserConfigBackendKrb5::deleteUser(const Common::UserInfo &userInfo) throw(C if(!context || !handle) throw Core::Exception(Core::Exception::NOT_AVAILABLE); - std::string princStr = userInfo.getUsername() + "@" + realm; + std::string princStr = userInfo.getUsername().extract() + "@" + realm; krb5_principal princ; krb5_error_code err = krb5_parse_name(context, princStr.c_str(), &princ); @@ -261,7 +263,7 @@ void UserConfigBackendKrb5::setPassword(const Common::UserInfo &userInfo, const if(!context || !handle) throw Core::Exception(Core::Exception::NOT_AVAILABLE); - std::string princStr = userInfo.getUsername() + "@" + realm; + std::string princStr = userInfo.getUsername().extract() + "@" + realm; krb5_principal princ; krb5_error_code err = krb5_parse_name(context, princStr.c_str(), &princ); diff --git a/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp b/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp index 7e7711a..46f9d12 100644 --- a/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp +++ b/src/modules/UserDBBackendMysql/UserDBBackendMysql.cpp @@ -27,6 +27,7 @@ #include <boost/bind.hpp> #include <boost/regex.hpp> #include <boost/thread/locks.hpp> +#include <boost/variant/get.hpp> #include <mysql/mysqld_error.h> @@ -34,7 +35,7 @@ namespace Mad { namespace Modules { namespace UserDBBackendMysql { -const std::string UserDBBackendMysql::name("UserDBBackendMysql"); +const Core::String UserDBBackendMysql::name("UserDBBackendMysql"); bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) { if(!entry[0].getKey().matches("UserManager")) @@ -48,19 +49,19 @@ bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool if(entry[2].getKey().matches("Host")) { if(entry[3].isEmpty()) - host = entry[2][0].extract(); + host = entry[2][0]; } else if(entry[2].getKey().matches("Username")) { if(entry[3].isEmpty()) - username = entry[2][0].extract(); + username = entry[2][0]; } else if(entry[2].getKey().matches("Password")) { if(entry[3].isEmpty()) - passwd = entry[2][0].extract(); + passwd = entry[2][0]; } else if(entry[2].getKey().matches("Database")) { if(entry[3].isEmpty()) - db = entry[2][0].extract(); + db = entry[2][0]; } else if(entry[2].getKey().matches("Port")) { if(entry[3].isEmpty()) { @@ -77,76 +78,76 @@ bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool } else if(entry[2].getKey().matches("UnixSocket")) { if(entry[3].isEmpty()) - unixSocket = entry[2][0].extract(); + unixSocket = entry[2][0]; } else if(entry[2].getKey().matches("Queries")) { if(entry[3].getKey().matches("ListUsers")) { if(entry[4].isEmpty()) - queryListUsers = entry[3][0].extract(); + queryListUsers = entry[3][0]; } else if(entry[3].getKey().matches("ListGroups")) { if(entry[4].isEmpty()) - queryListGroups = entry[3][0].extract(); + queryListGroups = entry[3][0]; } else if(entry[3].getKey().matches("ListUserGroups")) { if(entry[4].isEmpty()) - queryListUserGroups = entry[3][0].extract(); + queryListUserGroups = entry[3][0]; } else if(entry[3].getKey().matches("ListGroupUsers")) { if(entry[4].isEmpty()) - queryListGroupUsers = entry[3][0].extract(); + queryListGroupUsers = entry[3][0]; } else if(entry[3].getKey().matches("UserById")) { if(entry[4].isEmpty()) - queryUserById = entry[3][0].extract(); + queryUserById = entry[3][0]; } else if(entry[3].getKey().matches("UserByName")) { if(entry[4].isEmpty()) - queryUserByName = entry[3][0].extract(); + queryUserByName = entry[3][0]; } else if(entry[3].getKey().matches("GroupById")) { if(entry[4].isEmpty()) - queryGroupById = entry[3][0].extract(); + queryGroupById = entry[3][0]; } else if(entry[3].getKey().matches("GroupByName")) { if(entry[4].isEmpty()) - queryGroupByName = entry[3][0].extract(); + queryGroupByName = entry[3][0]; } else if(entry[3].getKey().matches("UserGroupTable")) { if(entry[4].isEmpty()) - queryUserGroupTable = entry[3][0].extract(); + queryUserGroupTable = entry[3][0]; } else if(entry[3].getKey().matches("AddUser")) { if(entry[4].isEmpty()) - queryAddUser = entry[3][0].extract(); + queryAddUser = entry[3][0]; } else if(entry[3].getKey().matches("UpdateUser")) { if(entry[4].isEmpty()) - queryUpdateUser = entry[3][0].extract(); + queryUpdateUser = entry[3][0]; } else if(entry[3].getKey().matches("DeleteUser")) { if(entry[4].isEmpty()) - queryDeleteUser = entry[3][0].extract(); + queryDeleteUser = entry[3][0]; } else if(entry[3].getKey().matches("AddGroup")) { if(entry[4].isEmpty()) - queryAddGroup = entry[3][0].extract(); + queryAddGroup = entry[3][0]; } else if(entry[3].getKey().matches("UpdateGroup")) { if(entry[4].isEmpty()) - queryUpdateGroup = entry[3][0].extract(); + queryUpdateGroup = entry[3][0]; } else if(entry[3].getKey().matches("DeleteGroup")) { if(entry[4].isEmpty()) - queryDeleteGroup = entry[3][0].extract(); + queryDeleteGroup = entry[3][0]; } else if(entry[3].getKey().matches("AddUserToGroup")) { if(entry[4].isEmpty()) - queryAddUserToGroup = entry[3][0].extract(); + queryAddUserToGroup = entry[3][0]; } else if(entry[3].getKey().matches("DeleteUserFromGroup")) { if(entry[4].isEmpty()) - queryDeleteUserFromGroup = entry[3][0].extract(); + queryDeleteUserFromGroup = entry[3][0]; } else if(!entry[3].isEmpty()) return false; @@ -158,32 +159,33 @@ bool UserDBBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool } void UserDBBackendMysql::configFinished() { - if(db.empty()) { + if(db.isEmpty()) { application->log(Core::Logger::LOG_ERROR, "UserDBBackendMysql: No database name given"); return; } boost::lock_guard<boost::mutex> lock(mutex); mysql = mysql_init(0); - mysql_real_connect(mysql, host.c_str(), username.c_str(), passwd.c_str(), db.c_str(), port, unixSocket.empty() ? 0 : unixSocket.c_str(), 0); + mysql_real_connect(mysql, host.extract().c_str(), username.extract().c_str(), passwd.extract().c_str(), + db.extract().c_str(), port, unixSocket.isEmpty() ? 0 : unixSocket.extract().c_str(), 0); } -UserDBBackendMysql::Result UserDBBackendMysql::query(const std::string &query, const ArgumentMap &args) throw(Core::Exception) { +UserDBBackendMysql::Result UserDBBackendMysql::query(const Core::String &query, const ArgumentMap &args) throw(Core::Exception) { if(!mysql || mysql_ping(mysql)) throw Core::Exception(Core::Exception::NOT_AVAILABLE); + std::string queryStr = query.extract(); + if(args.empty()) { - mysql_real_query(mysql, query.c_str(), query.length()); + mysql_real_query(mysql, queryStr.c_str(), queryStr.length()); } else { - std::string queryStr = query; - for(ArgumentMap::const_iterator arg = args.begin(); arg != args.end(); ++arg) { std::string argStr; try { - argStr = boost::get<std::string>(arg->second); + argStr = boost::get<Core::String>(arg->second).extract(); } catch(...) { std::ostringstream stream; @@ -194,7 +196,7 @@ UserDBBackendMysql::Result UserDBBackendMysql::query(const std::string &query, c boost::scoped_array<char> escaped(new char[argStr.length()*2+1]); mysql_real_escape_string(mysql, escaped.get(), argStr.c_str(), argStr.length()); - queryStr = boost::regex_replace(queryStr, boost::regex("\\{" + arg->first + "\\}"), "\"" + std::string(escaped.get()) + "\"", boost::match_default); + queryStr = boost::regex_replace(queryStr, boost::regex("\\{" + arg->first.extract() + "\\}"), "\"" + std::string(escaped.get()) + "\"", boost::match_default); } mysql_real_query(mysql, queryStr.c_str(), queryStr.length()); @@ -273,7 +275,7 @@ boost::shared_ptr<const Common::UserInfo> UserDBBackendMysql::getUserInfo(unsign throw Core::Exception(Core::Exception::NOT_FOUND); } -boost::shared_ptr<const Common::UserInfo> UserDBBackendMysql::getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { +boost::shared_ptr<const Common::UserInfo> UserDBBackendMysql::getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { application->getThreadManager()->detach(); boost::unique_lock<boost::mutex> lock(mutex); @@ -400,7 +402,7 @@ boost::shared_ptr<const Common::GroupInfo> UserDBBackendMysql::getGroupInfo(unsi throw Core::Exception(Core::Exception::NOT_FOUND); } -boost::shared_ptr<const Common::GroupInfo> UserDBBackendMysql::getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { +boost::shared_ptr<const Common::GroupInfo> UserDBBackendMysql::getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception) { application->getThreadManager()->detach(); boost::unique_lock<boost::mutex> lock(mutex); diff --git a/src/modules/UserDBBackendMysql/UserDBBackendMysql.h b/src/modules/UserDBBackendMysql/UserDBBackendMysql.h index 959e133..9351ca1 100644 --- a/src/modules/UserDBBackendMysql/UserDBBackendMysql.h +++ b/src/modules/UserDBBackendMysql/UserDBBackendMysql.h @@ -29,7 +29,7 @@ #include <mysql/mysql.h> #include <boost/thread/mutex.hpp> -#include <boost/variant.hpp> +#include <boost/variant/variant.hpp> namespace Mad { namespace Modules { @@ -37,14 +37,14 @@ namespace UserDBBackendMysql { class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configurable, private boost::noncopyable { private: - typedef std::map<std::string, boost::variant<std::string, unsigned long> > ArgumentMap; + typedef std::map<Core::String, boost::variant<Core::String, unsigned long> > ArgumentMap; class Result; - Result query(const std::string &query, const ArgumentMap &args = ArgumentMap()) throw(Core::Exception); + Result query(const Core::String &query, const ArgumentMap &args = ArgumentMap()) throw(Core::Exception); class Result { private: - friend Result UserDBBackendMysql::query(const std::string &query, const ArgumentMap &args) throw(Core::Exception); + friend Result UserDBBackendMysql::query(const Core::String &query, const ArgumentMap &args) throw(Core::Exception); boost::shared_ptr<MYSQL_RES> result; @@ -84,21 +84,21 @@ class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configura } }; - static const std::string name; + static const Core::String name; Common::Application *application; - std::string host, username, passwd, db, unixSocket; + Core::String host, username, passwd, db, unixSocket; uint16_t port; - std::string queryListUsers, queryListGroups; - std::string queryListUserGroups, queryListGroupUsers; - std::string queryUserById, queryUserByName; - std::string queryGroupById, queryGroupByName; - std::string queryUserGroupTable; - std::string queryAddUser, queryUpdateUser, queryDeleteUser; - std::string queryAddGroup, queryUpdateGroup, queryDeleteGroup; - std::string queryAddUserToGroup, queryDeleteUserFromGroup; + Core::String queryListUsers, queryListGroups; + Core::String queryListUserGroups, queryListGroupUsers; + Core::String queryUserById, queryUserByName; + Core::String queryGroupById, queryGroupByName; + Core::String queryUserGroupTable; + Core::String queryAddUser, queryUpdateUser, queryDeleteUser; + Core::String queryAddGroup, queryUpdateGroup, queryDeleteGroup; + Core::String queryAddUserToGroup, queryDeleteUserFromGroup; MYSQL *mysql; @@ -112,12 +112,12 @@ class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configura virtual boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const Common::UserInfo> getUserInfo(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception); - virtual boost::shared_ptr<const Common::UserInfo> getUserInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); + virtual boost::shared_ptr<const Common::UserInfo> getUserInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::set<unsigned long> > getUserGroupList(unsigned long uid, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > getGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfo(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception); - virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfoByName(const std::string &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); + virtual boost::shared_ptr<const Common::GroupInfo> getGroupInfoByName(const Core::String &name, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::set<unsigned long> > getGroupUserList(unsigned long gid, boost::posix_time::ptime *timestamp) throw(Core::Exception); virtual boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > getFullUserGroupList(boost::posix_time::ptime *timestamp) throw(Core::Exception); @@ -147,7 +147,7 @@ class UserDBBackendMysql : public Common::UserDBBackend, private Core::Configura } } - virtual const std::string& getName() { + virtual const Core::String& getName() { return name; } }; |