-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from mloskot/issue-66
Implementation of query transformation callback feature
- Loading branch information
Showing
6 changed files
with
129 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// Copyright (C) 2013 Mateusz Loskot <mateusz@loskot.net> | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
|
||
#ifndef SOCI_QUERY_TRANSFORMATION_H_INCLUDED | ||
#define SOCI_QUERY_TRANSFORMATION_H_INCLUDED | ||
|
||
#include "soci-config.h" | ||
#include <functional> | ||
#include <string> | ||
|
||
namespace soci | ||
{ | ||
|
||
namespace details | ||
{ | ||
|
||
// TODO: use std::unary_function<const std::string&, std::string> | ||
class query_transformation_function : public std::unary_function<std::string const&, std::string> | ||
{ | ||
public: | ||
virtual result_type operator()(argument_type a) const = 0; | ||
}; | ||
|
||
template <typename T> | ||
class query_transformation : public query_transformation_function | ||
{ | ||
public: | ||
query_transformation(T callback) | ||
: callback_(callback) | ||
{} | ||
|
||
result_type operator()(argument_type query) const | ||
{ | ||
return callback_(query); | ||
} | ||
|
||
private: | ||
T callback_; | ||
}; | ||
|
||
} // namespace details | ||
|
||
} // namespace soci | ||
|
||
#endif // SOCI_QUERY_TRANSFORMATION_H_INCLUDED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters