summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libadhocutil/ctf-impl/printf-compat.h4
-rw-r--r--libadhocutil/factory.h4
-rw-r--r--libadhocutil/factory.impl.h4
-rw-r--r--libadhocutil/nagios.cpp7
-rw-r--r--libadhocutil/nagios.h5
-rw-r--r--libadhocutil/plugins.cpp10
-rw-r--r--libadhocutil/plugins.h24
-rw-r--r--libadhocutil/plugins.impl.h18
-rw-r--r--libadhocutil/unittests/testCurl.cpp2
-rw-r--r--libadhocutil/unittests/testPluginsRuntime.cpp12
10 files changed, 44 insertions, 46 deletions
diff --git a/libadhocutil/ctf-impl/printf-compat.h b/libadhocutil/ctf-impl/printf-compat.h
index b2004fb..a24c620 100644
--- a/libadhocutil/ctf-impl/printf-compat.h
+++ b/libadhocutil/ctf-impl/printf-compat.h
@@ -178,13 +178,13 @@ namespace AdHoc {
StreamWriterT('.', '*', 's') {
template<typename... Pn>
static inline void
- write(stream & s, int l, const std::string_view & p, const Pn &... pn)
+ write(stream & s, int l, const std::string_view p, const Pn &... pn)
{
return write(s, static_cast<size_t>(l), p, pn...);
}
template<typename... Pn>
static inline void
- write(stream & s, size_t l, const std::string_view & p, const Pn &... pn)
+ write(stream & s, size_t l, const std::string_view p, const Pn &... pn)
{
s << p.substr(0, l);
s.copyfmt(std::ios(nullptr));
diff --git a/libadhocutil/factory.h b/libadhocutil/factory.h
index 748fc4a..806e02d 100644
--- a/libadhocutil/factory.h
+++ b/libadhocutil/factory.h
@@ -37,13 +37,13 @@ namespace AdHoc {
* Helper to get the factory for a specific implementation.
* @param name The name of the implementation.
*/
- [[nodiscard]] static std::shared_ptr<const Factory> get(const std::string_view & name);
+ [[nodiscard]] static std::shared_ptr<const Factory> get(const std::string_view name);
/**
* Helper to create a new instance from a specific factory.
* @param name The name of the implementation.
* @param p The parameters to pass to the constructor.
*/
- [[nodiscard]] static std::shared_ptr<Base> createNew(const std::string_view & name, const Params &... p);
+ [[nodiscard]] static std::shared_ptr<Base> createNew(const std::string_view name, const Params &... p);
};
}
diff --git a/libadhocutil/factory.impl.h b/libadhocutil/factory.impl.h
index 074deea..38b0aab 100644
--- a/libadhocutil/factory.impl.h
+++ b/libadhocutil/factory.impl.h
@@ -8,14 +8,14 @@
namespace AdHoc {
template<typename Base, typename... Params>
std::shared_ptr<const Factory<Base, Params...>>
- Factory<Base, Params...>::get(const std::string_view & name)
+ Factory<Base, Params...>::get(const std::string_view name)
{
return PluginManager::getDefault()->get<Factory>(name)->implementation();
}
template<typename Base, typename... Params>
std::shared_ptr<Base>
- Factory<Base, Params...>::createNew(const std::string_view & name, const Params &... p)
+ Factory<Base, Params...>::createNew(const std::string_view name, const Params &... p)
{
return get(name)->create(p...);
}
diff --git a/libadhocutil/nagios.cpp b/libadhocutil/nagios.cpp
index 4350c35..a995a13 100644
--- a/libadhocutil/nagios.cpp
+++ b/libadhocutil/nagios.cpp
@@ -11,8 +11,7 @@ namespace AdHoc {
/// LCOV_EXCL_START (calls real Nagios)
bool
- submitNagiosPassiveServiceCheck(
- const std::string_view & svc, NagiosStatusCode code, const std::string_view & output)
+ submitNagiosPassiveServiceCheck(const std::string_view svc, NagiosStatusCode code, const std::string_view output)
{
std::ofstream command_file("/var/nagios/rw/nagios.cmd");
return submitNagiosPassiveServiceCheck(command_file, svc, code, output);
@@ -20,8 +19,8 @@ namespace AdHoc {
/// LCOV_EXCL_STOP
bool
- submitNagiosPassiveServiceCheck(std::ostream & command_file, const std::string_view & svc, NagiosStatusCode code,
- const std::string_view & output)
+ submitNagiosPassiveServiceCheck(std::ostream & command_file, const std::string_view svc, NagiosStatusCode code,
+ const std::string_view output)
{
if (command_file.good()) {
struct utsname buf {
diff --git a/libadhocutil/nagios.h b/libadhocutil/nagios.h
index cbe02d9..2518e89 100644
--- a/libadhocutil/nagios.h
+++ b/libadhocutil/nagios.h
@@ -13,8 +13,7 @@ namespace AdHoc {
Unknown = 3,
};
+ DLL_PUBLIC bool submitNagiosPassiveServiceCheck(const std::string_view, NagiosStatusCode, const std::string_view);
DLL_PUBLIC bool submitNagiosPassiveServiceCheck(
- const std::string_view &, NagiosStatusCode, const std::string_view &);
- DLL_PUBLIC bool submitNagiosPassiveServiceCheck(
- std::ostream &, const std::string_view &, NagiosStatusCode, const std::string_view &);
+ std::ostream &, const std::string_view, NagiosStatusCode, const std::string_view);
}
diff --git a/libadhocutil/plugins.cpp b/libadhocutil/plugins.cpp
index 000e86d..aeef27e 100644
--- a/libadhocutil/plugins.cpp
+++ b/libadhocutil/plugins.cpp
@@ -38,10 +38,10 @@ namespace AdHoc {
AbstractPluginImplementation::~AbstractPluginImplementation() = default;
- Plugin::Plugin(const std::string_view & n, const std::string_view & f, int l) : name(n), filename(f), lineno(l) { }
+ Plugin::Plugin(const std::string_view n, const std::string_view f, int l) : name(n), filename(f), lineno(l) { }
AdHocFormatter(NoSuchPluginExceptionMsg, "No such plugin: %? of type %?");
- NoSuchPluginException::NoSuchPluginException(const std::string_view & n, const std::type_info & t) :
+ NoSuchPluginException::NoSuchPluginException(const std::string_view n, const std::type_info & t) :
std::runtime_error(NoSuchPluginExceptionMsg::get(n, t))
{
}
@@ -60,7 +60,7 @@ namespace AdHoc {
}
AdHocFormatter(LoadLibraryExceptionMsg, "Failed to load library [%?]; %?");
- LoadLibraryException::LoadLibraryException(const std::string_view & f, const std::string_view & msg) :
+ LoadLibraryException::LoadLibraryException(const std::string_view f, const std::string_view msg) :
std::runtime_error(LoadLibraryExceptionMsg::get(f, msg))
{
}
@@ -106,14 +106,14 @@ namespace AdHoc {
}
void
- PluginManager::remove(const std::string_view & n, const std::type_info & t)
+ PluginManager::remove(const std::string_view n, const std::type_info & t)
{
auto r = plugins->get<2>().equal_range(std::make_tuple(n, std::cref(t)));
plugins->get<2>().erase(r.first, r.second);
}
PluginPtr
- PluginManager::get(const std::string_view & n, const std::type_info & t) const
+ PluginManager::get(const std::string_view n, const std::type_info & t) const
{
auto r = plugins->get<2>().equal_range(std::make_tuple(n, std::cref(t)));
if (r.first == r.second) {
diff --git a/libadhocutil/plugins.h b/libadhocutil/plugins.h
index 4f2ff84..7ae5bba 100644
--- a/libadhocutil/plugins.h
+++ b/libadhocutil/plugins.h
@@ -24,7 +24,7 @@ namespace AdHoc {
class NoSuchPluginException : public std::runtime_error {
public:
/// Constructor taking name and type of plugin requested.
- NoSuchPluginException(const std::string_view &, const std::type_info &);
+ NoSuchPluginException(const std::string_view, const std::type_info &);
};
/// Base class for all plugin implementations.
@@ -40,7 +40,7 @@ namespace AdHoc {
class DLL_PUBLIC Plugin {
public:
/// Constructor taking name, filename and line of install.
- Plugin(const std::string_view &, const std::string_view &, int);
+ Plugin(const std::string_view, const std::string_view, int);
/// Standard move/copy support
SPECIAL_MEMBERS_DELETE(Plugin);
virtual ~Plugin() = default;
@@ -78,7 +78,7 @@ namespace AdHoc {
class LoadLibraryException : public std::runtime_error {
public:
/// Constuctor taking syscall error details.
- LoadLibraryException(const std::string_view & f, const std::string_view & msg);
+ LoadLibraryException(const std::string_view f, const std::string_view msg);
};
template<typename T>
@@ -86,7 +86,7 @@ namespace AdHoc {
class DLL_PUBLIC PluginOf : public Plugin {
public:
/// Constructor taking an instance and name, filename and line of install for Plugin.
- PluginOf(std::shared_ptr<T> t, const std::string_view & n, const std::string_view & f, int l);
+ PluginOf(std::shared_ptr<T> t, const std::string_view n, const std::string_view f, int l);
/// Get the type of this plugin.
[[nodiscard]] const std::type_info & type() const override;
@@ -105,7 +105,7 @@ namespace AdHoc {
/// Callback definition to resolve a plugin type and name to a potential library
/// containing an implementation.
using PluginResolver
- = std::function<std::optional<std::string>(const std::type_info &, const std::string_view &)>;
+ = std::function<std::optional<std::string>(const std::type_info &, const std::string_view)>;
PluginManager();
virtual ~PluginManager();
@@ -116,9 +116,9 @@ namespace AdHoc {
/// Install a plugin.
void add(const PluginPtr &);
/// Uninstall a plugin.
- void remove(const std::string_view &, const std::type_info &);
+ void remove(const std::string_view, const std::type_info &);
/// Get a specific plugin.
- [[nodiscard]] PluginPtr get(const std::string_view &, const std::type_info &) const;
+ [[nodiscard]] PluginPtr get(const std::string_view, const std::type_info &) const;
/// Get all plugins.
[[nodiscard]] std::set<PluginPtr> getAll() const;
/// Get all plugins of a specific type.
@@ -132,7 +132,7 @@ namespace AdHoc {
* @param l Line number.
*/
template<typename T>
- void add(const std::shared_ptr<T> & i, const std::string_view & n, const std::string_view & f, int l);
+ void add(const std::shared_ptr<T> & i, const std::string_view n, const std::string_view f, int l);
/**
* Create and install a plugin
@@ -146,7 +146,7 @@ namespace AdHoc {
*/
template<typename T, typename I, typename... Args>
void
- create(const std::string_view & n, const std::string_view & f, int l, const Args &... args)
+ create(const std::string_view n, const std::string_view f, int l, const Args &... args)
{
add<T>(std::make_shared<I>(args...), n, f, l);
}
@@ -155,19 +155,19 @@ namespace AdHoc {
* Uninstall a plugin.
* @param n Name of plugin.
*/
- template<typename T> void remove(const std::string_view & n);
+ template<typename T> void remove(const std::string_view n);
/**
* Get a specific plugin.
* @param n Name of plugin.
*/
- template<typename T> [[nodiscard]] std::shared_ptr<const PluginOf<T>> get(const std::string_view & n) const;
+ template<typename T> [[nodiscard]] std::shared_ptr<const PluginOf<T>> get(const std::string_view n) const;
/**
* Get the implementation from specific plugin.
* @param n Name of plugin.
*/
- template<typename T> [[nodiscard]] std::shared_ptr<T> getImplementation(const std::string_view & n) const;
+ template<typename T> [[nodiscard]] std::shared_ptr<T> getImplementation(const std::string_view n) const;
/**
* Get all plugins of a given time.
diff --git a/libadhocutil/plugins.impl.h b/libadhocutil/plugins.impl.h
index becd149..772d37a 100644
--- a/libadhocutil/plugins.impl.h
+++ b/libadhocutil/plugins.impl.h
@@ -10,7 +10,7 @@
namespace AdHoc {
template<typename T>
- PluginOf<T>::PluginOf(std::shared_ptr<T> t, const std::string_view & n, const std::string_view & f, int l) :
+ PluginOf<T>::PluginOf(std::shared_ptr<T> t, const std::string_view n, const std::string_view f, int l) :
Plugin(n, f, l), impl(std::move(t))
{
}
@@ -40,28 +40,28 @@ namespace AdHoc {
template<typename T>
void
- PluginManager::add(const std::shared_ptr<T> & i, const std::string_view & n, const std::string_view & f, int l)
+ PluginManager::add(const std::shared_ptr<T> & i, const std::string_view n, const std::string_view f, int l)
{
add(std::make_shared<PluginOf<T>>(i, n, f, l));
}
template<typename T>
void
- PluginManager::remove(const std::string_view & n)
+ PluginManager::remove(const std::string_view n)
{
remove(n, typeid(T));
}
template<typename T>
std::shared_ptr<const PluginOf<T>>
- PluginManager::get(const std::string_view & n) const
+ PluginManager::get(const std::string_view n) const
{
return std::dynamic_pointer_cast<const PluginOf<T>>(get(n, typeid(T)));
}
template<typename T>
std::shared_ptr<T>
- PluginManager::getImplementation(const std::string_view & n) const
+ PluginManager::getImplementation(const std::string_view n) const
{
return std::static_pointer_cast<T>(get<T>(n)->implementation());
}
@@ -97,12 +97,12 @@ namespace AdHoc {
#define INSTANTIATEPLUGINOF(...) \
template class AdHoc::PluginOf<__VA_ARGS__>; \
template DLL_PUBLIC void AdHoc::PluginManager::add<__VA_ARGS__>( \
- const std::shared_ptr<__VA_ARGS__> &, const std::string_view &, const std::string_view &, int); \
- template DLL_PUBLIC void AdHoc::PluginManager::remove<__VA_ARGS__>(const std::string_view &); \
+ const std::shared_ptr<__VA_ARGS__> &, const std::string_view, const std::string_view, int); \
+ template DLL_PUBLIC void AdHoc::PluginManager::remove<__VA_ARGS__>(const std::string_view); \
template DLL_PUBLIC std::shared_ptr<const AdHoc::PluginOf<__VA_ARGS__>> AdHoc::PluginManager::get<__VA_ARGS__>( \
- const std::string_view &) const; \
+ const std::string_view) const; \
template DLL_PUBLIC std::shared_ptr<__VA_ARGS__> AdHoc::PluginManager::getImplementation<__VA_ARGS__>( \
- const std::string_view &) const; \
+ const std::string_view) const; \
template DLL_PUBLIC std::set<std::shared_ptr<const AdHoc::PluginOf<__VA_ARGS__>>> \
AdHoc::PluginManager::getAll<__VA_ARGS__>() const; \
template DLL_PUBLIC void AdHoc::PluginManager::addResolver<__VA_ARGS__>( \
diff --git a/libadhocutil/unittests/testCurl.cpp b/libadhocutil/unittests/testCurl.cpp
index c60c242..b07c774 100644
--- a/libadhocutil/unittests/testCurl.cpp
+++ b/libadhocutil/unittests/testCurl.cpp
@@ -26,7 +26,7 @@ discard(void *, size_t sz, size_t nm, void *)
}
AdHocFormatter(FileUrl, "file://%?/%?");
-const auto urlGen = [](const std::string_view & url) {
+const auto urlGen = [](const std::string_view url) {
return FileUrl::get(rootDir.string(), url);
};
diff --git a/libadhocutil/unittests/testPluginsRuntime.cpp b/libadhocutil/unittests/testPluginsRuntime.cpp
index 9b3279d..9730c5b 100644
--- a/libadhocutil/unittests/testPluginsRuntime.cpp
+++ b/libadhocutil/unittests/testPluginsRuntime.cpp
@@ -23,9 +23,9 @@ struct GetLibPath {
};
BOOST_TEST_GLOBAL_FIXTURE(GetLibPath);
-static std::optional<std::string> nullResolver(const std::type_info &, const std::string_view &);
-static std::optional<std::string> badResolver(const std::type_info &, const std::string_view &);
-static std::optional<std::string> goodResolver(const std::type_info &, const std::string_view &);
+static std::optional<std::string> nullResolver(const std::type_info &, const std::string_view);
+static std::optional<std::string> badResolver(const std::type_info &, const std::string_view);
+static std::optional<std::string> goodResolver(const std::type_info &, const std::string_view);
BOOST_AUTO_TEST_CASE(ready)
{
@@ -48,19 +48,19 @@ BOOST_AUTO_TEST_CASE(loadAndUnloadlib)
}
std::optional<std::string>
-nullResolver(const std::type_info &, const std::string_view &)
+nullResolver(const std::type_info &, const std::string_view)
{
return {};
}
std::optional<std::string>
-badResolver(const std::type_info &, const std::string_view &)
+badResolver(const std::type_info &, const std::string_view)
{
return std::string("dontexist");
}
std::optional<std::string>
-goodResolver(const std::type_info & t, const std::string_view & n)
+goodResolver(const std::type_info & t, const std::string_view n)
{
BOOST_REQUIRE_EQUAL(typeid(BaseThing), t);
BOOST_REQUIRE_EQUAL("ImplOfThing", n);