lunch-rest/meal.cpp

20 lines
608 B
C++
Raw Permalink Normal View History

2020-09-14 22:55:03 +00:00
#include "meal.hpp"
2020-09-14 23:30:34 +00:00
#include <sstream>
2020-09-14 22:55:03 +00:00
std::ostream &operator<<(std::ostream &os, const LunchRest::Meal &meal) {
if(meal.isSoup())
os << "SOUP ";
os << meal.getName();
if(meal.getDesc() != "")
os << " - " << meal.getDesc();
if(meal.getPrice() > 0)
os << ", " << meal.getPrice() << " czk";
return os;
}
2020-09-14 23:30:34 +00:00
std::string LunchRest::Meal::jsonify() const {
std::stringstream ss;
ss << "{\"name\": \"" << _name << "\", \"description\": \"" << _desc << "\", \"isSoup\": " << (_isSoup ? "true" : "false") << ", \"price\": " << _price << "}";
return ss.str();
}