Skip to content

Commit

Permalink
Modify the Result class in orm (drogonframework#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
an-tao authored Aug 16, 2020
1 parent f0110a6 commit f1a7462
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
5 changes: 2 additions & 3 deletions drogon_ctl/create_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,9 @@ void create_model::createModelClassFromSqlite3(
data["primaryKeyType"] = pkTypes;
}
data["columns"] = cols;
std::ofstream headerFile(path + "/" + className + ".h",
std::ofstream::out);
std::ofstream headerFile(path + "/" + className + ".h", std::ofstream::out);
std::ofstream sourceFile(path + "/" + className + ".cc",
std::ofstream::out);
std::ofstream::out);
auto templ = DrTemplateBase::newTemplate("model_h.csp");
headerFile << templ->genText(data);
templ = DrTemplateBase::newTemplate("model_cc.csp");
Expand Down
9 changes: 5 additions & 4 deletions lib/src/HttpRequestImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,11 @@ void HttpRequestImpl::appendToBuffer(trantor::MsgBuffer *output) const
if (!passThrough_ && (!content.empty() || !content_.empty()))
{
char buf[64];
auto len = snprintf(buf,
sizeof(buf),
contentLengthFormatString<decltype(content.length())>(),
content.length() + content_.length());
auto len =
snprintf(buf,
sizeof(buf),
contentLengthFormatString<decltype(content.length())>(),
content.length() + content_.length());
output->append(buf, len);
if (contentTypeString_.empty())
{
Expand Down
10 changes: 5 additions & 5 deletions lib/src/HttpResponseImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ using namespace drogon;

namespace drogon
{

// "Fri, 23 Aug 2019 12:58:03 GMT" length = 29
static const size_t httpFullDateStringLength = 29;
static inline void doResponseCreateAdvices(
Expand Down Expand Up @@ -284,10 +283,11 @@ void HttpResponseImpl::makeHeaderString(trantor::MsgBuffer &buffer)
LOG_SYSERR << sendfileName_ << " stat error";
return;
}
len = snprintf(buffer.beginWrite(),
buffer.writableBytes(),
contentLengthFormatString<decltype(filestat.st_size)>(),
filestat.st_size);
len = snprintf(
buffer.beginWrite(),
buffer.writableBytes(),
contentLengthFormatString<decltype(filestat.st_size)>(),
filestat.st_size);
}
buffer.hasWritten(len);
if (headers_.find("Connection") == headers_.end())
Expand Down
12 changes: 4 additions & 8 deletions orm_lib/inc/drogon/orm/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ class Result
*/
unsigned long long insertId() const noexcept;

#ifdef _MSC_VER
Result() = default;
#endif

private:
ResultImplPtr resultPtr_;

Expand All @@ -142,14 +146,6 @@ class Result
const char *getValue(SizeType row, RowSizeType column) const;
bool isNull(SizeType row, RowSizeType column) const;
FieldSizeType getLength(SizeType row, RowSizeType column) const;
#ifdef _MSC_VER
public:
#else
protected:
#endif
Result()
{
}
};
inline void swap(Result &one, Result &two) noexcept
{
Expand Down
5 changes: 4 additions & 1 deletion orm_lib/src/ResultImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ namespace drogon
{
namespace orm
{
class ResultImpl : public trantor::NonCopyable, public Result
class ResultImpl : public trantor::NonCopyable
{
public:
ResultImpl() = default;
using SizeType = Result::SizeType;
using RowSizeType = Result::RowSizeType;
using FieldSizeType = Result::FieldSizeType;
virtual SizeType size() const noexcept = 0;
virtual RowSizeType columns() const noexcept = 0;
virtual const char *columnName(RowSizeType Number) const = 0;
Expand Down

0 comments on commit f1a7462

Please sign in to comment.