member variables renamed

This commit is contained in:
Martin Brodbeck 2022-07-07 15:03:39 +02:00
parent 21571215bc
commit 3e6e587df8
9 changed files with 37 additions and 41 deletions

View file

@ -5,34 +5,34 @@
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
Article::Article(int price) : price_(price) {} Article::Article(int price) : m_price(price) {}
void Article::setArticleNo(int articleNo) { articleNo_ = articleNo; } void Article::setArticleNo(int articleNo) { m_articleNo = articleNo; }
void Article::setPrice(int price) { price_ = price; } void Article::setPrice(int price) { m_price = price; }
void Article::setDescription(const std::string& description) { description_ = description; } void Article::setDescription(const std::string& description) { m_description = description; }
void Article::setSale(Sale* salePtr) { salePtr_ = salePtr; } void Article::setSale(Sale* salePtr) { m_salePtr = salePtr; }
void Article::setSeller(Seller* sellerPtr) { sellerPtr_ = sellerPtr; } void Article::setSeller(Seller* sellerPtr) { m_sellerPtr = sellerPtr; }
bool Article::isSold() { return salePtr_ ? true : false; } bool Article::isSold() { return m_salePtr ? true : false; }
std::string Article::getDescription() { return description_; } std::string Article::getDescription() { return m_description; }
Seller* Article::getSeller() { return sellerPtr_; } Seller* Article::getSeller() { return m_sellerPtr; }
Sale* Article::getSale() { return salePtr_; } Sale* Article::getSale() { return m_salePtr; }
int Article::getPrice() const { return price_; } int Article::getPrice() const { return m_price; }
std::string Article::getPriceAsString() const { return formatCentAsEuroString(price_); } std::string Article::getPriceAsString() const { return formatCentAsEuroString(m_price); }
int Article::getArticleNo() const { return articleNo_; } int Article::getArticleNo() const { return m_articleNo; }
std::string Article::getCompleteArticleNo() const std::string Article::getCompleteArticleNo() const
{ {
std::stringstream artNoStream; std::stringstream artNoStream;
artNoStream << sourceNo_ << "K" << std::setfill('0') << std::setw(5) << articleNo_; artNoStream << m_sourceNo << "K" << std::setfill('0') << std::setw(5) << m_articleNo;
return artNoStream.str(); return artNoStream.str();
} }

View file

@ -33,12 +33,11 @@ class Article : public EntityUuid
std::string getPriceAsString() const; std::string getPriceAsString() const;
private: private:
Seller* sellerPtr_{}; Seller* m_sellerPtr{};
Sale* salePtr_{}; Sale* m_salePtr{};
int articleNo_{}; int m_articleNo{};
int price_{}; int m_price{};
std::string description_{}; std::string m_description{};
}; };
#endif #endif

View file

@ -1,6 +1,3 @@
#include "entity.h" #include "entity.h"
Entity::State Entity::getState() const Entity::State Entity::getState() const { return m_state; }
{
return state_;
}

View file

@ -6,11 +6,11 @@ class Entity
public: public:
enum class State { NEW, UPDATE, DELETE, OK }; enum class State { NEW, UPDATE, DELETE, OK };
virtual ~Entity() = default; virtual ~Entity() = default;
void setState(State state) { state_ = state; } void setState(State state) { m_state = state; }
virtual State getState() const; virtual State getState() const;
private: private:
State state_{State::NEW}; State m_state{State::NEW};
}; };
#endif // ENTITY_H #endif // ENTITY_H

View file

@ -1,5 +1,5 @@
#include "entityint.h" #include "entityint.h"
EntityInt::EntityInt(int id) { id_ = id; } EntityInt::EntityInt(int id) { m_id = id; }
void EntityInt::setId(int id) { id_ = id; } void EntityInt::setId(int id) { m_id = id; }

View file

@ -10,10 +10,10 @@ class EntityInt : public Entity
virtual ~EntityInt() = default; virtual ~EntityInt() = default;
EntityInt(int id); EntityInt(int id);
void setId(int id); void setId(int id);
int getId() const { return id_; }; int getId() const { return m_id; };
protected: protected:
int id_{}; int m_id{};
}; };
#endif // ENTITY_INT_H #endif // ENTITY_INT_H

View file

@ -8,15 +8,15 @@
void EntityUuid::createUuid() void EntityUuid::createUuid()
{ {
static boost::uuids::random_generator generator{}; static boost::uuids::random_generator generator{};
uuid_ = generator(); m_uuid = generator();
} }
void EntityUuid::setUuidFromString(const std::string& uuidString) void EntityUuid::setUuidFromString(const std::string& uuidString)
{ {
boost::uuids::string_generator generator{}; boost::uuids::string_generator generator{};
uuid_ = generator(uuidString); m_uuid = generator(uuidString);
} }
void EntityUuid::setSourceNo(int sourceNo) { sourceNo_ = sourceNo; } void EntityUuid::setSourceNo(int sourceNo) { m_sourceNo = sourceNo; }
int EntityUuid::getSourceNo() const { return sourceNo_; } int EntityUuid::getSourceNo() const { return m_sourceNo; }

View file

@ -18,15 +18,15 @@ class EntityUuid : public Entity
void setUuidFromString(const std::string& uuidString); void setUuidFromString(const std::string& uuidString);
void setSourceNo(int sourceNo); void setSourceNo(int sourceNo);
const boost::uuids::uuid& getUuid() const { return uuid_; }; const boost::uuids::uuid& getUuid() const { return m_uuid; };
std::string getUuidAsString() const { return boost::uuids::to_string(uuid_); } std::string getUuidAsString() const { return boost::uuids::to_string(m_uuid); }
virtual int getSourceNo() const; virtual int getSourceNo() const;
protected: protected:
int sourceNo_{}; int m_sourceNo{};
private: private:
boost::uuids::uuid uuid_{}; boost::uuids::uuid m_uuid{};
}; };
#endif // ENTITY_UUID_H #endif // ENTITY_UUID_H

View file

@ -38,7 +38,7 @@ std::string Seller::getSellerNoAsString() const
{ {
std::stringstream selNoStr; std::stringstream selNoStr;
selNoStr << std::setfill('0') << std::setw(3) << id_; selNoStr << std::setfill('0') << std::setw(3) << m_id;
return selNoStr.str(); return selNoStr.str();
; ;
@ -103,8 +103,8 @@ int Seller::sumInCents()
std::string Seller::sumAsString() { return formatCentAsEuroString(sumInCents()); } std::string Seller::sumAsString() { return formatCentAsEuroString(sumInCents()); }
bool operator<(const Seller& li, const Seller& re) { return li.id_ < re.id_; } bool operator<(const Seller& li, const Seller& re) { return li.m_id < re.m_id; }
bool operator<(const std::unique_ptr<Seller>& li, const std::unique_ptr<Seller>& re) bool operator<(const std::unique_ptr<Seller>& li, const std::unique_ptr<Seller>& re)
{ {
return li->id_ < re->id_; return li->m_id < re->m_id;
} }