From 305d13544dc29f55d194daf3c09a6f89e995c96a Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Tue, 11 Aug 2026 12:39:02 +0200 Subject: [PATCH] Avoid using namespace in headers. --- tool/Command.h | 101 ++++++++++++++++++++-------------------- tool/CommandConfig.h | 15 +++--- tool/FoeCommand.cpp | 2 + tool/FoeCommand.h | 2 +- tool/MasterDevice.h | 13 +++--- tool/NumberListParser.h | 3 +- tool/SdoCommand.cpp | 2 + tool/SdoCommand.h | 2 +- tool/SoeCommand.h | 2 +- 9 files changed, 71 insertions(+), 71 deletions(-) diff --git a/tool/Command.h b/tool/Command.h index 5fe878bb..fdb92edc 100644 --- a/tool/Command.h +++ b/tool/Command.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -26,7 +26,6 @@ #include #include #include -using namespace std; #include "../master/ioctl.h" @@ -35,34 +34,34 @@ class MasterDevice; /****************************************************************************/ class InvalidUsageException: - public runtime_error + public std::runtime_error { friend class Command; protected: /** Constructor with stringstream parameter. */ InvalidUsageException( - const stringstream &s /**< Message. */ - ): runtime_error(s.str()) {} + const std::stringstream &s /**< Message. */ + ): std::runtime_error(s.str()) {} }; /****************************************************************************/ class CommandException: - public runtime_error + public std::runtime_error { friend class Command; protected: /** Constructor with char * parameter. */ CommandException( - const string &msg /**< Message. */ - ): runtime_error(msg) {} + const std::string &msg /**< Message. */ + ): std::runtime_error(msg) {} /** Constructor with stringstream parameter. */ CommandException( - const stringstream &s /**< Message. */ - ): runtime_error(s.str()) {} + const std::stringstream &s /**< Message. */ + ): std::runtime_error(s.str()) {} }; /****************************************************************************/ @@ -70,14 +69,14 @@ class CommandException: class Command { public: - Command(const string &, const string &); + Command(const std::string &, const std::string &); virtual ~Command(); - const string &getName() const; - const string &getBriefDescription() const; + const std::string &getName() const; + const std::string &getBriefDescription() const; - typedef list MasterIndexList; - void setMasters(const string &); + typedef std::list MasterIndexList; + void setMasters(const std::string &); MasterIndexList getMasterIndices() const; unsigned int getSingleMasterIndex() const; @@ -89,15 +88,15 @@ class Command void setVerbosity(Verbosity); Verbosity getVerbosity() const; - void setAliases(const string &); - void setPositions(const string &); + void setAliases(const std::string &); + void setPositions(const std::string &); - void setDomains(const string &); - typedef list DomainIndexList; + void setDomains(const std::string &); + typedef std::list DomainIndexList; DomainIndexList getDomainIndices() const; - void setDataType(const string &); - const string &getDataType() const; + void setDataType(const std::string &); + const std::string &getDataType() const; void setEmergency(bool); bool getEmergency() const; @@ -105,67 +104,67 @@ class Command void setForce(bool); bool getForce() const; - void setOutputFile(const string &); - const string &getOutputFile() const; + void setOutputFile(const std::string &); + const std::string &getOutputFile() const; - void setSkin(const string &); - const string &getSkin() const; + void setSkin(const std::string &); + const std::string &getSkin() const; - bool matchesSubstr(const string &) const; - bool matchesAbbrev(const string &) const; + bool matchesSubstr(const std::string &) const; + bool matchesAbbrev(const std::string &) const; - virtual string helpString(const string &) const = 0; + virtual std::string helpString(const std::string &) const = 0; - typedef vector StringVector; + typedef std::vector StringVector; virtual void execute(const StringVector &) = 0; - static string numericInfo(); + static std::string numericInfo(); protected: enum {BreakAfterBytes = 16}; - void throwInvalidUsageException(const stringstream &) const; - void throwCommandException(const string &) const; - void throwCommandException(const stringstream &) const; + void throwInvalidUsageException(const std::stringstream &) const; + void throwCommandException(const std::string &) const; + void throwCommandException(const std::stringstream &) const; void throwSingleSlaveRequired(unsigned int) const; - typedef list SlaveList; + typedef std::list SlaveList; SlaveList selectedSlaves(MasterDevice &); - typedef list ConfigList; + typedef std::list ConfigList; ConfigList selectedConfigs(MasterDevice &); - typedef list DomainList; + typedef std::list DomainList; DomainList selectedDomains(MasterDevice &, const ec_ioctl_master_t &); int emergencySlave() const; - static string alStateString(uint8_t); + static std::string alStateString(uint8_t); private: - string name; - string briefDesc; - string masters; + std::string name; + std::string briefDesc; + std::string masters; Verbosity verbosity; - string aliases; - string positions; - string domains; - string dataType; + std::string aliases; + std::string positions; + std::string domains; + std::string dataType; bool emergency; bool force; - string outputFile; - string skin; + std::string outputFile; + std::string skin; Command(); }; /****************************************************************************/ -inline const string &Command::getName() const +inline const std::string &Command::getName() const { return name; } /****************************************************************************/ -inline const string &Command::getBriefDescription() const +inline const std::string &Command::getBriefDescription() const { return briefDesc; } @@ -179,7 +178,7 @@ inline Command::Verbosity Command::getVerbosity() const /****************************************************************************/ -inline const string &Command::getDataType() const +inline const std::string &Command::getDataType() const { return dataType; } @@ -200,14 +199,14 @@ inline bool Command::getForce() const /****************************************************************************/ -inline const string &Command::getOutputFile() const +inline const std::string &Command::getOutputFile() const { return outputFile; } /****************************************************************************/ -inline const string &Command::getSkin() const +inline const std::string &Command::getSkin() const { return skin; } diff --git a/tool/CommandConfig.h b/tool/CommandConfig.h index f58d4324..7cc9e4e7 100644 --- a/tool/CommandConfig.h +++ b/tool/CommandConfig.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -23,7 +23,6 @@ #define __COMMANDCONFIG_H__ #include -using namespace std; #include "Command.h" #include "SoeCommand.h" @@ -37,16 +36,16 @@ class CommandConfig: public: CommandConfig(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: struct Info { - string alias; - string pos; - string ident; - string slavePos; - string state; + std::string alias; + std::string pos; + std::string ident; + std::string slavePos; + std::string state; }; void showDetailedConfigs(MasterDevice &, const ConfigList &, bool); diff --git a/tool/FoeCommand.cpp b/tool/FoeCommand.cpp index 82443085..3ebd2ea0 100644 --- a/tool/FoeCommand.cpp +++ b/tool/FoeCommand.cpp @@ -22,6 +22,8 @@ #include "FoeCommand.h" #include "foe.h" +using std::string; + /****************************************************************************/ FoeCommand::FoeCommand(const string &name, const string &briefDesc): diff --git a/tool/FoeCommand.h b/tool/FoeCommand.h index 6becbde9..6d93dd5c 100644 --- a/tool/FoeCommand.h +++ b/tool/FoeCommand.h @@ -30,7 +30,7 @@ class FoeCommand: public Command { public: - FoeCommand(const string &, const string &); + FoeCommand(const std::string &, const std::string &); protected: static std::string resultText(int); diff --git a/tool/MasterDevice.h b/tool/MasterDevice.h index 204fd1ba..8762f2bf 100644 --- a/tool/MasterDevice.h +++ b/tool/MasterDevice.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2024 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -24,7 +24,6 @@ #include #include -using namespace std; #include "ecrt.h" #include "ioctl.h" @@ -32,20 +31,20 @@ using namespace std; /****************************************************************************/ class MasterDeviceException: - public runtime_error + public std::runtime_error { friend class MasterDevice; protected: /** Constructor with string parameter. */ MasterDeviceException( - const string &s /**< Message. */ - ): runtime_error(s) {} + const std::string &s /**< Message. */ + ): std::runtime_error(s) {} /** Constructor with stringstream parameter. */ MasterDeviceException( - const stringstream &s /**< Message. */ - ): runtime_error(s.str()) {} + const std::stringstream &s /**< Message. */ + ): std::runtime_error(s.str()) {} }; /****************************************************************************/ diff --git a/tool/NumberListParser.h b/tool/NumberListParser.h index 37b89f33..15ebdccf 100644 --- a/tool/NumberListParser.h +++ b/tool/NumberListParser.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -20,7 +20,6 @@ ****************************************************************************/ #include -using namespace std; /****************************************************************************/ diff --git a/tool/SdoCommand.cpp b/tool/SdoCommand.cpp index aa93583f..c21a0e71 100644 --- a/tool/SdoCommand.cpp +++ b/tool/SdoCommand.cpp @@ -21,6 +21,8 @@ #include "SdoCommand.h" +using std::string; + /****************************************************************************/ SdoCommand::SdoCommand(const string &name, const string &briefDesc): diff --git a/tool/SdoCommand.h b/tool/SdoCommand.h index 794ddc80..41ca24a8 100644 --- a/tool/SdoCommand.h +++ b/tool/SdoCommand.h @@ -32,7 +32,7 @@ class SdoCommand: public DataTypeHandler { public: - SdoCommand(const string &, const string &); + SdoCommand(const std::string &, const std::string &); static const char *abortText(uint32_t); diff --git a/tool/SoeCommand.h b/tool/SoeCommand.h index 2391b25a..864dfb88 100644 --- a/tool/SoeCommand.h +++ b/tool/SoeCommand.h @@ -32,7 +32,7 @@ class SoeCommand { protected: - static uint16_t parseIdn(const string &); + static uint16_t parseIdn(const std::string &); static std::string outputIdn(uint16_t); static std::string errorMsg(uint16_t); };