Skip to content

Commit

Permalink
clang-tidy modernize-pass-by-value fix
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele77 committed Mar 18, 2021
1 parent 913aec7 commit 3663d96
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion examples/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

#include "cli/clilocalsession.h"
#include "cli/cli.h"
#include <utility>
#include <vector>

using namespace cli;
Expand All @@ -55,7 +56,7 @@ using namespace std;
class Plugin
{
public:
Plugin(const string& _name) : name(_name) { cout << "Plugin " << name << " loaded" << endl; }
Plugin(string _name) : name(std::move(_name)) { cout << "Plugin " << name << " loaded" << endl; }
virtual ~Plugin() { cout << "Plugin " << name << " unloaded" << endl; }
const string& Name() const { return name; }
private:
Expand Down
29 changes: 15 additions & 14 deletions include/cli/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#ifndef CLI_H_
#define CLI_H_

#include <iostream>
#include <string>
#include <vector>
#include <memory>
Expand All @@ -44,6 +43,8 @@
#include "detail/fromstring.h"
#include "historystorage.h"
#include "volatilehistorystorage.h"
#include <iostream>
#include <utility>

namespace cli
{
Expand Down Expand Up @@ -128,7 +129,7 @@ namespace cli
) :
globalHistoryStorage(std::move(historyStorage)),
rootMenu(std::move(_rootMenu)),
exitAction(_exitAction)
exitAction(std::move(_exitAction))
{
}

Expand Down Expand Up @@ -191,7 +192,7 @@ namespace cli
class Command
{
public:
explicit Command(const std::string& _name) : name(_name), enabled(true) {}
explicit Command(std::string _name) : name(std::move(_name)), enabled(true) {}
virtual ~Command() = default;
virtual void Enable() { enabled = true; }
virtual void Disable() { enabled = false; }
Expand Down Expand Up @@ -313,9 +314,9 @@ namespace cli
private:
struct Descriptor
{
Descriptor() {}
Descriptor(const std::weak_ptr<Command>& c, const std::weak_ptr<CmdVec>& v) :
cmd(c), cmds(v)
Descriptor() = default;
Descriptor(std::weak_ptr<Command> c, std::weak_ptr<CmdVec> v) :
cmd(std::move(c)), cmds(std::move(v))
{}
void Enable()
{
Expand Down Expand Up @@ -359,8 +360,8 @@ namespace cli

Menu() : Command({}), parent(nullptr), description(), cmds(std::make_shared<Cmds>()) {}

Menu(const std::string& _name, const std::string& desc = "(menu)") :
Command(_name), parent(nullptr), description(desc), cmds(std::make_shared<Cmds>())
Menu(const std::string& _name, std::string desc = "(menu)") :
Command(_name), parent(nullptr), description(std::move(desc)), cmds(std::make_shared<Cmds>())
{}

template <typename F>
Expand Down Expand Up @@ -568,10 +569,10 @@ namespace cli
VariadicFunctionCommand(
const std::string& _name,
F fun,
const std::string& desc,
const std::vector<std::string>& parDesc
std::string desc,
std::vector<std::string> parDesc
)
: Command(_name), func(std::move(fun)), description(desc), parameterDesc(parDesc)
: Command(_name), func(std::move(fun)), description(std::move(desc)), parameterDesc(std::move(parDesc))
{
}

Expand Down Expand Up @@ -626,10 +627,10 @@ namespace cli
FreeformCommand(
const std::string& _name,
F fun,
const std::string& desc,
const std::vector<std::string>& parDesc
std::string desc,
std::vector<std::string> parDesc
)
: Command(_name), func(std::move(fun)), description(desc), parameterDesc(parDesc)
: Command(_name), func(std::move(fun)), description(std::move(desc)), parameterDesc(std::move(parDesc))
{
}

Expand Down
5 changes: 3 additions & 2 deletions include/cli/detail/split.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
#ifndef CLI_DETAIL_SPLIT_H_
#define CLI_DETAIL_SPLIT_H_

#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

namespace cli
{
Expand All @@ -42,7 +43,7 @@ namespace detail
class Text
{
public:
explicit Text(const std::string& _input) : input(_input)
explicit Text(std::string _input) : input(std::move(_input))
{
}
void SplitInto(std::vector<std::string>& strs)
Expand Down
5 changes: 3 additions & 2 deletions include/cli/filehistorystorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@

#include "historystorage.h"
#include <fstream>
#include <utility>

namespace cli
{

class FileHistoryStorage : public HistoryStorage
{
public:
FileHistoryStorage(const std::string& _fileName, std::size_t size = 1000) :
FileHistoryStorage(std::string _fileName, std::size_t size = 1000) :
maxSize(size),
fileName(_fileName)
fileName(std::move(_fileName))
{
}
void Store(const std::vector<std::string>& cmds) override
Expand Down

0 comments on commit 3663d96

Please sign in to comment.