diff --git a/daemon/src/history/historyitem.cpp b/daemon/src/history/historyitem.cpp index ddf1668a53b512c835f41f5c47552df25ae016f6..aca76630bec0fe7e67d5220e5ffa310db9e7991f 100644 --- a/daemon/src/history/historyitem.cpp +++ b/daemon/src/history/historyitem.cpp @@ -30,14 +30,20 @@ * as that of the covered work. */ -#include <historyitem.h> +#include "historyitem.h" #include <sstream> -#include "stdlib.h" -#include <manager.h> - -#define ITEM_SEPARATOR "|" - -HistoryItem::HistoryItem(std::string timestamp_start, CallType call_type, std::string timestamp_stop, std::string name, std::string number, std::string id, std::string account_id, std::string recording, std::string confID, std::string timeAdded) +#include <cstdlib> +#include "manager.h" + +static const char * const ITEM_SEPARATOR = "|"; + +HistoryItem::HistoryItem(const std::string ×tamp_start, + CallType call_type, const std::string ×tamp_stop, + const std::string &name, const std::string &number, + const std::string &id, const std::string &account_id, + const std::string &recording, + const std::string &confID, + const std::string &timeAdded) : timestamp_start_(timestamp_start), timestamp_stop_(timestamp_stop), call_type_(call_type), @@ -53,11 +59,9 @@ HistoryItem::HistoryItem(std::string timestamp_start, CallType call_type, std::s HistoryItem::HistoryItem(std::string serialized_form) { - int index = 0; - - while (serialized_form.find(ITEM_SEPARATOR, 0) != std::string::npos) { + for (int index = 0; serialized_form.find(ITEM_SEPARATOR, 0) != std::string::npos; ++index) { size_t pos = serialized_form.find(ITEM_SEPARATOR, 0); - std::string tmp = serialized_form.substr(0, pos); + std::string tmp(serialized_form.substr(0, pos)); serialized_form.erase(0, pos + 1); switch (index) { @@ -98,8 +102,6 @@ HistoryItem::HistoryItem(std::string serialized_form) ERROR("Unserialized form %d not recognized\n", index); break; } - - ++index; } } diff --git a/daemon/src/history/historyitem.h b/daemon/src/history/historyitem.h index f54a6c463a2aa4f8804355f03c51ec9dbdc81271..a7cfeef7b65015ae94aa06afbfee17c396f4081b 100644 --- a/daemon/src/history/historyitem.h +++ b/daemon/src/history/historyitem.h @@ -59,7 +59,10 @@ class HistoryItem { * @param Configuration ID * @param time added */ - HistoryItem(std::string, CallType, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string); + HistoryItem(const std::string&, CallType, const std::string&, + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&, const std::string&, + const std::string&); /* * Constructor from a serialized form