Skip to content

Commit

Permalink
remove all uses of using namespace in header files
Browse files Browse the repository at this point in the history
  • Loading branch information
nam20485 committed Oct 19, 2023
1 parent 72e0555 commit 7c74b08
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 43 deletions.
4 changes: 1 addition & 3 deletions OdbDesignLib/IOdbApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include "ExitCode.h"
#include "odbdesign_export.h"

using namespace Utils;

namespace Odb::Lib
{
class ODBDESIGN_EXPORT IOdbApp
Expand All @@ -17,7 +15,7 @@ namespace Odb::Lib
virtual const OdbDesignArgs& args() const = 0;
virtual DesignCache& design_cache() = 0;

virtual ExitCode Run() = 0;
virtual Utils::ExitCode Run() = 0;

protected:
// abstract class/interface
Expand Down
15 changes: 6 additions & 9 deletions OdbDesignLib/IProtoBuffable.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#include "IJsonable.h"
#include "odbdesign_export.h"

using namespace google::protobuf;
using namespace google::protobuf::util;


namespace Odb::Lib
{
Expand All @@ -29,31 +26,31 @@ namespace Odb::Lib
{}

// TMessage MUST derive from Message (must use this until template type contraints support is added)
static_assert(std::is_base_of<Message, TPbMessage>::value, "template parameter type TPbMessage must derive from Protobuf Message class");
static_assert(std::is_base_of<google::protobuf::Message, TPbMessage>::value, "template parameter type TPbMessage must derive from Protobuf Message class");

};

template<typename TPbMessage>
std::string IProtoBuffable<TPbMessage>::to_json() const
{
// use default options
JsonOptions jsonOptions;
google::protobuf::util::JsonOptions jsonOptions;

std::string json;
auto status = MessageToJsonString(*to_protobuf(), &json, jsonOptions);
auto status = google::protobuf::util::MessageToJsonString(*to_protobuf(), &json, jsonOptions);
if (!status.ok()) json.clear();
return json;
}

template<typename TPbMessage>
inline void IProtoBuffable<TPbMessage>::from_json(const std::string& json)
{
StringPiece sp_json(json);
google::protobuf::StringPiece sp_json(json);
// use default options
JsonOptions jsonOptions;
google::protobuf::util::JsonOptions jsonOptions;

auto pMessage = std::unique_ptr<TPbMessage>();
auto status = JsonStringToMessage(sp_json, pMessage.get());
auto status = google::protobuf::util::JsonStringToMessage(sp_json, pMessage.get());
if (!status.ok()) return;
from_protobuf(*pMessage);
}
Expand Down
2 changes: 2 additions & 0 deletions OdbDesignLib/MiscInfoFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "timestamp.h"
#include "Logger.h"

using namespace std::chrono;

namespace Odb::Lib::FileModel::Design
{
bool MiscInfoFile::Parse(std::filesystem::path path)
Expand Down
9 changes: 1 addition & 8 deletions OdbDesignLib/MiscInfoFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
#include "OdbFile.h"
#include <chrono>

#ifndef ODBDESIGN_MISCINFOFILE_H
#define ODBDESIGN_MISCINFOFILE_H

//using namespace std::chrono;
#pragma once

namespace Odb::Lib::FileModel::Design
{
Expand Down Expand Up @@ -47,8 +44,4 @@ namespace Odb::Lib::FileModel::Design
unsigned int m_maxUniqueId;

};

}


#endif //ODBDESIGN_MISCINFOFILE_H
2 changes: 0 additions & 2 deletions OdbDesignLib/OdbAppBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include "OdbDesignArgs.h"
#include "odbdesign_export.h"

using namespace Utils;

namespace Odb::Lib
{
class ODBDESIGN_EXPORT OdbAppBase : public virtual IOdbApp
Expand Down
4 changes: 1 addition & 3 deletions OdbDesignLib/OdbDesignArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
#include "CommandLineArgs.h"
#include "odbdesign_export.h"

using namespace Utils;

namespace Odb::Lib
{
class ODBDESIGN_EXPORT OdbDesignArgs : public CommandLineArgs
class ODBDESIGN_EXPORT OdbDesignArgs : public Utils::CommandLineArgs
{
public:
OdbDesignArgs(int argc, char* argv[]);
Expand Down
1 change: 1 addition & 0 deletions OdbDesignLib/OdbServerAppBase.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "OdbServerAppBase.h"

using namespace Utils;

namespace Odb::Lib
{
Expand Down
2 changes: 1 addition & 1 deletion OdbDesignLib/OdbServerAppBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Odb::Lib

crow::SimpleApp& crow_app() override;

ExitCode Run() override;
Utils::ExitCode Run() override;

protected:
crow::SimpleApp m_crowApp;
Expand Down
1 change: 1 addition & 0 deletions OdbDesignServer/Controllers/HelloWorldController.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "HelloWorldController.h"
#include "../OdbDesignServerApp.h"

using namespace Odb::Lib;

namespace Odb::App::Server
{
Expand Down
5 changes: 2 additions & 3 deletions OdbDesignServer/Controllers/HelloWorldController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
#include "RouteController.h"
#include "IOdbServerApp.h"

using namespace Odb::Lib;

namespace Odb::App::Server
{
class HelloWorldController : public RouteController
class HelloWorldController : public Odb::Lib::RouteController
{
public:
HelloWorldController(IOdbServerApp& serverApp);
HelloWorldController(Odb::Lib::IOdbServerApp& serverApp);

void register_routes() override;

Expand Down
5 changes: 2 additions & 3 deletions OdbDesignServer/Controllers/StepsEdaDataController.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
#include "crow_win.h"
#include "IOdbServerApp.h"

using namespace Odb::Lib;

namespace Odb::App::Server
{
class StepsEdaDataController : public RouteController
class StepsEdaDataController : public Odb::Lib::RouteController
{
public:
StepsEdaDataController(IOdbServerApp& serverApp);
StepsEdaDataController(Odb::Lib::IOdbServerApp& serverApp);

void register_routes() override;

Expand Down
3 changes: 1 addition & 2 deletions OdbDesignServer/OdbDesignServerApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
#include "OdbDesignServer.h"
#include "OdbServerAppBase.h"

using namespace Odb::Lib;

namespace Odb::App::Server
{
class OdbDesignServerApp : public OdbServerAppBase
class OdbDesignServerApp : public Odb::Lib::OdbServerAppBase
{
public:
OdbDesignServerApp(int argc, char* argv[]);
Expand Down
2 changes: 1 addition & 1 deletion Utils/CommandLineArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Utils

void Utils::CommandLineArgs::parse()
{
for (int i = 0; i < m_vecArguments.size(); i++)
for (std::size_t i = 0; i < m_vecArguments.size(); i++)
{
auto& arg = m_vecArguments[i];
if (arg.length() > 0)
Expand Down
5 changes: 1 addition & 4 deletions Utils/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include <chrono>
#include "utils_export.h"

using namespace std::chrono;


namespace Utils
{

Expand Down Expand Up @@ -42,7 +39,7 @@ namespace Utils
{
std::string message;
Level level;
system_clock::time_point timeStamp;
std::chrono::system_clock::time_point timeStamp;
std::string file;
int line;

Expand Down
6 changes: 2 additions & 4 deletions Utils/timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
#include <chrono>
#include "utils_export.h"

using namespace std::chrono;

namespace Utils
{
std::string UTILS_EXPORT make_timestamp(const system_clock::time_point& timepoint);
std::string UTILS_EXPORT make_timestamp(const std::chrono::system_clock::time_point& timepoint);
std::string UTILS_EXPORT make_timestamp();

system_clock::time_point UTILS_EXPORT parse_timestamp(const std::string& timestamp, const std::string& format);
std::chrono::system_clock::time_point UTILS_EXPORT parse_timestamp(const std::string& timestamp, const std::string& format);
}

0 comments on commit 7c74b08

Please sign in to comment.