mirror of
https://github.com/drogonframework/drogon.git
synced 2025-09-09 00:00:40 -04:00
Modify file formats and comments
This commit is contained in:
parent
b53073f848
commit
032aa19a53
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* CommandHandler.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* cmd.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* cmd.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* create.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* create.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* create_controller.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -2,12 +2,13 @@
|
||||
*
|
||||
* create_filter.cc
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -2,12 +2,13 @@
|
||||
*
|
||||
* create_filter.h
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -2,9 +2,9 @@
|
||||
*
|
||||
* create_project.cc
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -2,9 +2,9 @@
|
||||
*
|
||||
* create_project.h
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -2,9 +2,9 @@
|
||||
*
|
||||
* create_view.cc
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* create_view.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* help.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* help.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,16 +1,15 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* main.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
* this is a drogon lib tool program
|
||||
* run drogon_ctl help to get usage
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cmd.h"
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* version.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* version.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* CacheMap.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -60,16 +60,17 @@ class CacheMap
|
||||
{
|
||||
public:
|
||||
/// constructor
|
||||
/// @param loop
|
||||
/// eventloop pointer
|
||||
/// @param tickInterval
|
||||
/// second
|
||||
/// @param wheelsNum
|
||||
/// number of wheels
|
||||
/// @param bucketsNumPerWheel
|
||||
/// buckets number per wheel
|
||||
/// The max delay of the CacheMap is about tickInterval*(bucketsNumPerWheel^wheelsNum) seconds.
|
||||
|
||||
/**
|
||||
* @param loop
|
||||
* eventloop pointer
|
||||
* @param tickInterval
|
||||
* second
|
||||
* @param wheelsNum
|
||||
* number of wheels
|
||||
* @param bucketsNumPerWheel
|
||||
* buckets number per wheel
|
||||
* The max delay of the CacheMap is about tickInterval*(bucketsNumPerWheel^wheelsNum) seconds.
|
||||
*/
|
||||
CacheMap(trantor::EventLoop *loop,
|
||||
float tickInterval = TICK_INTERVAL,
|
||||
size_t wheelsNum = WHEELS_NUM,
|
||||
@ -137,9 +138,11 @@ class CacheMap
|
||||
WeakCallbackEntryPtr _weakEntryPtr;
|
||||
} MapValue;
|
||||
|
||||
//If timeout>0,the value will be erased
|
||||
//within the 'timeout' seconds after the last access
|
||||
|
||||
/// Inserts a value of the keyword
|
||||
/**
|
||||
* If timeout>0,the value will be erased
|
||||
* within the 'timeout' seconds after the last access
|
||||
*/
|
||||
void insert(const T1 &key, T2 &&value, size_t timeout = 0, std::function<void()> timeoutCallback = std::function<void()>())
|
||||
{
|
||||
if (timeout > 0)
|
||||
@ -188,6 +191,7 @@ class CacheMap
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the reference to the value of the keyword.
|
||||
T2 &operator[](const T1 &key)
|
||||
{
|
||||
int timeout = 0;
|
||||
@ -204,6 +208,7 @@ class CacheMap
|
||||
return _map[key].value;
|
||||
}
|
||||
|
||||
/// Determine if the value of the keyword exists
|
||||
bool find(const T1 &key)
|
||||
{
|
||||
int timeout = 0;
|
||||
@ -223,6 +228,11 @@ class CacheMap
|
||||
return flag;
|
||||
}
|
||||
|
||||
/// Atomically find and get the value of a keyword
|
||||
/**
|
||||
* Returns true when the value is found, and the value
|
||||
* is assigned to the @param value
|
||||
*/
|
||||
bool findAndFetch(const T1 &key, T2 &value)
|
||||
{
|
||||
int timeout = 0;
|
||||
@ -242,10 +252,10 @@ class CacheMap
|
||||
return flag;
|
||||
}
|
||||
|
||||
/// Erases the value of the keyword.
|
||||
void erase(const T1 &key)
|
||||
{
|
||||
//in this case,we don't evoke the timeout callback;
|
||||
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
_map.erase(key);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* Cookis.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* DeleteFilter.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* DrClassMap.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* DrObject.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -45,10 +45,10 @@ class DrObjectBase
|
||||
virtual ~DrObjectBase() {}
|
||||
};
|
||||
|
||||
/*
|
||||
* a class template to
|
||||
* implement the reflection function of creating the class object by class name
|
||||
* */
|
||||
/**
|
||||
* a class template to
|
||||
* implement the reflection function of creating the class object by class name
|
||||
*/
|
||||
template <typename T>
|
||||
class DrObject : public virtual DrObjectBase
|
||||
{
|
||||
@ -96,4 +96,5 @@ class DrObject : public virtual DrObjectBase
|
||||
};
|
||||
template <typename T>
|
||||
typename DrObject<T>::DrAllocator DrObject<T>::_alloc;
|
||||
|
||||
} // namespace drogon
|
||||
|
@ -2,9 +2,9 @@
|
||||
*
|
||||
* DrTemplate.h
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -2,9 +2,9 @@
|
||||
*
|
||||
* DrTemplateBase.h
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -24,10 +24,10 @@ namespace drogon
|
||||
typedef HttpViewData DrTemplateData;
|
||||
class DrTemplateBase : virtual public DrObjectBase
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<DrTemplateBase> newTemplate(std::string templateName);
|
||||
virtual std::string genText(const DrTemplateData &data = DrTemplateData()) = 0;
|
||||
virtual ~DrTemplateBase(){};
|
||||
DrTemplateBase(){};
|
||||
public:
|
||||
static std::shared_ptr<DrTemplateBase> newTemplate(std::string templateName);
|
||||
virtual std::string genText(const DrTemplateData &data = DrTemplateData()) = 0;
|
||||
virtual ~DrTemplateBase(){};
|
||||
DrTemplateBase(){};
|
||||
};
|
||||
} // namespace drogon
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* FileUpload.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* GetFilter.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpAppFramework.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -61,7 +61,7 @@ inline std::string getGitCommit()
|
||||
class HttpAppFramework : public trantor::NonCopyable
|
||||
{
|
||||
public:
|
||||
///Get the instance of HttpAppFramework
|
||||
///Get the instance of HttpAppFramework
|
||||
/**
|
||||
* HttpAppFramework works at singleton mode, so any calling of this
|
||||
* method will get the same instance;
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpBinder.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -60,7 +60,7 @@ class HttpBinderBase
|
||||
{
|
||||
public:
|
||||
virtual void handleHttpRequest(std::list<std::string> &pathParameter,
|
||||
const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> callback) = 0;
|
||||
const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> callback) = 0;
|
||||
virtual size_t paramCount() = 0;
|
||||
virtual ~HttpBinderBase() {}
|
||||
|
||||
@ -75,7 +75,7 @@ class HttpBinder : public HttpBinderBase
|
||||
public:
|
||||
typedef FUNCTION FunctionType;
|
||||
virtual void handleHttpRequest(std::list<std::string> &pathParameter,
|
||||
const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> callback) override
|
||||
const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> callback) override
|
||||
{
|
||||
run(pathParameter, req, callback);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* HttpController.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -58,12 +58,12 @@ class HttpController : public DrObject<T>
|
||||
}
|
||||
if (pattern.empty() || pattern[0] == '/')
|
||||
app().registerHttpMethod(path + pattern,
|
||||
std::forward<FUNCTION>(function),
|
||||
filtersAndMethods);
|
||||
std::forward<FUNCTION>(function),
|
||||
filtersAndMethods);
|
||||
else
|
||||
app().registerHttpMethod(path + "/" + pattern,
|
||||
std::forward<FUNCTION>(function),
|
||||
filtersAndMethods);
|
||||
std::forward<FUNCTION>(function),
|
||||
filtersAndMethods);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpFilter.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* HttpRequest.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,20 +1,9 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
//
|
||||
// This is a public header file, it must only include public header files.
|
||||
|
||||
/**
|
||||
* taken from muduo and modified
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpResponse.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpSimpleController.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpViewBase.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* HttpViewData.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
* InnerIpFilter.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* LocalHostFilter.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,4 +1,19 @@
|
||||
//this file is generated by program automatically,don't modify it!
|
||||
|
||||
/**
|
||||
*
|
||||
* NotFound.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include <drogon/DrTemplate.h>
|
||||
using namespace drogon;
|
||||
class NotFound : public DrTemplate<NotFound>
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* PostFilter.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* PutFilter.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Session.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* WebSocketConnection.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* WebSocketController.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* ConfigLoader.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* ConfigLoader.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* Cookie.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -21,14 +21,6 @@ const std::string Cookie::cookieString() const
|
||||
ret.append(_key).append("= ").append(_value).append("; ");
|
||||
if (_expiresDate.microSecondsSinceEpoch() > 0)
|
||||
{
|
||||
//add expiresDate string
|
||||
// struct tm tm1=_expiresDate.tmStruct();
|
||||
// char timeBuf[64];
|
||||
// asctime_r(&tm1,timeBuf);
|
||||
// std::string timeStr(timeBuf);
|
||||
// std::string::size_type len=timeStr.length();
|
||||
// timeStr =timeStr.substr(0,len-1)+" GMT";
|
||||
|
||||
ret.append("Expires= ").append(getHttpFullDate(_expiresDate)).append("; ");
|
||||
}
|
||||
if (!_domain.empty())
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* DeleteFilter.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* DrClassMap.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -2,15 +2,16 @@
|
||||
*
|
||||
* DrTemplateBase.cc
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include <drogon/DrTemplateBase.h>
|
||||
#include <drogon/DrClassMap.h>
|
||||
#include <trantor/utils/Logger.h>
|
||||
|
@ -1,3 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* FileUpload.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include <drogon/utils/Utilities.h>
|
||||
#include <drogon/FileUpload.h>
|
||||
#include <drogon/HttpAppFramework.h>
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* GetFilter.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -2,15 +2,16 @@
|
||||
*
|
||||
* HttpAppFrameworkImpl.cc
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include "HttpAppFrameworkImpl.h"
|
||||
#include "ConfigLoader.h"
|
||||
#include "HttpServer.h"
|
||||
|
@ -1,16 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpAppFrameworkImpl.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "HttpRequestImpl.h"
|
||||
@ -81,7 +82,7 @@ class HttpAppFrameworkImpl : public HttpAppFramework
|
||||
virtual void setStaticFilesCacheTime(int cacheTime) override { _staticFilesCacheTime = cacheTime; }
|
||||
virtual int staticFilesCacheTime() const override { return _staticFilesCacheTime; }
|
||||
virtual void setIdleConnectionTimeout(size_t timeout) override { _idleConnectionTimeout = timeout; }
|
||||
virtual ~HttpAppFrameworkImpl()
|
||||
virtual ~HttpAppFrameworkImpl() noexcept
|
||||
{
|
||||
//Destroy the following objects before _loop destruction
|
||||
_sharedLibManagerPtr.reset();
|
||||
|
@ -1,21 +1,10 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
//
|
||||
|
||||
//taken from muduo and modified
|
||||
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpClientContext.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,28 +1,17 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
//
|
||||
// This is an internal header file, you should not include this.
|
||||
|
||||
//taken from muduo and modified
|
||||
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpClientContext.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "HttpResponseImpl.h"
|
||||
@ -38,7 +27,6 @@ namespace drogon
|
||||
class HttpClientContext
|
||||
{
|
||||
public:
|
||||
|
||||
enum class HttpResponseParseState
|
||||
{
|
||||
kExpectResponseLine,
|
||||
@ -69,7 +57,6 @@ class HttpClientContext
|
||||
_response.reset(new HttpResponseImpl);
|
||||
}
|
||||
|
||||
|
||||
const HttpResponsePtr response() const
|
||||
{
|
||||
return _response;
|
||||
@ -83,7 +70,7 @@ class HttpClientContext
|
||||
{
|
||||
return _response;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
bool processResponseLine(const char *begin, const char *end);
|
||||
|
||||
|
@ -1,3 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* HttpClientImpl.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include "HttpClientImpl.h"
|
||||
#include "HttpRequestImpl.h"
|
||||
#include "HttpClientContext.h"
|
||||
|
@ -1,16 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpClientImpl.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <drogon/HttpClient.h>
|
||||
|
@ -1,21 +1,10 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
//
|
||||
|
||||
//taken from muduo and modified
|
||||
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpRequestImpl.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,21 +1,10 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
//
|
||||
// This is a public header file, it must only include public header files.
|
||||
|
||||
//taken from muduo and modified
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpRequestImpl.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,18 +1,10 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpResponseImpl.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,22 +1,10 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
//
|
||||
// This is a public header file, it must only include public header files.
|
||||
|
||||
//taken from muduo and modified
|
||||
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpResponseImpl.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -322,11 +310,11 @@ class HttpResponseImpl : public HttpResponse
|
||||
Version _v;
|
||||
std::string _statusMessage;
|
||||
bool _closeConnection;
|
||||
|
||||
|
||||
size_t _left_body_length;
|
||||
size_t _current_chunk_length;
|
||||
std::shared_ptr<std::string> _bodyPtr;
|
||||
|
||||
|
||||
uint8_t _contentType = CT_TEXT_HTML;
|
||||
|
||||
ssize_t _expriedTime = -1;
|
||||
|
@ -1,20 +1,10 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
//
|
||||
|
||||
//taken from muduo and modified
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpServer.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpServer.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,21 +1,10 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
//
|
||||
|
||||
//taken from muduo and modified
|
||||
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpServerContext.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -180,8 +169,6 @@ bool HttpServerContext::parseRequest(MsgBuffer *buf)
|
||||
}
|
||||
else if (state_ == kExpectBody)
|
||||
{
|
||||
//LOG_INFO << "expectBody:len=" << request_->contentLen;
|
||||
//LOG_INFO << "expectBody:buf=" << buf;
|
||||
if (buf->readableBytes() == 0)
|
||||
{
|
||||
if (request_->contentLen == 0)
|
||||
@ -205,9 +192,6 @@ bool HttpServerContext::parseRequest(MsgBuffer *buf)
|
||||
if (request_->contentLen == 0)
|
||||
{
|
||||
state_ = kGotAll;
|
||||
LOG_TRACE << "post got all:len=" << request_->content_.length();
|
||||
//LOG_INFO<<"content:"<<request_->content_;
|
||||
LOG_TRACE << "content(END)";
|
||||
hasMore = false;
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,17 @@
|
||||
// Copyright 2010, Shuo Chen. All rights reserved.
|
||||
// http://code.google.com/p/muduo/
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the License file.
|
||||
|
||||
// Author: Shuo Chen (chenshuo at chenshuo dot com)
|
||||
//
|
||||
// This is an internal header file, you should not include this.
|
||||
|
||||
//taken from muduo and modified
|
||||
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* HttpServerContext.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "HttpRequestImpl.h"
|
||||
@ -49,8 +38,6 @@ class HttpServerContext
|
||||
|
||||
HttpServerContext(const trantor::TcpConnectionPtr &connPtr);
|
||||
|
||||
// default copy-ctor, dtor and assignment are fine
|
||||
|
||||
// return false if any error
|
||||
bool parseRequest(MsgBuffer *buf);
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* HttpViewBase.h
|
||||
* HttpViewBase.cc
|
||||
* An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include <drogon/HttpViewBase.h>
|
||||
#include <drogon/DrClassMap.h>
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* InnerIpFilter.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* LocalHostFilter.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,4 +1,19 @@
|
||||
//this file is generated by program automatically,don't modify it!
|
||||
|
||||
/**
|
||||
*
|
||||
* NotFound.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include <drogon/NotFound.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* PostFilter.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* PutFilter.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* SharedLibManager.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -1,16 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* @author An Tao
|
||||
* @section LICENSE
|
||||
*
|
||||
* SharedLibManager.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <trantor/utils/NonCopyable.h>
|
||||
|
@ -2,8 +2,9 @@
|
||||
*
|
||||
* Utilities.cc
|
||||
* An Tao
|
||||
*
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -499,7 +500,7 @@ int createPath(const std::string &path)
|
||||
}
|
||||
}
|
||||
pathStack.pop();
|
||||
|
||||
|
||||
if (mkdir(tmpPath.c_str(), 0755) == -1)
|
||||
{
|
||||
LOG_ERROR << "Can't create path:" << path;
|
||||
|
@ -1,3 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* WebSocketConnectionImpl.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include "WebSockectConnectionImpl.h"
|
||||
#include <trantor/net/TcpConnection.h>
|
||||
|
||||
|
@ -1,3 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* WebSocketConnectionImpl.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <drogon/WebSocketConnection.h>
|
||||
|
@ -1,3 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* Md5.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Md5.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
@ -5,6 +5,20 @@
|
||||
*******************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Md5.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MD5_ENCODE_H__
|
||||
#define __MD5_ENCODE_H__
|
||||
|
||||
|
@ -1,3 +1,17 @@
|
||||
/**
|
||||
*
|
||||
* Sha1.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Sha1.h"
|
||||
#include <string.h>
|
||||
|
||||
|
@ -1,3 +1,16 @@
|
||||
/**
|
||||
*
|
||||
* Sha1.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
@ -4,11 +4,14 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <drogon/config.h>
|
||||
|
@ -4,9 +4,11 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
@ -128,8 +130,7 @@ class DbClient : public trantor::NonCopyable
|
||||
internal::SqlBinder operator<<(const std::string &sql);
|
||||
virtual std::shared_ptr<Transaction> newTransaction() = 0;
|
||||
|
||||
|
||||
ClientType type() const { return _type; }
|
||||
ClientType type() const { return _type; }
|
||||
|
||||
private:
|
||||
friend internal::SqlBinder;
|
||||
|
@ -15,9 +15,11 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
@ -46,12 +48,12 @@ namespace orm
|
||||
*/
|
||||
class DrogonDbException
|
||||
{
|
||||
public:
|
||||
/// Support run-time polymorphism, and keep this class abstract
|
||||
virtual ~DrogonDbException() noexcept;
|
||||
public:
|
||||
/// Support run-time polymorphism, and keep this class abstract
|
||||
virtual ~DrogonDbException() noexcept;
|
||||
|
||||
/// Return std::exception base-class object
|
||||
/** Use this to get at the exception's what() function, or to downcast to a
|
||||
/// Return std::exception base-class object
|
||||
/** Use this to get at the exception's what() function, or to downcast to a
|
||||
* more specific type using dynamic_cast.
|
||||
*
|
||||
* Casting directly from DrogonDbException to a specific exception type is not
|
||||
@ -73,22 +75,23 @@ public:
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
virtual const std::exception &base() const noexcept {
|
||||
static std::exception except;
|
||||
return except;
|
||||
} //[t00]
|
||||
virtual const std::exception &base() const noexcept
|
||||
{
|
||||
static std::exception except;
|
||||
return except;
|
||||
} //[t00]
|
||||
};
|
||||
|
||||
/// Run-time Failure encountered by drogon orm lib, similar to std::runtime_error
|
||||
class Failure : public DrogonDbException, public std::runtime_error
|
||||
{
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit Failure(const std::string &);
|
||||
public:
|
||||
explicit Failure(const std::string &);
|
||||
};
|
||||
|
||||
/// Exception class for lost or failed backend connection.
|
||||
@ -112,9 +115,9 @@ public:
|
||||
*/
|
||||
class BrokenConnection : public Failure
|
||||
{
|
||||
public:
|
||||
BrokenConnection();
|
||||
explicit BrokenConnection(const std::string &);
|
||||
public:
|
||||
BrokenConnection();
|
||||
explicit BrokenConnection(const std::string &);
|
||||
};
|
||||
|
||||
/// Exception class for failed queries.
|
||||
@ -123,21 +126,21 @@ public:
|
||||
*/
|
||||
class SqlError : public Failure
|
||||
{
|
||||
/// Query string. Empty if unknown.
|
||||
const std::string _query;
|
||||
/// SQLSTATE string describing the error type, if known; or empty string.
|
||||
const std::string _sqlState;
|
||||
/// Query string. Empty if unknown.
|
||||
const std::string _query;
|
||||
/// SQLSTATE string describing the error type, if known; or empty string.
|
||||
const std::string _sqlState;
|
||||
|
||||
public:
|
||||
explicit SqlError(
|
||||
const std::string &msg = "",
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr);
|
||||
virtual ~SqlError() noexcept;
|
||||
public:
|
||||
explicit SqlError(
|
||||
const std::string &msg = "",
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr);
|
||||
virtual ~SqlError() noexcept;
|
||||
|
||||
/// The query whose execution triggered the exception
|
||||
const std::string &query() const noexcept;
|
||||
const std::string &sqlState() const noexcept;
|
||||
/// The query whose execution triggered the exception
|
||||
const std::string &query() const noexcept;
|
||||
const std::string &sqlState() const noexcept;
|
||||
};
|
||||
|
||||
/// "Help, I don't know whether transaction was committed successfully!"
|
||||
@ -149,15 +152,15 @@ public:
|
||||
*/
|
||||
class InDoubtError : public Failure
|
||||
{
|
||||
public:
|
||||
explicit InDoubtError(const std::string &);
|
||||
public:
|
||||
explicit InDoubtError(const std::string &);
|
||||
};
|
||||
|
||||
/// The backend saw itself forced to roll back the ongoing transaction.
|
||||
class TransactionRollback : public Failure
|
||||
{
|
||||
public:
|
||||
explicit TransactionRollback(const std::string &);
|
||||
public:
|
||||
explicit TransactionRollback(const std::string &);
|
||||
};
|
||||
|
||||
/// Transaction failed to serialize. Please retry it.
|
||||
@ -171,278 +174,278 @@ public:
|
||||
*/
|
||||
class SerializationFailure : public TransactionRollback
|
||||
{
|
||||
public:
|
||||
explicit SerializationFailure(const std::string &);
|
||||
public:
|
||||
explicit SerializationFailure(const std::string &);
|
||||
};
|
||||
|
||||
/// We can't tell whether our last statement succeeded.
|
||||
class StatementCompletionUnknown : public TransactionRollback
|
||||
{
|
||||
public:
|
||||
explicit StatementCompletionUnknown(const std::string &);
|
||||
public:
|
||||
explicit StatementCompletionUnknown(const std::string &);
|
||||
};
|
||||
|
||||
/// The ongoing transaction has deadlocked. Retrying it may help.
|
||||
class DeadlockDetected : public TransactionRollback
|
||||
{
|
||||
public:
|
||||
explicit DeadlockDetected(const std::string &);
|
||||
public:
|
||||
explicit DeadlockDetected(const std::string &);
|
||||
};
|
||||
|
||||
/// Internal error in internal library
|
||||
class InternalError : public DrogonDbException, public std::logic_error
|
||||
{
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit InternalError(const std::string &);
|
||||
public:
|
||||
explicit InternalError(const std::string &);
|
||||
};
|
||||
|
||||
/// Error in usage of drogon orm library, similar to std::logic_error
|
||||
class UsageError : public DrogonDbException, public std::logic_error
|
||||
{
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit UsageError(const std::string &);
|
||||
public:
|
||||
explicit UsageError(const std::string &);
|
||||
};
|
||||
|
||||
/// Invalid argument passed to drogon orm lib, similar to std::invalid_argument
|
||||
class ArgumentError : public DrogonDbException, public std::invalid_argument
|
||||
{
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit ArgumentError(const std::string &);
|
||||
public:
|
||||
explicit ArgumentError(const std::string &);
|
||||
};
|
||||
|
||||
/// Value conversion failed, e.g. when converting "Hello" to int.
|
||||
class ConversionError : public DrogonDbException, public std::domain_error
|
||||
{
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit ConversionError(const std::string &);
|
||||
public:
|
||||
explicit ConversionError(const std::string &);
|
||||
};
|
||||
|
||||
/// Something is out of range, similar to std::out_of_range
|
||||
class RangeError : public DrogonDbException, public std::out_of_range
|
||||
{
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit RangeError(const std::string &);
|
||||
public:
|
||||
explicit RangeError(const std::string &);
|
||||
};
|
||||
|
||||
/// Query returned an unexpected number of rows.
|
||||
class UnexpectedRows : public RangeError
|
||||
{
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
virtual const std::exception &base() const noexcept override
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit UnexpectedRows(const std::string &msg) : RangeError(msg) {}
|
||||
public:
|
||||
explicit UnexpectedRows(const std::string &msg) : RangeError(msg) {}
|
||||
};
|
||||
|
||||
/// Database feature not supported in current setup
|
||||
class FeatureNotSupported : public SqlError
|
||||
{
|
||||
public:
|
||||
explicit FeatureNotSupported(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit FeatureNotSupported(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
/// Error in data provided to SQL statement
|
||||
class DataException : public SqlError
|
||||
{
|
||||
public:
|
||||
explicit DataException(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit DataException(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class IntegrityConstraintViolation : public SqlError
|
||||
{
|
||||
public:
|
||||
explicit IntegrityConstraintViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit IntegrityConstraintViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class RestrictViolation : public IntegrityConstraintViolation
|
||||
{
|
||||
public:
|
||||
explicit RestrictViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit RestrictViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class NotNullViolation : public IntegrityConstraintViolation
|
||||
{
|
||||
public:
|
||||
explicit NotNullViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit NotNullViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class ForeignKeyViolation : public IntegrityConstraintViolation
|
||||
{
|
||||
public:
|
||||
explicit ForeignKeyViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit ForeignKeyViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class UniqueViolation : public IntegrityConstraintViolation
|
||||
{
|
||||
public:
|
||||
explicit UniqueViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit UniqueViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class CheckViolation : public IntegrityConstraintViolation
|
||||
{
|
||||
public:
|
||||
explicit CheckViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit CheckViolation(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : IntegrityConstraintViolation(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class InvalidCursorState : public SqlError
|
||||
{
|
||||
public:
|
||||
explicit InvalidCursorState(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit InvalidCursorState(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class InvalidSqlStatementName : public SqlError
|
||||
{
|
||||
public:
|
||||
explicit InvalidSqlStatementName(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit InvalidSqlStatementName(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class InvalidCursorName : public SqlError
|
||||
{
|
||||
public:
|
||||
explicit InvalidCursorName(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit InvalidCursorName(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class SyntaxError : public SqlError
|
||||
{
|
||||
public:
|
||||
/// Approximate position in string where error occurred, or -1 if unknown.
|
||||
const int _errorPosition;
|
||||
public:
|
||||
/// Approximate position in string where error occurred, or -1 if unknown.
|
||||
const int _errorPosition;
|
||||
|
||||
explicit SyntaxError(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr,
|
||||
int pos = -1) : SqlError(err, Q, sqlstate), _errorPosition(pos) {}
|
||||
explicit SyntaxError(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr,
|
||||
int pos = -1) : SqlError(err, Q, sqlstate), _errorPosition(pos) {}
|
||||
};
|
||||
|
||||
class UndefinedColumn : public SyntaxError
|
||||
{
|
||||
public:
|
||||
explicit UndefinedColumn(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SyntaxError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit UndefinedColumn(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SyntaxError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class UndefinedFunction : public SyntaxError
|
||||
{
|
||||
public:
|
||||
explicit UndefinedFunction(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SyntaxError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit UndefinedFunction(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SyntaxError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class UndefinedTable : public SyntaxError
|
||||
{
|
||||
public:
|
||||
explicit UndefinedTable(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SyntaxError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit UndefinedTable(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SyntaxError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class InsufficientPrivilege : public SqlError
|
||||
{
|
||||
public:
|
||||
explicit InsufficientPrivilege(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit InsufficientPrivilege(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
/// Resource shortage on the server
|
||||
class InsufficientResources : public SqlError
|
||||
{
|
||||
public:
|
||||
explicit InsufficientResources(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit InsufficientResources(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : SqlError(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class DiskFull : public InsufficientResources
|
||||
{
|
||||
public:
|
||||
explicit DiskFull(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : InsufficientResources(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit DiskFull(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : InsufficientResources(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class OutOfMemory : public InsufficientResources
|
||||
{
|
||||
public:
|
||||
explicit OutOfMemory(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : InsufficientResources(err, Q, sqlstate) {}
|
||||
public:
|
||||
explicit OutOfMemory(
|
||||
const std::string &err,
|
||||
const std::string &Q = "",
|
||||
const char sqlstate[] = nullptr) : InsufficientResources(err, Q, sqlstate) {}
|
||||
};
|
||||
|
||||
class TooManyConnections : public BrokenConnection
|
||||
{
|
||||
public:
|
||||
explicit TooManyConnections(const std::string &err) : BrokenConnection(err) {}
|
||||
public:
|
||||
explicit TooManyConnections(const std::string &err) : BrokenConnection(err) {}
|
||||
};
|
||||
|
||||
// /// PL/pgSQL error
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
@ -123,21 +124,21 @@ class Field
|
||||
{
|
||||
std::vector<std::shared_ptr<T>> ret;
|
||||
auto arrParser = getArrayParser();
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
auto arrVal = arrParser.getNext();
|
||||
if(arrVal.first==ArrayParser::juncture::done)
|
||||
if (arrVal.first == ArrayParser::juncture::done)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(arrVal.first==ArrayParser::juncture::string_value)
|
||||
if (arrVal.first == ArrayParser::juncture::string_value)
|
||||
{
|
||||
T val;
|
||||
std::stringstream ss(std::move(arrVal.second));
|
||||
ss >> val;
|
||||
ret.push_back(std::shared_ptr<T>(new T(val)));
|
||||
}
|
||||
else if(arrVal.first==ArrayParser::juncture::null_value)
|
||||
else if (arrVal.first == ArrayParser::juncture::null_value)
|
||||
{
|
||||
ret.push_back(std::shared_ptr<T>());
|
||||
}
|
||||
|
@ -4,9 +4,11 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
@ -97,7 +99,7 @@ template <
|
||||
typename ReturnType,
|
||||
typename... Arguments>
|
||||
struct FunctionTraits<
|
||||
ReturnType (*)(bool,Arguments...)> : FunctionTraits<ReturnType (*)(Arguments...)>
|
||||
ReturnType (*)(bool, Arguments...)> : FunctionTraits<ReturnType (*)(Arguments...)>
|
||||
{
|
||||
static const bool isSqlCallback = true;
|
||||
static const bool isStepResultCallback = true;
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
|
@ -4,9 +4,11 @@
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -7,7 +7,21 @@
|
||||
* or contact the author.
|
||||
*/
|
||||
|
||||
//Taken from libpqxx and modified
|
||||
//Taken from libpqxx and modified
|
||||
|
||||
/**
|
||||
*
|
||||
* ArrayParser.cc
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
@ -17,7 +31,6 @@
|
||||
#include <drogon/orm/ArrayParser.h>
|
||||
#include <drogon/orm/Exception.h>
|
||||
|
||||
|
||||
using namespace drogon::orm;
|
||||
|
||||
namespace
|
||||
@ -29,7 +42,7 @@ namespace
|
||||
*
|
||||
* Returns the address of the first character after the closing quote.
|
||||
*/
|
||||
const char*scan_single_quoted_string(const char begin[])
|
||||
const char *scan_single_quoted_string(const char begin[])
|
||||
{
|
||||
const char *here = begin;
|
||||
assert(*here == '\'');
|
||||
@ -43,7 +56,8 @@ const char*scan_single_quoted_string(const char begin[])
|
||||
// If the next character is a quote, we've got a double single quote.
|
||||
// That's how SQL escapes embedded quotes in a string. Terrible idea,
|
||||
// but it's what we have.
|
||||
if (*here != '\'') return here;
|
||||
if (*here != '\'')
|
||||
return here;
|
||||
// Otherwise, we've found the end of the string. Return the address of
|
||||
// the very next byte.
|
||||
break;
|
||||
@ -52,7 +66,7 @@ const char*scan_single_quoted_string(const char begin[])
|
||||
here++;
|
||||
if (!*here)
|
||||
throw ArgumentError(
|
||||
"SQL string ends in escape: " + std::string(begin));
|
||||
"SQL string ends in escape: " + std::string(begin));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -60,7 +74,6 @@ const char*scan_single_quoted_string(const char begin[])
|
||||
"Null byte in SQL string: " + std::string(begin));
|
||||
}
|
||||
|
||||
|
||||
/// Parse a single-quoted SQL string: un-quote it and un-escape it.
|
||||
/** Assumes UTF-8 or an ASCII-superset single-byte encoding.
|
||||
*/
|
||||
@ -80,14 +93,14 @@ std::string parse_single_quoted_string(const char begin[], const char end[])
|
||||
{
|
||||
auto c = *here;
|
||||
// Skip escapes.
|
||||
if (c == '\'' || c == '\\') here++;
|
||||
if (c == '\'' || c == '\\')
|
||||
here++;
|
||||
output.push_back(c);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
/// Find the end of a double-quoted SQL string in an SQL array.
|
||||
/** Assumes UTF-8 or an ASCII-superset single-byte encoding.
|
||||
*/
|
||||
@ -114,7 +127,6 @@ const char *scan_double_quoted_string(const char begin[])
|
||||
"Null byte in SQL string: " + std::string(begin));
|
||||
}
|
||||
|
||||
|
||||
/// Parse a double-quoted SQL string: un-quote it and un-escape it.
|
||||
/** Assumes UTF-8 or an ASCII-superset single-byte encoding.
|
||||
*/
|
||||
@ -134,14 +146,14 @@ std::string parse_double_quoted_string(const char begin[], const char end[])
|
||||
{
|
||||
auto c = *here;
|
||||
// Skip escapes.
|
||||
if (c == '\\') here++;
|
||||
if (c == '\\')
|
||||
here++;
|
||||
output.push_back(c);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
/// Find the end of an unquoted string in an SQL array.
|
||||
/** Assumes UTF-8 or an ASCII-superset single-byte encoding.
|
||||
*/
|
||||
@ -152,13 +164,13 @@ const char *scan_unquoted_string(const char begin[])
|
||||
|
||||
const char *p;
|
||||
for (
|
||||
p = begin;
|
||||
*p != ',' && *p != ';' && *p != '}';
|
||||
p++);
|
||||
p = begin;
|
||||
*p != ',' && *p != ';' && *p != '}';
|
||||
p++)
|
||||
;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/// Parse an unquoted SQL string.
|
||||
/** Here, the special unquoted value NULL means a null value, not a string
|
||||
* that happens to spell "NULL".
|
||||
@ -170,12 +182,10 @@ std::string parse_unquoted_string(const char begin[], const char end[])
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
ArrayParser::ArrayParser(const char input[]) : m_pos(input)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::pair<ArrayParser::juncture, std::string>
|
||||
ArrayParser::getNext()
|
||||
{
|
||||
@ -188,48 +198,49 @@ ArrayParser::getNext()
|
||||
found = juncture::done;
|
||||
end = nullptr;
|
||||
}
|
||||
else switch (*m_pos)
|
||||
{
|
||||
case '\0':
|
||||
found = juncture::done;
|
||||
end = m_pos;
|
||||
break;
|
||||
case '{':
|
||||
found = juncture::row_start;
|
||||
end = m_pos + 1;
|
||||
break;
|
||||
case '}':
|
||||
found = juncture::row_end;
|
||||
end = m_pos + 1;
|
||||
break;
|
||||
case '\'':
|
||||
found = juncture::string_value;
|
||||
end = scan_single_quoted_string(m_pos);
|
||||
value = parse_single_quoted_string(m_pos, end);
|
||||
break;
|
||||
case '"':
|
||||
found = juncture::string_value;
|
||||
end = scan_double_quoted_string(m_pos);
|
||||
value = parse_double_quoted_string(m_pos, end);
|
||||
break;
|
||||
default:
|
||||
end = scan_unquoted_string(m_pos);
|
||||
value = parse_unquoted_string(m_pos, end);
|
||||
if (value == "NULL")
|
||||
else
|
||||
switch (*m_pos)
|
||||
{
|
||||
// In this one situation, as a special case, NULL means a null field,
|
||||
// not a string that happens to spell "NULL".
|
||||
value.clear();
|
||||
found = juncture::null_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The normal case: we just parsed an unquoted string. The value is
|
||||
// what we need.
|
||||
case '\0':
|
||||
found = juncture::done;
|
||||
end = m_pos;
|
||||
break;
|
||||
case '{':
|
||||
found = juncture::row_start;
|
||||
end = m_pos + 1;
|
||||
break;
|
||||
case '}':
|
||||
found = juncture::row_end;
|
||||
end = m_pos + 1;
|
||||
break;
|
||||
case '\'':
|
||||
found = juncture::string_value;
|
||||
end = scan_single_quoted_string(m_pos);
|
||||
value = parse_single_quoted_string(m_pos, end);
|
||||
break;
|
||||
case '"':
|
||||
found = juncture::string_value;
|
||||
end = scan_double_quoted_string(m_pos);
|
||||
value = parse_double_quoted_string(m_pos, end);
|
||||
break;
|
||||
default:
|
||||
end = scan_unquoted_string(m_pos);
|
||||
value = parse_unquoted_string(m_pos, end);
|
||||
if (value == "NULL")
|
||||
{
|
||||
// In this one situation, as a special case, NULL means a null field,
|
||||
// not a string that happens to spell "NULL".
|
||||
value.clear();
|
||||
found = juncture::null_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The normal case: we just parsed an unquoted string. The value is
|
||||
// what we need.
|
||||
found = juncture::string_value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Skip a field separator following a string (or null).
|
||||
if (end != nullptr && (*end == ',' || *end == ';'))
|
||||
@ -238,4 +249,3 @@ ArrayParser::getNext()
|
||||
m_pos = end;
|
||||
return std::make_pair(found, value);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user