lunch-rest/meal.cpp
2020-09-15 01:30:34 +02:00

20 lines
608 B
C++

#include "meal.hpp"
#include <sstream>
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;
}
std::string LunchRest::Meal::jsonify() const {
std::stringstream ss;
ss << "{\"name\": \"" << _name << "\", \"description\": \"" << _desc << "\", \"isSoup\": " << (_isSoup ? "true" : "false") << ", \"price\": " << _price << "}";
return ss.str();
}