Skip to content

Commit

Permalink
Merge pull request #135 from belugum/json_constness
Browse files Browse the repository at this point in the history
Fix constness on json dump method #133
  • Loading branch information
The-EDev authored May 18, 2021
2 parents 7e72f28 + 7d6f82c commit d4b4c08
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions include/crow/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -1606,14 +1606,14 @@ namespace crow

private:

inline void dump_string(const std::string& str, std::string& out)
inline void dump_string(const std::string& str, std::string& out) const
{
out.push_back('"');
escape(str, out);
out.push_back('"');
}

inline void dump_internal(const wvalue& v, std::string& out)
inline void dump_internal(const wvalue& v, std::string& out) const
{
switch(v.t_)
{
Expand Down Expand Up @@ -1689,7 +1689,7 @@ namespace crow
}

public:
std::string dump()
std::string dump() const
{
std::string ret;
ret.reserve(estimate_length());
Expand Down
10 changes: 5 additions & 5 deletions include/crow/multipart.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace crow
}

///Represent all parts as a string (**does not include message headers**)
std::string dump() override
std::string dump() const override
{
std::stringstream str;
std::string delimiter = dd + boundary;
Expand All @@ -60,7 +60,7 @@ namespace crow
}

///Represent an individual part as a string
std::string dump(int part_)
std::string dump(int part_) const
{
std::stringstream str;
part item = parts[part_];
Expand Down Expand Up @@ -92,7 +92,7 @@ namespace crow

private:

std::string get_boundary(const std::string& header)
std::string get_boundary(const std::string& header) const
{
size_t found = header.find("boundary=");
if (found)
Expand Down Expand Up @@ -181,14 +181,14 @@ namespace crow
}
}

inline std::string trim (std::string& string, const char& excess = '"')
inline std::string trim (std::string& string, const char& excess = '"') const
{
if (string.length() > 1 && string[0] == excess && string[string.length()-1] == excess)
return string.substr(1, string.length()-2);
return string;
}

inline std::string pad (std::string& string, const char& padding = '"')
inline std::string pad (std::string& string, const char& padding = '"') const
{
return (padding + string + padding);
}
Expand Down
2 changes: 1 addition & 1 deletion include/crow/returnable.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace crow
struct returnable
{
std::string content_type;
virtual std::string dump() = 0;
virtual std::string dump() const = 0;

returnable(std::string ctype) : content_type {ctype}
{}
Expand Down

0 comments on commit d4b4c08

Please sign in to comment.