Remove trailing whitespace (#3668)

This commit is contained in:
John Vandenberg 2022-07-07 17:18:20 +08:00 committed by GitHub
parent 0af9524e16
commit 0e6e16645c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1330 changed files with 23570 additions and 23571 deletions

View File

@ -12,5 +12,5 @@ vc.project.compiler.defines =
vc.project.compiler.defines.shared = vc.project.compiler.defines.shared =
vc.project.compiler.defines.debug_shared = ${vc.project.compiler.defines.shared} vc.project.compiler.defines.debug_shared = ${vc.project.compiler.defines.shared}
vc.project.compiler.defines.release_shared = ${vc.project.compiler.defines.shared} vc.project.compiler.defines.release_shared = ${vc.project.compiler.defines.shared}
vc.project.linker.dependencies = vc.project.linker.dependencies =
vc.solution.create = true vc.solution.create = true

View File

@ -16,7 +16,7 @@ file (usually <[httpd.conf]>):
LoadModule poco_module modules/mod_pocod.so LoadModule poco_module modules/mod_pocod.so
---- ----
!!!Configuring ApacheConnector !!!Configuring ApacheConnector
ApacheConnector must be able to find shared libraries containing request handler, as well ApacheConnector must be able to find shared libraries containing request handler, as well
as optional configuration files. ApacheConnector provides an Poco::Util::Application class as optional configuration files. ApacheConnector provides an Poco::Util::Application class
@ -30,7 +30,7 @@ is used in the Apache configuration file:
AddPocoRequestHandler <FactoryClass> <SharedLibrary> <Path>... AddPocoRequestHandler <FactoryClass> <SharedLibrary> <Path>...
---- ----
The first argument specifies the name of the request handler factory class. The second argument The first argument specifies the name of the request handler factory class. The second argument
contains the path of the shared library containing the request handler. contains the path of the shared library containing the request handler.
The third (and optionally following) argument(s) specify the URI paths handled by the The third (and optionally following) argument(s) specify the URI paths handled by the
@ -38,7 +38,7 @@ request handler. For example:
AddPocoRequestHandler TimeRequestHandlerFactory p:/Poco/ApacheConnector/samples/TimeServer/bin/TimeServerd.dll /time AddPocoRequestHandler TimeRequestHandlerFactory p:/Poco/ApacheConnector/samples/TimeServer/bin/TimeServerd.dll /time
---- ----
loads the TimeRequestHandlerFactory from TimeServerd.dll. Whenever a request for a URI starting with "/time" loads the TimeRequestHandlerFactory from TimeServerd.dll. Whenever a request for a URI starting with "/time"
is sent by a client, this request will be handled by the TimeRequestHandler. is sent by a client, this request will be handled by the TimeRequestHandler.
@ -76,8 +76,8 @@ Following is a sample for a request handler implementation. The complete sample
#include "Poco/DateTimeFormatter.h" #include "Poco/DateTimeFormatter.h"
#include "Poco/DateTimeFormat.h" #include "Poco/DateTimeFormat.h"
#include "Poco/ClassLibrary.h" #include "Poco/ClassLibrary.h"
using Poco::Net::HTTPRequestHandler; using Poco::Net::HTTPRequestHandler;
using Poco::Net::HTTPRequestHandlerFactory; using Poco::Net::HTTPRequestHandlerFactory;
using Poco::Net::HTTPServerRequest; using Poco::Net::HTTPServerRequest;
@ -85,24 +85,24 @@ Following is a sample for a request handler implementation. The complete sample
using Poco::Timestamp; using Poco::Timestamp;
using Poco::DateTimeFormatter; using Poco::DateTimeFormatter;
using Poco::DateTimeFormat; using Poco::DateTimeFormat;
class TimeRequestHandler: public HTTPRequestHandler class TimeRequestHandler: public HTTPRequestHandler
/// Return a HTML document with the current date and time. /// Return a HTML document with the current date and time.
{ {
public: public:
TimeRequestHandler() TimeRequestHandler()
{ {
} }
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{ {
Timestamp now; Timestamp now;
std::string dt(DateTimeFormatter::format(now, DateTimeFormat::SORTABLE_FORMAT)); std::string dt(DateTimeFormatter::format(now, DateTimeFormat::SORTABLE_FORMAT));
response.setChunkedTransferEncoding(true); response.setChunkedTransferEncoding(true);
response.setContentType("text/html"); response.setContentType("text/html");
std::ostream& ostr = response.send(); std::ostream& ostr = response.send();
ostr << "<html><head><title>TimeServer powered by POCO ApacheConnector</title>"; ostr << "<html><head><title>TimeServer powered by POCO ApacheConnector</title>";
ostr << "<meta http-equiv=\"refresh\" content=\"1\"></head>"; ostr << "<meta http-equiv=\"refresh\" content=\"1\"></head>";
@ -111,22 +111,22 @@ Following is a sample for a request handler implementation. The complete sample
ostr << "</p></body></html>"; ostr << "</p></body></html>";
} }
}; };
class TimeRequestHandlerFactory: public HTTPRequestHandlerFactory class TimeRequestHandlerFactory: public HTTPRequestHandlerFactory
{ {
public: public:
TimeRequestHandlerFactory() TimeRequestHandlerFactory()
{ {
} }
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request) HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
{ {
return new TimeRequestHandler; return new TimeRequestHandler;
} }
}; };
POCO_BEGIN_MANIFEST(HTTPRequestHandlerFactory) POCO_BEGIN_MANIFEST(HTTPRequestHandlerFactory)
POCO_EXPORT_CLASS(TimeRequestHandlerFactory) POCO_EXPORT_CLASS(TimeRequestHandlerFactory)
POCO_END_MANIFEST POCO_END_MANIFEST

View File

@ -25,7 +25,7 @@ class ApacheRequestRec
public: public:
ApacheRequestRec(request_rec* _pRec); ApacheRequestRec(request_rec* _pRec);
/// Creates the ApacheRequestRec; /// Creates the ApacheRequestRec;
bool haveRequestBody(); bool haveRequestBody();
/// Returns true if the request contains a body. /// Returns true if the request contains a body.

View File

@ -45,7 +45,7 @@ public:
private: private:
typedef std::map<std::string, Poco::Net::HTTPRequestHandlerFactory*> RequestHandlerFactories; typedef std::map<std::string, Poco::Net::HTTPRequestHandlerFactory*> RequestHandlerFactories;
RequestHandlerFactories _requestHandlers; RequestHandlerFactories _requestHandlers;
Poco::ClassLoader<Poco::Net::HTTPRequestHandlerFactory> _loader; Poco::ClassLoader<Poco::Net::HTTPRequestHandlerFactory> _loader;
Poco::FastMutex _mutex; Poco::FastMutex _mutex;

View File

@ -25,10 +25,10 @@ class ApacheServerRequest: public Poco::Net::HTTPServerRequest
{ {
public: public:
ApacheServerRequest( ApacheServerRequest(
ApacheRequestRec* pApacheRequest, ApacheRequestRec* pApacheRequest,
const char* serverName, const char* serverName,
int serverPort, int serverPort,
const char* clientName, const char* clientName,
int clientPort); int clientPort);
/// Creates a new ApacheServerRequest. /// Creates a new ApacheServerRequest.
@ -73,7 +73,7 @@ private:
ApacheInputStream* _pStream; ApacheInputStream* _pStream;
Poco::Net::SocketAddress _serverAddress; Poco::Net::SocketAddress _serverAddress;
Poco::Net::SocketAddress _clientAddress; Poco::Net::SocketAddress _clientAddress;
friend class ApacheServerResponse; friend class ApacheServerResponse;
}; };
@ -84,7 +84,7 @@ private:
inline std::istream& ApacheServerRequest::stream() inline std::istream& ApacheServerRequest::stream()
{ {
poco_check_ptr (_pStream); poco_check_ptr (_pStream);
return *_pStream; return *_pStream;
} }

View File

@ -42,7 +42,7 @@ public:
void sendContinue(); void sendContinue();
/// Sends a 100 Continue response to the /// Sends a 100 Continue response to the
/// client. /// client.
void sendErrorResponse(int status); void sendErrorResponse(int status);
/// Sends an error response with the given /// Sends an error response with the given
/// status back to the client. /// status back to the client.
@ -55,20 +55,20 @@ public:
/// The returned stream is valid until the response /// The returned stream is valid until the response
/// object is destroyed. /// object is destroyed.
/// ///
/// Must not be called after sendFile(), sendBuffer() /// Must not be called after sendFile(), sendBuffer()
/// or redirect() has been called. /// or redirect() has been called.
void sendFile(const std::string& path, const std::string& mediaType); void sendFile(const std::string& path, const std::string& mediaType);
/// Sends the response header to the client, followed /// Sends the response header to the client, followed
/// by the content of the given file. /// by the content of the given file.
/// ///
/// Must not be called after send(), sendBuffer() /// Must not be called after send(), sendBuffer()
/// or redirect() has been called. /// or redirect() has been called.
/// ///
/// Throws a FileNotFoundException if the file /// Throws a FileNotFoundException if the file
/// cannot be found, or an OpenFileException if /// cannot be found, or an OpenFileException if
/// the file cannot be opened. /// the file cannot be opened.
void sendBuffer(const void* pBuffer, std::size_t length); void sendBuffer(const void* pBuffer, std::size_t length);
/// Sends the response header to the client, followed /// Sends the response header to the client, followed
/// by the contents of the given buffer. /// by the contents of the given buffer.
@ -77,12 +77,12 @@ public:
/// to length and chunked transfer encoding is disabled. /// to length and chunked transfer encoding is disabled.
/// ///
/// If both the HTTP message header and body (from the /// If both the HTTP message header and body (from the
/// given buffer) fit into one single network packet, the /// given buffer) fit into one single network packet, the
/// complete response can be sent in one network packet. /// complete response can be sent in one network packet.
/// ///
/// Must not be called after send(), sendFile() /// Must not be called after send(), sendFile()
/// or redirect() has been called. /// or redirect() has been called.
void redirect(const std::string& uri, Poco::Net::HTTPResponse::HTTPStatus status); void redirect(const std::string& uri, Poco::Net::HTTPResponse::HTTPStatus status);
/// Sets the status code, which must be one of /// Sets the status code, which must be one of
/// HTTP_MOVED_PERMANENTLY (301), HTTP_FOUND (302), /// HTTP_MOVED_PERMANENTLY (301), HTTP_FOUND (302),
@ -92,12 +92,12 @@ public:
/// the HTTP specification, must be absolute. /// the HTTP specification, must be absolute.
/// ///
/// Must not be called after send() has been called. /// Must not be called after send() has been called.
void requireAuthentication(const std::string& realm); void requireAuthentication(const std::string& realm);
/// Sets the status code to 401 (Unauthorized) /// Sets the status code to 401 (Unauthorized)
/// and sets the "WWW-Authenticate" header field /// and sets the "WWW-Authenticate" header field
/// according to the given realm. /// according to the given realm.
bool sent() const; bool sent() const;
/// Returns true if the response (header) has been sent. /// Returns true if the response (header) has been sent.

View File

@ -33,7 +33,7 @@ protected:
int writeToDevice(const char* buffer, std::streamsize length); int writeToDevice(const char* buffer, std::streamsize length);
private: private:
enum enum
{ {
STREAM_BUFFER_SIZE = 1024 STREAM_BUFFER_SIZE = 1024
}; };
@ -53,15 +53,15 @@ class ApacheIOS: public virtual std::ios
public: public:
ApacheIOS(ApacheRequestRec* pApacheRequest, bool haveData = false); ApacheIOS(ApacheRequestRec* pApacheRequest, bool haveData = false);
/// Creates the ApacheIOS with the given socket. /// Creates the ApacheIOS with the given socket.
~ApacheIOS(); ~ApacheIOS();
/// Destroys the ApacheIOS. /// Destroys the ApacheIOS.
/// ///
/// Flushes the buffer, but does not close the socket. /// Flushes the buffer, but does not close the socket.
ApacheStreamBuf* rdbuf(); ApacheStreamBuf* rdbuf();
/// Returns a pointer to the internal ApacheStreamBuf. /// Returns a pointer to the internal ApacheStreamBuf.
void close(); void close();
/// Flushes the stream. /// Flushes the stream.

View File

@ -40,7 +40,7 @@ public:
_length(0) _length(0)
{ {
} }
void handlePart(const MessageHeader& header, std::istream& stream) void handlePart(const MessageHeader& header, std::istream& stream)
{ {
_type = header.get("Content-Type", "(unspecified)"); _type = header.get("Content-Type", "(unspecified)");
@ -52,18 +52,18 @@ public:
_name = params.get("name", "(unnamed)"); _name = params.get("name", "(unnamed)");
_fileName = params.get("filename", "(unnamed)"); _fileName = params.get("filename", "(unnamed)");
} }
CountingInputStream istr(stream); CountingInputStream istr(stream);
NullOutputStream ostr; NullOutputStream ostr;
StreamCopier::copyStream(istr, ostr); StreamCopier::copyStream(istr, ostr);
_length = istr.chars(); _length = istr.chars();
} }
int length() const int length() const
{ {
return _length; return _length;
} }
const std::string& name() const const std::string& name() const
{ {
return _name; return _name;
@ -73,12 +73,12 @@ public:
{ {
return _fileName; return _fileName;
} }
const std::string& contentType() const const std::string& contentType() const
{ {
return _type; return _type;
} }
private: private:
int _length; int _length;
std::string _type; std::string _type;
@ -91,10 +91,10 @@ class FormRequestHandler: public HTTPRequestHandler
/// Return a HTML document with the current date and time. /// Return a HTML document with the current date and time.
{ {
public: public:
FormRequestHandler() FormRequestHandler()
{ {
} }
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{ {
MyPartHandler partHandler; MyPartHandler partHandler;
@ -104,7 +104,7 @@ public:
response.setContentType("text/html"); response.setContentType("text/html");
std::ostream& ostr = response.send(); std::ostream& ostr = response.send();
ostr << ostr <<
"<html>\n" "<html>\n"
"<head>\n" "<head>\n"
@ -127,7 +127,7 @@ public:
"<input type=\"file\" name=\"file\" size=\"31\"> \n" "<input type=\"file\" name=\"file\" size=\"31\"> \n"
"<input type=\"submit\" value=\"Upload\">\n" "<input type=\"submit\" value=\"Upload\">\n"
"</form>\n"; "</form>\n";
ostr << "<h2>Request</h2><p>\n"; ostr << "<h2>Request</h2><p>\n";
ostr << "Method: " << request.getMethod() << "<br>\n"; ostr << "Method: " << request.getMethod() << "<br>\n";
ostr << "URI: " << request.getURI() << "<br>\n"; ostr << "URI: " << request.getURI() << "<br>\n";
@ -150,7 +150,7 @@ public:
} }
ostr << "</p>"; ostr << "</p>";
} }
if (!partHandler.name().empty()) if (!partHandler.name().empty())
{ {
ostr << "<h2>Upload</h2><p>\n"; ostr << "<h2>Upload</h2><p>\n";

View File

@ -32,10 +32,10 @@ class TimeRequestHandler: public HTTPRequestHandler
/// Return a HTML document with the current date and time. /// Return a HTML document with the current date and time.
{ {
public: public:
TimeRequestHandler() TimeRequestHandler()
{ {
} }
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{ {
Timestamp now; Timestamp now;

View File

@ -35,7 +35,7 @@ ApacheApplication::~ApacheApplication()
void ApacheApplication::setup() void ApacheApplication::setup()
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
if (!_ready) if (!_ready)
{ {
std::vector<std::string> cmdLine; std::vector<std::string> cmdLine;

View File

@ -34,7 +34,7 @@ ApacheRequestHandlerFactory::~ApacheRequestHandlerFactory()
Poco::Net::HTTPRequestHandler* ApacheRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest& request) Poco::Net::HTTPRequestHandler* ApacheRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest& request)
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
// only if the given uri is found in _uris we are // only if the given uri is found in _uris we are
// handling this request. // handling this request.
RequestHandlerFactories::iterator it = _requestHandlers.begin(); RequestHandlerFactories::iterator it = _requestHandlers.begin();
@ -75,7 +75,7 @@ void ApacheRequestHandlerFactory::handleURIs(const std::string& uris)
void ApacheRequestHandlerFactory::addRequestHandlerFactory(const std::string& dllPath, const std::string& factoryName, const std::string& uri) void ApacheRequestHandlerFactory::addRequestHandlerFactory(const std::string& dllPath, const std::string& factoryName, const std::string& uri)
{ {
try try
{ {
_loader.loadLibrary(dllPath); _loader.loadLibrary(dllPath);

View File

@ -16,10 +16,10 @@
ApacheServerRequest::ApacheServerRequest( ApacheServerRequest::ApacheServerRequest(
ApacheRequestRec* pApacheRequest, ApacheRequestRec* pApacheRequest,
const char* serverName, const char* serverName,
int serverPort, int serverPort,
const char* clientName, const char* clientName,
int clientPort): int clientPort):
_pApacheRequest(pApacheRequest), _pApacheRequest(pApacheRequest),
_pResponse(0), _pResponse(0),

View File

@ -52,7 +52,7 @@ void ApacheServerResponse::initApacheOutputStream()
std::vector<HTTPCookie> cookies; std::vector<HTTPCookie> cookies;
getCookies(cookies); getCookies(cookies);
std::size_t cnt = cookies.size(); std::size_t cnt = cookies.size();
for (int c = 0; c < cnt; c++) for (int c = 0; c < cnt; c++)
{ {
@ -77,7 +77,7 @@ void ApacheServerResponse::sendContinue()
std::ostream& ApacheServerResponse::send() std::ostream& ApacheServerResponse::send()
{ {
poco_assert (!_pStream); poco_assert (!_pStream);
initApacheOutputStream(); initApacheOutputStream();
return *_pStream; return *_pStream;
@ -124,7 +124,7 @@ void ApacheServerResponse::redirect(const std::string& uri, HTTPStatus status)
void ApacheServerResponse::sendErrorResponse(int status) void ApacheServerResponse::sendErrorResponse(int status)
{ {
initApacheOutputStream(); initApacheOutputStream();
_pApacheRequest->sendErrorResponse(status); _pApacheRequest->sendErrorResponse(status);

View File

@ -21,7 +21,7 @@ using Poco::BufferedStreamBuf;
// //
ApacheStreamBuf::ApacheStreamBuf(ApacheRequestRec* pApacheRequest, bool haveData): ApacheStreamBuf::ApacheStreamBuf(ApacheRequestRec* pApacheRequest, bool haveData):
BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in | std::ios::out), BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in | std::ios::out),
_pApacheRequest(pApacheRequest), _pApacheRequest(pApacheRequest),
_haveData(haveData) _haveData(haveData)

View File

@ -34,7 +34,7 @@ class CppParser_API Attributes
public: public:
typedef std::map<std::string, std::string> AttrMap; typedef std::map<std::string, std::string> AttrMap;
typedef AttrMap::const_iterator Iterator; typedef AttrMap::const_iterator Iterator;
Attributes(); Attributes();
/// Creates the Attributes object. /// Creates the Attributes object.
@ -46,15 +46,15 @@ public:
Attributes& operator = (const Attributes& attrs); Attributes& operator = (const Attributes& attrs);
/// Assignment operator. /// Assignment operator.
bool has(const std::string& name) const; bool has(const std::string& name) const;
/// Returns true if an attribute with the given name exists. /// Returns true if an attribute with the given name exists.
std::string getString(const std::string& name) const; std::string getString(const std::string& name) const;
/// Returns the attribute's value as a string. /// Returns the attribute's value as a string.
/// ///
/// Throws a Poco::NotFoundException if the attribute does not exist. /// Throws a Poco::NotFoundException if the attribute does not exist.
std::string getString(const std::string& name, const std::string& defaultValue) const; std::string getString(const std::string& name, const std::string& defaultValue) const;
/// Returns the attribute's value as a string, if it exists. /// Returns the attribute's value as a string, if it exists.
/// Returns the defaultValue if the attribute does not exist. /// Returns the defaultValue if the attribute does not exist.
@ -64,7 +64,7 @@ public:
/// ///
/// Throws a Poco::NotFoundException if the attribute does not exist. /// Throws a Poco::NotFoundException if the attribute does not exist.
/// Throws a Poco::SyntaxException if the stored value is not an integer. /// Throws a Poco::SyntaxException if the stored value is not an integer.
int getInt(const std::string& name, int defaultValue) const; int getInt(const std::string& name, int defaultValue) const;
/// Returns the attribute's value as an integer, if it exists. /// Returns the attribute's value as an integer, if it exists.
/// Returns the defaultValue if the attribute does not exist. /// Returns the defaultValue if the attribute does not exist.
@ -74,7 +74,7 @@ public:
bool getBool(const std::string& name) const; bool getBool(const std::string& name) const;
/// Returns the attribute's value as a boolean. /// Returns the attribute's value as a boolean.
/// The returned value is 'true', iff the stored value is not "false". /// The returned value is 'true', iff the stored value is not "false".
/// ///
/// Throws a Poco::NotFoundException if the attribute does not exist. /// Throws a Poco::NotFoundException if the attribute does not exist.
bool getBool(const std::string& name, bool defaultValue) const; bool getBool(const std::string& name, bool defaultValue) const;
@ -83,17 +83,17 @@ public:
void set(const std::string& name, const std::string& value); void set(const std::string& name, const std::string& value);
/// Sets the value of an attribute. /// Sets the value of an attribute.
void remove(const std::string& name); void remove(const std::string& name);
/// Removes the attribute with the given name. /// Removes the attribute with the given name.
/// Does nothing if the attribute does not exist. /// Does nothing if the attribute does not exist.
const std::string& operator [] (const std::string& name) const; const std::string& operator [] (const std::string& name) const;
std::string& operator [] (const std::string& name); std::string& operator [] (const std::string& name);
Iterator begin() const; Iterator begin() const;
Iterator end() const; Iterator end() const;
void clear(); void clear();
/// Clears all attributes. /// Clears all attributes.

View File

@ -34,13 +34,13 @@ class CppParser_API AttributesParser
/// structs/classes, functions, types, etc. can be annotated /// structs/classes, functions, types, etc. can be annotated
/// with attributes. /// with attributes.
/// ///
/// Attributes always come immediately before the symbol that /// Attributes always come immediately before the symbol that
/// is being annotated, and are written inside special comments /// is being annotated, and are written inside special comments
/// with the syntax: /// with the syntax:
/// //@ <attrDecl>[,<attrDec>...] /// //@ <attrDecl>[,<attrDec>...]
/// where <attrDecl> is /// where <attrDecl> is
/// <name>[=<value>] /// <name>[=<value>]
/// <name> is a valid C++ identifier, or two identifiers separated by /// <name> is a valid C++ identifier, or two identifiers separated by
/// a period (struct accessor notation). /// a period (struct accessor notation).
/// <value> is a string, integer, identifier, bool literal, or a complex value /// <value> is a string, integer, identifier, bool literal, or a complex value
/// in the form /// in the form
@ -67,7 +67,7 @@ protected:
static bool isOperator(const Poco::Token* pToken, int kind); static bool isOperator(const Poco::Token* pToken, int kind);
static bool isLiteral(const Poco::Token* pToken); static bool isLiteral(const Poco::Token* pToken);
static bool isEOF(const Poco::Token* pToken); static bool isEOF(const Poco::Token* pToken);
private: private:
Attributes& _attrs; Attributes& _attrs;
Tokenizer _tokenizer; Tokenizer _tokenizer;

View File

@ -48,7 +48,7 @@ public:
FN_DEFAULT = 512, /// The function is default. FN_DEFAULT = 512, /// The function is default.
FN_DELETE = 1024 /// The function has been deleted. FN_DELETE = 1024 /// The function has been deleted.
}; };
typedef std::vector<Parameter*> Parameters; typedef std::vector<Parameter*> Parameters;
typedef Parameters::const_iterator Iterator; typedef Parameters::const_iterator Iterator;
@ -68,51 +68,51 @@ public:
Iterator end() const; Iterator end() const;
/// Returns an iterator for iterating over the Function's Parameter's. /// Returns an iterator for iterating over the Function's Parameter's.
void makeInline(); void makeInline();
/// Sets the FN_INLINE flag. /// Sets the FN_INLINE flag.
void makeConst(); void makeConst();
/// Sets the FN_CONST flag. /// Sets the FN_CONST flag.
void makePureVirtual(); void makePureVirtual();
/// Sets the FN_PURE_VIRTUAL flag. /// Sets the FN_PURE_VIRTUAL flag.
void makeFinal(); void makeFinal();
/// Sets the FN_FINAL flag. /// Sets the FN_FINAL flag.
void makeOverride(); void makeOverride();
/// Sets the FN_OVERRIDE flag. /// Sets the FN_OVERRIDE flag.
void makeNoexcept(); void makeNoexcept();
/// Sets the FN_NOEXCEPT flag. /// Sets the FN_NOEXCEPT flag.
void makeDefault(); void makeDefault();
/// Sets the FN_DEFAULT flag. /// Sets the FN_DEFAULT flag.
void makeDelete(); void makeDelete();
/// Sets the FN_DELETE flag. /// Sets the FN_DELETE flag.
int flags() const; int flags() const;
/// Returns the function's flags. /// Returns the function's flags.
bool isConstructor() const; bool isConstructor() const;
/// Returns true iff the function is a constructor. /// Returns true iff the function is a constructor.
bool isDestructor() const; bool isDestructor() const;
/// Returns true iff the function is a destructor. /// Returns true iff the function is a destructor.
bool isMethod() const; bool isMethod() const;
/// Returns true iff the function is a method (it's part of /// Returns true iff the function is a method (it's part of
/// a Struct and it's neither a constructor nor a destructor). /// a Struct and it's neither a constructor nor a destructor).
bool isFunction() const; bool isFunction() const;
/// Returns true iff the function is not a member of a class /// Returns true iff the function is not a member of a class
/// (a freestanding function). /// (a freestanding function).
bool isConst() const; bool isConst() const;
/// Returns true iff the method is const. /// Returns true iff the method is const.
bool isDefault() const; bool isDefault() const;
/// Returns true iff the method has a default implementation. /// Returns true iff the method has a default implementation.
@ -121,20 +121,20 @@ public:
int countParameters() const; int countParameters() const;
/// Returns the number of parameters. /// Returns the number of parameters.
std::string signature() const; std::string signature() const;
/// Returns the signature of the function. /// Returns the signature of the function.
bool isVirtual() const; bool isVirtual() const;
/// Returns true if the method is virtual. Also examines base /// Returns true if the method is virtual. Also examines base
/// classes to check for a virtual function with the same /// classes to check for a virtual function with the same
/// signature. /// signature.
Function* getOverridden() const; Function* getOverridden() const;
/// If the function is virtual and overrides a function in a /// If the function is virtual and overrides a function in a
/// base class, the base class function is returned. /// base class, the base class function is returned.
/// Otherwise, null is returned. /// Otherwise, null is returned.
Symbol::Kind kind() const; Symbol::Kind kind() const;
std::string toString() const; std::string toString() const;

View File

@ -37,7 +37,7 @@ public:
typedef SymbolTable::const_iterator Iterator; typedef SymbolTable::const_iterator Iterator;
typedef std::map<std::string, std::string> AliasMap; typedef std::map<std::string, std::string> AliasMap;
typedef std::vector<std::string> NameSpaceVec; typedef std::vector<std::string> NameSpaceVec;
NameSpace(); NameSpace();
/// Creates the NameSpace. /// Creates the NameSpace.
@ -46,56 +46,56 @@ public:
~NameSpace(); ~NameSpace();
/// Destroys the NameSpace. /// Destroys the NameSpace.
void addSymbol(Symbol* pSymbol); void addSymbol(Symbol* pSymbol);
/// Adds a symbol to the namespace. /// Adds a symbol to the namespace.
void importSymbol(const std::string& fullName); void importSymbol(const std::string& fullName);
/// Imports a symbol from another namespace (using <symbol>). /// Imports a symbol from another namespace (using <symbol>).
void importNameSpace(const std::string& nameSpace); void importNameSpace(const std::string& nameSpace);
/// Imports a namespace (using namespace <namespace>). /// Imports a namespace (using namespace <namespace>).
Iterator begin() const; Iterator begin() const;
/// Returns an iterator for iterating over the NameSpace's Symbol's. /// Returns an iterator for iterating over the NameSpace's Symbol's.
Iterator end() const; Iterator end() const;
/// Returns an iterator for iterating over the NameSpace's Symbol's. /// Returns an iterator for iterating over the NameSpace's Symbol's.
Symbol* lookup(const std::string& name) const; Symbol* lookup(const std::string& name) const;
/// Looks up the given name in the symbol table /// Looks up the given name in the symbol table
/// and returns the corresponding symbol, or null /// and returns the corresponding symbol, or null
/// if no symbol can be found. The name can include /// if no symbol can be found. The name can include
/// a namespace. /// a namespace.
static NameSpace* root(); static NameSpace* root();
/// Returns the root namespace. Never delete this one! /// Returns the root namespace. Never delete this one!
void nameSpaces(SymbolTable& table) const; void nameSpaces(SymbolTable& table) const;
/// Fills the symbol table with all namespaces. /// Fills the symbol table with all namespaces.
void typeDefs(SymbolTable& table) const; void typeDefs(SymbolTable& table) const;
/// Fills the symbol table with all type definitions. /// Fills the symbol table with all type definitions.
void typeAliases(SymbolTable& table) const; void typeAliases(SymbolTable& table) const;
/// Fills the symbol table with all type alias (using) definitions. /// Fills the symbol table with all type alias (using) definitions.
void enums(SymbolTable& table) const; void enums(SymbolTable& table) const;
/// Fills the symbol table with all enums. /// Fills the symbol table with all enums.
void classes(SymbolTable& table) const; void classes(SymbolTable& table) const;
/// Fills the symbol table with all classes and structs. /// Fills the symbol table with all classes and structs.
void functions(SymbolTable& table) const; void functions(SymbolTable& table) const;
/// Fills the symbol table with all functions. /// Fills the symbol table with all functions.
void variables(SymbolTable& table) const; void variables(SymbolTable& table) const;
/// Fills the symbol table with all variables. /// Fills the symbol table with all variables.
const AliasMap& importedSymbols() const; const AliasMap& importedSymbols() const;
/// Returns a const reference to a SymbolTable containing all /// Returns a const reference to a SymbolTable containing all
/// imported symbols. /// imported symbols.
const NameSpaceVec& importedNameSpaces() const; const NameSpaceVec& importedNameSpaces() const;
/// Returns a vector containing all imported namespaces. /// Returns a vector containing all imported namespaces.
@ -128,7 +128,7 @@ inline const NameSpace::AliasMap& NameSpace::importedSymbols() const
return _importedSymbols; return _importedSymbols;
} }
inline const NameSpace::NameSpaceVec& NameSpace::importedNameSpaces() const inline const NameSpace::NameSpaceVec& NameSpace::importedNameSpaces() const
{ {
return _importedNameSpaces; return _importedNameSpaces;

View File

@ -82,7 +82,7 @@ protected:
const Poco::Token* parseClassMembers(const Poco::Token* pNext, Struct* pClass); const Poco::Token* parseClassMembers(const Poco::Token* pNext, Struct* pClass);
const Poco::Token* parseAccess(const Poco::Token* pNext); const Poco::Token* parseAccess(const Poco::Token* pNext);
const Poco::Token* parseIdentifier(const Poco::Token* pNext, std::string& id); const Poco::Token* parseIdentifier(const Poco::Token* pNext, std::string& id);
void addSymbol(Symbol* pSymbol, int lineNumber, bool addGST = true); void addSymbol(Symbol* pSymbol, int lineNumber, bool addGST = true);
void pushNameSpace(NameSpace* pNameSpace, int lineNumber, bool addGST = true); void pushNameSpace(NameSpace* pNameSpace, int lineNumber, bool addGST = true);
void popNameSpace(); void popNameSpace();

View File

@ -42,7 +42,7 @@ public:
FN_TEMPLATE_SPECIALIZATION = 4, FN_TEMPLATE_SPECIALIZATION = 4,
FN_FINAL = 8 FN_FINAL = 8
}; };
struct Base struct Base
{ {
Symbol::Access access; Symbol::Access access;
@ -50,7 +50,7 @@ public:
std::string name; std::string name;
Struct* pClass; Struct* pClass;
}; };
typedef std::vector<Base> BaseClasses; typedef std::vector<Base> BaseClasses;
typedef BaseClasses::const_iterator BaseIterator; typedef BaseClasses::const_iterator BaseIterator;
typedef std::vector<Struct*> StructVec; typedef std::vector<Struct*> StructVec;
@ -67,13 +67,13 @@ public:
void addBase(const std::string&, Symbol::Access access, bool isVirtual); void addBase(const std::string&, Symbol::Access access, bool isVirtual);
/// Adds a base class. /// Adds a base class.
BaseIterator baseBegin() const; BaseIterator baseBegin() const;
/// Returns an iterator for iterating over all base classes. /// Returns an iterator for iterating over all base classes.
BaseIterator baseEnd() const; BaseIterator baseEnd() const;
/// Returns an iterator for iterating over all base classes. /// Returns an iterator for iterating over all base classes.
void fixupBases(); void fixupBases();
/// Adds pointers for all base classes. /// Adds pointers for all base classes.
@ -88,13 +88,13 @@ public:
const std::string& declaration() const; const std::string& declaration() const;
/// Returns the declaration. /// Returns the declaration.
int flags() const; int flags() const;
/// Returns the struct's flags. /// Returns the struct's flags.
void makeInline(); void makeInline();
/// Changes the class to a inline class, i.e. definition and implementation are hidden in a cpp file. /// Changes the class to a inline class, i.e. definition and implementation are hidden in a cpp file.
void makeFinal(); void makeFinal();
/// Makes the class final. /// Makes the class final.
@ -106,39 +106,39 @@ public:
void constructors(Functions& functions) const; void constructors(Functions& functions) const;
/// Returns all constructors, sorted by their parameter count. /// Returns all constructors, sorted by their parameter count.
Function* destructor() const; Function* destructor() const;
/// Returns the destructor, or NULL if no /// Returns the destructor, or NULL if no
/// destructor is defined. /// destructor is defined.
void methods(Symbol::Access access, Functions& functions) const; void methods(Symbol::Access access, Functions& functions) const;
/// Returns all functions with the given access. /// Returns all functions with the given access.
void inheritedMethods(FunctionSet& functions) const; void inheritedMethods(FunctionSet& functions) const;
/// Returns all inherited methods. /// Returns all inherited methods.
void bases(std::set<std::string>& bases) const; void bases(std::set<std::string>& bases) const;
/// Returns all base classes. /// Returns all base classes.
void derived(StructSet& derived) const; void derived(StructSet& derived) const;
/// Returns all derived classes. /// Returns all derived classes.
Function* findFunction(const std::string& signature) const; Function* findFunction(const std::string& signature) const;
/// Finds a function with the given signature. /// Finds a function with the given signature.
bool hasVirtualDestructor() const; bool hasVirtualDestructor() const;
/// Returns true if the class CppParser_API or one if its base classes /// Returns true if the class CppParser_API or one if its base classes
/// has a virtual destructor. /// has a virtual destructor.
bool isClass() const; bool isClass() const;
/// Returns true iff the struct was declared as class. /// Returns true iff the struct was declared as class.
bool isDerived() const; bool isDerived() const;
/// Returns true iff the struct or class is derived from another struct or class. /// Returns true iff the struct or class is derived from another struct or class.
Symbol::Kind kind() const; Symbol::Kind kind() const;
std::string toString() const; std::string toString() const;
private: private:
std::string _decl; std::string _decl;
BaseClasses _bases; BaseClasses _bases;

View File

@ -37,9 +37,9 @@ public:
public: public:
std::string beginNameSpaceDecl; // contains either $(NS)_BEGIN or the namespace x { decl std::string beginNameSpaceDecl; // contains either $(NS)_BEGIN or the namespace x { decl
std::string endNameSpaceDecl; // contains either $(NS)_END or the closing brackets } std::string endNameSpaceDecl; // contains either $(NS)_END or the closing brackets }
std::vector<std::string> classDecls; // contains strings of the form "class X;" std::vector<std::string> classDecls; // contains strings of the form "class X;"
}; };
static void parse(const std::string& file, NameSpace::SymbolTable& st, const std::string& exec, const std::string& options, const std::string& path); static void parse(const std::string& file, NameSpace::SymbolTable& st, const std::string& exec, const std::string& options, const std::string& path);
/// Preprocesses and parses the file. The resulting symboltable has base class references already fixed, /// Preprocesses and parses the file. The resulting symboltable has base class references already fixed,

View File

@ -37,13 +37,13 @@ public:
VAR_VOLATILE = 4, /// The variable is volatile. VAR_VOLATILE = 4, /// The variable is volatile.
VAR_CONST = 8 /// The variable is const. VAR_CONST = 8 /// The variable is const.
}; };
Variable(const std::string& decl, NameSpace* pNameSpace); Variable(const std::string& decl, NameSpace* pNameSpace);
/// Creates the Variable. /// Creates the Variable.
~Variable(); ~Variable();
/// Destroys the Variable. /// Destroys the Variable.
int flags() const; int flags() const;
/// Returns the variable's flags. /// Returns the variable's flags.
@ -57,7 +57,7 @@ public:
/// ///
/// Example: a type const std::string& -> std::string, a type const std::string* returns std::string /// Example: a type const std::string& -> std::string, a type const std::string* returns std::string
private: private:
int _flags; int _flags;
bool _isPointer; bool _isPointer;

View File

@ -48,13 +48,13 @@ Attributes& Attributes::operator = (const Attributes& attrs)
return *this; return *this;
} }
bool Attributes::has(const std::string& name) const bool Attributes::has(const std::string& name) const
{ {
return _map.find(name) != _map.end(); return _map.find(name) != _map.end();
} }
std::string Attributes::getString(const std::string& name) const std::string Attributes::getString(const std::string& name) const
{ {
AttrMap::const_iterator it = _map.find(name); AttrMap::const_iterator it = _map.find(name);
@ -64,7 +64,7 @@ std::string Attributes::getString(const std::string& name) const
throw Poco::NotFoundException(name); throw Poco::NotFoundException(name);
} }
std::string Attributes::getString(const std::string& name, const std::string& defaultValue) const std::string Attributes::getString(const std::string& name, const std::string& defaultValue) const
{ {
AttrMap::const_iterator it = _map.find(name); AttrMap::const_iterator it = _map.find(name);
@ -84,7 +84,7 @@ int Attributes::getInt(const std::string& name) const
throw Poco::NotFoundException(name); throw Poco::NotFoundException(name);
} }
int Attributes::getInt(const std::string& name, int defaultValue) const int Attributes::getInt(const std::string& name, int defaultValue) const
{ {
AttrMap::const_iterator it = _map.find(name); AttrMap::const_iterator it = _map.find(name);

View File

@ -88,7 +88,7 @@ const Token* AttributesParser::parseAttribute(const Token* pNext)
const Token* AttributesParser::parseComplexAttribute(const Token* pNext, const std::string& id) const Token* AttributesParser::parseComplexAttribute(const Token* pNext, const std::string& id)
{ {
poco_assert_dbg (isOperator(pNext, OperatorToken::OP_OPENBRACE)); poco_assert_dbg (isOperator(pNext, OperatorToken::OP_OPENBRACE));
pNext = next(); pNext = next();
std::string oldId(_id); std::string oldId(_id);
if (!_id.empty()) if (!_id.empty())
@ -103,7 +103,7 @@ const Token* AttributesParser::parseComplexAttribute(const Token* pNext, const s
pNext = next(); pNext = next();
else else
throw SyntaxException("bad attribute declaration"); throw SyntaxException("bad attribute declaration");
return pNext; return pNext;
} }

View File

@ -111,13 +111,13 @@ void Function::makeFinal()
_flags |= FN_FINAL; _flags |= FN_FINAL;
} }
void Function::makeOverride() void Function::makeOverride()
{ {
_flags |= FN_OVERRIDE; _flags |= FN_OVERRIDE;
} }
void Function::makeNoexcept() void Function::makeNoexcept()
{ {
_flags |= FN_NOEXCEPT; _flags |= FN_NOEXCEPT;
@ -141,7 +141,7 @@ bool Function::isConstructor() const
return name() == nameSpace()->name(); return name() == nameSpace()->name();
} }
bool Function::isDestructor() const bool Function::isDestructor() const
{ {
return name()[0] == '~'; return name()[0] == '~';
@ -201,7 +201,7 @@ std::string Function::signature() const
return signature; return signature;
} }
bool Function::isVirtual() const bool Function::isVirtual() const
{ {
if (_flags & FN_VIRTUAL) if (_flags & FN_VIRTUAL)

View File

@ -49,7 +49,7 @@ NameSpace::~NameSpace()
void NameSpace::addSymbol(Symbol* pSymbol) void NameSpace::addSymbol(Symbol* pSymbol)
{ {
poco_check_ptr (pSymbol); poco_check_ptr (pSymbol);
_symbols.insert(SymbolTable::value_type(pSymbol->name(), pSymbol)); _symbols.insert(SymbolTable::value_type(pSymbol->name(), pSymbol));
} }
@ -65,7 +65,7 @@ void NameSpace::importSymbol(const std::string& fullName)
} }
} }
void NameSpace::importNameSpace(const std::string& nameSpace) void NameSpace::importNameSpace(const std::string& nameSpace)
{ {
_importedNameSpaces.push_back(nameSpace); _importedNameSpaces.push_back(nameSpace);
@ -94,7 +94,7 @@ Symbol* NameSpace::lookup(const std::string& name) const
Symbol* NameSpace::lookup(const std::string& name, std::set<const NameSpace*>& alreadyVisited) const Symbol* NameSpace::lookup(const std::string& name, std::set<const NameSpace*>& alreadyVisited) const
{ {
Symbol* pSymbol = 0; Symbol* pSymbol = 0;
if (name.empty()) if (name.empty())
return pSymbol; return pSymbol;
@ -103,12 +103,12 @@ Symbol* NameSpace::lookup(const std::string& name, std::set<const NameSpace*>& a
std::string head; std::string head;
std::string tail; std::string tail;
splitName(name, head, tail); splitName(name, head, tail);
alreadyVisited.insert(this); alreadyVisited.insert(this);
bool currentNSInserted = true; bool currentNSInserted = true;
if (head.empty()) if (head.empty())
{ {
alreadyVisited.insert(this); alreadyVisited.insert(this);
return root()->lookup(tail, alreadyVisited); return root()->lookup(tail, alreadyVisited);
@ -161,13 +161,13 @@ void NameSpace::nameSpaces(SymbolTable& table) const
extract(Symbol::SYM_NAMESPACE, table); extract(Symbol::SYM_NAMESPACE, table);
} }
void NameSpace::typeDefs(SymbolTable& table) const void NameSpace::typeDefs(SymbolTable& table) const
{ {
extract(Symbol::SYM_TYPEDEF, table); extract(Symbol::SYM_TYPEDEF, table);
} }
void NameSpace::typeAliases(SymbolTable& table) const void NameSpace::typeAliases(SymbolTable& table) const
{ {
extract(Symbol::SYM_TYPEALIAS, table); extract(Symbol::SYM_TYPEALIAS, table);
@ -179,19 +179,19 @@ void NameSpace::enums(SymbolTable& table) const
extract(Symbol::SYM_ENUM, table); extract(Symbol::SYM_ENUM, table);
} }
void NameSpace::classes(SymbolTable& table) const void NameSpace::classes(SymbolTable& table) const
{ {
extract(Symbol::SYM_STRUCT, table); extract(Symbol::SYM_STRUCT, table);
} }
void NameSpace::functions(SymbolTable& table) const void NameSpace::functions(SymbolTable& table) const
{ {
extract(Symbol::SYM_FUNCTION, table); extract(Symbol::SYM_FUNCTION, table);
} }
void NameSpace::variables(SymbolTable& table) const void NameSpace::variables(SymbolTable& table) const
{ {
extract(Symbol::SYM_VARIABLE, table); extract(Symbol::SYM_VARIABLE, table);
@ -226,7 +226,7 @@ void NameSpace::splitName(const std::string& name, std::string& head, std::strin
head.assign(name, 0, pos); head.assign(name, 0, pos);
pos += 2; pos += 2;
poco_assert (pos < name.length()); poco_assert (pos < name.length());
tail.assign(name, pos, name.length() - pos); tail.assign(name, pos, name.length() - pos);
} }
else head = name; else head = name;
} }

View File

@ -62,7 +62,7 @@ void Struct::addBase(const std::string& name, Symbol::Access access, bool isVirt
_bases.push_back(base); _bases.push_back(base);
} }
Struct::BaseIterator Struct::baseBegin() const Struct::BaseIterator Struct::baseBegin() const
{ {
return _bases.begin(); return _bases.begin();
@ -78,7 +78,7 @@ Struct::BaseIterator Struct::baseEnd() const
void Struct::addDerived(Struct* pClass) void Struct::addDerived(Struct* pClass)
{ {
poco_check_ptr (pClass); poco_check_ptr (pClass);
_derived.push_back(pClass); _derived.push_back(pClass);
} }

View File

@ -25,7 +25,7 @@ namespace CppParser {
Tokenizer::Tokenizer(std::istream& istr): Tokenizer::Tokenizer(std::istream& istr):
StreamTokenizer(istr) StreamTokenizer(istr)
{ {
addToken(new OperatorToken); addToken(new OperatorToken);
addToken(new IdentifierToken); addToken(new IdentifierToken);

View File

@ -195,14 +195,14 @@ std::string Utility::preprocessFile(const std::string& file, const std::string&
newPath += path; newPath += path;
Environment::set("PATH", path); Environment::set("PATH", path);
} }
ProcessHandle proc = Process::launch(exec, args); ProcessHandle proc = Process::launch(exec, args);
int rc = Process::wait(proc); int rc = Process::wait(proc);
if (rc != 0) if (rc != 0)
{ {
throw Poco::RuntimeException("Failed to process file"); throw Poco::RuntimeException("Failed to process file");
} }
return pp.getFileName(); return pp.getFileName();
} }
@ -293,7 +293,7 @@ std::string replace(const std::string& input, const std::string& oldToken, const
start = pos + oldToken.length(); start = pos + oldToken.length();
} }
while (pos != std::string::npos); while (pos != std::string::npos);
return result; return result;
} }

View File

@ -39,10 +39,10 @@ Variable::Variable(const std::string& decl, NameSpace* pNameSpace):
std::size_t pos = decl.rfind(name()); std::size_t pos = decl.rfind(name());
std::string tmp = decl.substr(0, pos); std::string tmp = decl.substr(0, pos);
tmp = Poco::trim(tmp); tmp = Poco::trim(tmp);
pos = tmp.rfind("*"); pos = tmp.rfind("*");
_isPointer = (pos == (tmp.size()-1)); _isPointer = (pos == (tmp.size()-1));
Poco::replaceInPlace(tmp, "static ", ""); Poco::replaceInPlace(tmp, "static ", "");
Poco::replaceInPlace(tmp, "mutable ", ""); Poco::replaceInPlace(tmp, "mutable ", "");
Poco::replaceInPlace(tmp, "volatile ", ""); Poco::replaceInPlace(tmp, "volatile ", "");
@ -53,7 +53,7 @@ Variable::Variable(const std::string& decl, NameSpace* pNameSpace):
tmp = tmp.substr(6); tmp = tmp.substr(6);
if (tmp.find("const\t") == 0) if (tmp.find("const\t") == 0)
tmp = tmp.substr(6); tmp = tmp.substr(6);
std::size_t rightCut = tmp.size(); std::size_t rightCut = tmp.size();
while (rightCut > 0 && (tmp[rightCut-1] == '&' || tmp[rightCut-1] == '*' || tmp[rightCut-1] == '\t' || tmp[rightCut-1] == ' ')) while (rightCut > 0 && (tmp[rightCut-1] == '&' || tmp[rightCut-1] == '*' || tmp[rightCut-1] == '\t' || tmp[rightCut-1] == ' '))
--rightCut; --rightCut;

View File

@ -15,14 +15,14 @@
<P>CppUnit is a simple unit test framework for C++. It is a port from JUnit, a testing framework for Java, developed by Kent Beck and Erich Gamma. </P> <P>CppUnit is a simple unit test framework for C++. It is a port from JUnit, a testing framework for Java, developed by Kent Beck and Erich Gamma. </P>
<H3>Contents</H3> <H3>Contents</H3>
<PRE>README.html&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this file <PRE>README.html&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this file
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the source code &nbsp;&nbsp;&nbsp; test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the source code
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; framework&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the testing framework &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; framework&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the testing framework
&#9;&#9;extensions&#9;some framework extension classes &#9;&#9;extensions&#9;some framework extension classes
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; textui&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a command line interface to run tests &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; textui&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a command line interface to run tests
&nbsp;&nbsp;&nbsp;&nbsp;ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; code for a Microsoft specific TestRunner &nbsp;&nbsp;&nbsp;&nbsp;ms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; code for a Microsoft specific TestRunner
&nbsp;&nbsp;&nbsp;&nbsp;samples&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; some example test cases and extensions to the framework &nbsp;&nbsp;&nbsp;&nbsp;samples&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; some example test cases and extensions to the framework
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; multicaster&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a sample illustrating a publish/subscribe &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; multicaster&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a sample illustrating a publish/subscribe
&#9;&#9;&#9;&#9;multicaster under test &#9;&#9;&#9;&#9;multicaster under test
&nbsp;&nbsp;&nbsp; doc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; documentation</PRE> &nbsp;&nbsp;&nbsp; doc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; documentation</PRE>
<H3>Installation</H3> <H3>Installation</H3>

View File

@ -17,7 +17,7 @@
<P>Subclass the TestCase class. Override the method "runTest ()". When you want to check a value, call "assert (bool)" and pass in an expression that is true if the test succeeds. </P> <P>Subclass the TestCase class. Override the method "runTest ()". When you want to check a value, call "assert (bool)" and pass in an expression that is true if the test succeeds. </P>
<P>For example, to test the equality comparison for a Complex number class, write:</P> <P>For example, to test the equality comparison for a Complex number class, write:</P>
<TT><PRE>&#9;class ComplexNumberTest : public TestCase {&nbsp; <TT><PRE>&#9;class ComplexNumberTest : public TestCase {&nbsp;
&#9;public: &#9;public:
ComplexNumberTest (string name) : TestCase (name) {} ComplexNumberTest (string name) : TestCase (name) {}
void runTest () { void runTest () {
assert (Complex (10, 1) == Complex (10, 1)); assert (Complex (10, 1) == Complex (10, 1));
@ -59,7 +59,7 @@
&#9;void&#9;&#9;setUp () { &#9;void&#9;&#9;setUp () {
&#9;&#9;&#9; m_10_1 = new Complex (10, 1); &#9;&#9;&#9; m_10_1 = new Complex (10, 1);
&#9;&#9;&#9; m_1_1 = new Complex (1, 1); &#9;&#9;&#9; m_1_1 = new Complex (1, 1);
&#9;&#9;&#9; m_11_2 = new Complex (11, 2); &#9;&#9;&#9; m_11_2 = new Complex (11, 2);
} }
&#9;void&#9;&#9;tearDown () { &#9;void&#9;&#9;tearDown () {
&#9;&#9;&#9; delete m_10_1, delete m_1_1, delete m_11_2; &#9;&#9;&#9; delete m_10_1, delete m_1_1, delete m_11_2;
@ -83,7 +83,7 @@
&#9;void&#9;&#9;setUp () { &#9;void&#9;&#9;setUp () {
&#9;&#9;&#9; m_10_1 = new Complex (10, 1); &#9;&#9;&#9; m_10_1 = new Complex (10, 1);
&#9;&#9;&#9; m_1_1 = new Complex (1, 1); &#9;&#9;&#9; m_1_1 = new Complex (1, 1);
&#9;&#9;&#9; m_11_2 = new Complex (11, 2); &#9;&#9;&#9; m_11_2 = new Complex (11, 2);
} }
&#9;void&#9;&#9;tearDown () { &#9;void&#9;&#9;tearDown () {
&#9;&#9;&#9; delete m_10_1, delete m_1_1, delete m_11_2; &#9;&#9;&#9; delete m_10_1, delete m_1_1, delete m_11_2;

View File

@ -20,8 +20,8 @@ class CppUnit_API CppUnitException: public std::exception
/// descriptive strings through its what() method /// descriptive strings through its what() method
{ {
public: public:
CppUnitException(const std::string& message = "", CppUnitException(const std::string& message = "",
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER, long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
const std::string& fileName = CPPUNIT_UNKNOWNFILENAME); const std::string& fileName = CPPUNIT_UNKNOWNFILENAME);
CppUnitException(const std::string& message, CppUnitException(const std::string& message,
long lineNumber, long lineNumber,
@ -110,26 +110,26 @@ inline const char* CppUnitException::what() const throw ()
inline long CppUnitException::lineNumber() const inline long CppUnitException::lineNumber() const
{ {
return _lineNumber; return _lineNumber;
} }
inline long CppUnitException::data1LineNumber() const inline long CppUnitException::data1LineNumber() const
{ {
return _data1lineNumber; return _data1lineNumber;
} }
inline long CppUnitException::data2LineNumber() const inline long CppUnitException::data2LineNumber() const
{ {
return _data2lineNumber; return _data2lineNumber;
} }
// The file in which the error occurred // The file in which the error occurred
inline const std::string& CppUnitException::fileName() const inline const std::string& CppUnitException::fileName() const
{ {
return _fileName; return _fileName;
} }

View File

@ -45,11 +45,11 @@ namespace CppUnit {
* *
* see TestSuite * see TestSuite
*/ */
template <class ClassUnderTest> template <class ClassUnderTest>
class Orthodox: public TestCase class Orthodox: public TestCase
{ {
public: public:
Orthodox(): TestCase("Orthodox") Orthodox(): TestCase("Orthodox")
{ {
} }
@ -60,7 +60,7 @@ protected:
// Run an orthodoxy test // Run an orthodoxy test
template <class ClassUnderTest> template <class ClassUnderTest>
void Orthodox<ClassUnderTest>::runTest() void Orthodox<ClassUnderTest>::runTest()
{ {
// make sure we have a default constructor // make sure we have a default constructor
@ -90,7 +90,7 @@ void Orthodox<ClassUnderTest>::runTest()
// Exercise a call // Exercise a call
template <class ClassUnderTest> template <class ClassUnderTest>
ClassUnderTest Orthodox<ClassUnderTest>::call(ClassUnderTest object) ClassUnderTest Orthodox<ClassUnderTest>::call(ClassUnderTest object)
{ {
return object; return object;

View File

@ -29,7 +29,7 @@ class CppUnit_API RepeatedTest: public TestDecorator
REFERENCEOBJECT (RepeatedTest) REFERENCEOBJECT (RepeatedTest)
public: public:
RepeatedTest(Test* test, int timesRepeat): TestDecorator (test), _timesRepeat (timesRepeat) RepeatedTest(Test* test, int timesRepeat): TestDecorator (test), _timesRepeat (timesRepeat)
{ {
} }
@ -59,7 +59,7 @@ inline std::string RepeatedTest::toString()
// Runs a repeated test // Runs a repeated test
inline void RepeatedTest::run(TestResult *result) inline void RepeatedTest::run(TestResult *result)
{ {
for (int n = 0; n < _timesRepeat; n++) for (int n = 0; n < _timesRepeat; n++)
{ {
if (result->shouldStop()) if (result->shouldStop())
break; break;

View File

@ -64,7 +64,7 @@ inline void Test::run(TestResult *result, const Callback& callback)
// Counts the number of test cases that will be run by this test. // Counts the number of test cases that will be run by this test.
inline int Test::countTestCases() const inline int Test::countTestCases() const
{ {
return 0; return 0;
} }

View File

@ -57,7 +57,7 @@ inline TestFailure::TestFailure(Test* failedTest, CppUnitException* thrownExcept
// Deletes the owned exception. // Deletes the owned exception.
inline TestFailure::~TestFailure() inline TestFailure::~TestFailure()
{ {
delete _thrownException; delete _thrownException;
} }

View File

@ -67,7 +67,7 @@ public:
SynchronizationObject() SynchronizationObject()
{ {
} }
virtual ~SynchronizationObject() virtual ~SynchronizationObject()
{ {
} }
@ -75,7 +75,7 @@ public:
virtual void lock() virtual void lock()
{ {
} }
virtual void unlock() virtual void unlock()
{ {
} }
@ -112,7 +112,7 @@ protected:
// Construct a TestResult // Construct a TestResult
inline TestResult::TestResult(): _syncObject(new SynchronizationObject()) inline TestResult::TestResult(): _syncObject(new SynchronizationObject())
{ {
_runTests = 0; _runTests = 0;
_stop = false; _stop = false;
} }
@ -121,7 +121,7 @@ inline TestResult::TestResult(): _syncObject(new SynchronizationObject())
// caused the error // caused the error
inline void TestResult::addError(Test* test, CppUnitException* e) inline void TestResult::addError(Test* test, CppUnitException* e)
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
_errors.push_back(new TestFailure(test, e)); _errors.push_back(new TestFailure(test, e));
} }
@ -130,7 +130,7 @@ inline void TestResult::addError(Test* test, CppUnitException* e)
// caused the failure. // caused the failure.
inline void TestResult::addFailure(Test* test, CppUnitException* e) inline void TestResult::addFailure(Test* test, CppUnitException* e)
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
_failures.push_back(new TestFailure(test, e)); _failures.push_back(new TestFailure(test, e));
} }
@ -138,7 +138,7 @@ inline void TestResult::addFailure(Test* test, CppUnitException* e)
// Informs the result that a test will be started. // Informs the result that a test will be started.
inline void TestResult::startTest(Test* test) inline void TestResult::startTest(Test* test)
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
_runTests++; _runTests++;
} }
@ -153,7 +153,7 @@ inline void TestResult::endTest(Test* test)
// Gets the number of run tests. // Gets the number of run tests.
inline int TestResult::runTests() inline int TestResult::runTests()
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
return _runTests; return _runTests;
} }
@ -161,7 +161,7 @@ inline int TestResult::runTests()
// Gets the number of detected errors. // Gets the number of detected errors.
inline int TestResult::testErrors() inline int TestResult::testErrors()
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
return (int) _errors.size(); return (int) _errors.size();
} }
@ -169,7 +169,7 @@ inline int TestResult::testErrors()
// Gets the number of detected failures. // Gets the number of detected failures.
inline int TestResult::testFailures() inline int TestResult::testFailures()
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
return (int) _failures.size(); return (int) _failures.size();
} }
@ -177,15 +177,15 @@ inline int TestResult::testFailures()
// Returns whether the entire test was successful or not. // Returns whether the entire test was successful or not.
inline bool TestResult::wasSuccessful() inline bool TestResult::wasSuccessful()
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
return _failures.size() == 0 && _errors.size () == 0; return _failures.size() == 0 && _errors.size () == 0;
} }
// Returns a std::vector of the errors. // Returns a std::vector of the errors.
inline std::vector<TestFailure*>& TestResult::errors() inline std::vector<TestFailure*>& TestResult::errors()
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
return _errors; return _errors;
} }
@ -193,7 +193,7 @@ inline std::vector<TestFailure*>& TestResult::errors()
// Returns a std::vector of the failures. // Returns a std::vector of the failures.
inline std::vector<TestFailure*>& TestResult::failures() inline std::vector<TestFailure*>& TestResult::failures()
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
return _failures; return _failures;
} }
@ -201,7 +201,7 @@ inline std::vector<TestFailure*>& TestResult::failures()
// Returns whether testing should be stopped // Returns whether testing should be stopped
inline bool TestResult::shouldStop() inline bool TestResult::shouldStop()
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
return _stop; return _stop;
} }
@ -209,7 +209,7 @@ inline bool TestResult::shouldStop()
// Stop testing // Stop testing
inline void TestResult::stop() inline void TestResult::stop()
{ {
ExclusiveZone zone(_syncObject); ExclusiveZone zone(_syncObject);
_stop = true; _stop = true;
} }
@ -218,7 +218,7 @@ inline void TestResult::stop()
// TestResult assumes ownership of the object // TestResult assumes ownership of the object
inline void TestResult::setSynchronizationObject(SynchronizationObject* syncObject) inline void TestResult::setSynchronizationObject(SynchronizationObject* syncObject)
{ {
delete _syncObject; delete _syncObject;
_syncObject = syncObject; _syncObject = syncObject;
} }

View File

@ -24,17 +24,17 @@ class CppUnit_API TestSetup: public TestDecorator
REFERENCEOBJECT (TestSetup) REFERENCEOBJECT (TestSetup)
public: public:
TestSetup(Test* test): TestDecorator(test) TestSetup(Test* test): TestDecorator(test)
{ {
} }
void run(TestResult* result); void run(TestResult* result);
protected: protected:
void setUp() void setUp()
{ {
} }
void tearDown() void tearDown()
{ {
} }
@ -44,7 +44,7 @@ protected:
inline void TestSetup::run(TestResult* result) inline void TestSetup::run(TestResult* result)
{ {
setUp(); setUp();
TestDecorator::run(result); TestDecorator::run(result);
tearDown(); tearDown();
} }

View File

@ -48,7 +48,7 @@ public:
Test::Type getType() const; Test::Type getType() const;
virtual void deleteContents(); virtual void deleteContents();
const std::vector<Test*> tests() const; const std::vector<Test*> tests() const;
private: private:
@ -80,7 +80,7 @@ inline void TestSuite::addTest(Test* test)
// Returns a std::string representation of the test suite. // Returns a std::string representation of the test suite.
inline std::string TestSuite::toString() const inline std::string TestSuite::toString() const
{ {
return "suite " + _name; return "suite " + _name;
} }
// Returns the type of the test, see Test::Type // Returns the type of the test, see Test::Type

View File

@ -31,7 +31,7 @@ public:
virtual void printErrors(std::ostream& stream); virtual void printErrors(std::ostream& stream);
virtual void printFailures(std::ostream& stream); virtual void printFailures(std::ostream& stream);
virtual void printHeader(std::ostream& stream); virtual void printHeader(std::ostream& stream);
protected: protected:
std::string shortName(const std::string& testName); std::string shortName(const std::string& testName);
void setup(); void setup();

View File

@ -32,26 +32,26 @@ inline std::string estring(std::string& expandedString)
// Create a std::string from an int // Create a std::string from an int
inline std::string estring(int number) inline std::string estring(int number)
{ {
char buffer[50]; char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%d", number); std::snprintf(buffer, sizeof(buffer), "%d", number);
return std::string (buffer); return std::string (buffer);
} }
// Create a string from a long // Create a string from a long
inline std::string estring(long number) inline std::string estring(long number)
{ {
char buffer[50]; char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%ld", number); std::snprintf(buffer, sizeof(buffer), "%ld", number);
return std::string (buffer); return std::string (buffer);
} }
// Create a std::string from a double // Create a std::string from a double
inline std::string estring(double number) inline std::string estring(double number)
{ {
char buffer[50]; char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%lf", number); std::snprintf(buffer, sizeof(buffer), "%lf", number);
return std::string(buffer); return std::string(buffer);
} }
@ -59,8 +59,8 @@ inline std::string estring(double number)
// Create a std::string from a double // Create a std::string from a double
inline std::string estring(const void* ptr) inline std::string estring(const void* ptr)
{ {
char buffer[50]; char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%p", ptr); std::snprintf(buffer, sizeof(buffer), "%p", ptr);
return std::string(buffer); return std::string(buffer);
} }

View File

@ -21,7 +21,7 @@ void TestSuite::deleteContents()
// Runs the tests and collects their result in a TestResult. // Runs the tests and collects their result in a TestResult.
void TestSuite::run(TestResult *result, const Test::Callback& callback) void TestSuite::run(TestResult *result, const Test::Callback& callback)
{ {
for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it) for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it)
{ {
if (result->shouldStop ()) if (result->shouldStop ())
break; break;

View File

@ -43,8 +43,8 @@ public:
/// Destroys the CipherFactory. /// Destroys the CipherFactory.
Cipher* createCipher(const CipherKey& key); Cipher* createCipher(const CipherKey& key);
/// Creates a Cipher object for the given Cipher name. Valid cipher /// Creates a Cipher object for the given Cipher name. Valid cipher
/// names depend on the OpenSSL version the library is linked with; /// names depend on the OpenSSL version the library is linked with;
/// see the output of /// see the output of
/// ///
/// openssl enc --help /// openssl enc --help
@ -64,7 +64,7 @@ public:
Cipher* createCipher(const EVPPKey& key); Cipher* createCipher(const EVPPKey& key);
/// Creates an EVPCipher using the given EVP key /// Creates an EVPCipher using the given EVP key
/// for public key encryption/private key decryption. /// for public key encryption/private key decryption.
static CipherFactory& defaultFactory(); static CipherFactory& defaultFactory();
/// Returns the default CipherFactory. /// Returns the default CipherFactory.

View File

@ -39,13 +39,13 @@ public:
/// See the OpenSSL documentation for a list of supported digest algorithms. /// See the OpenSSL documentation for a list of supported digest algorithms.
/// ///
/// Throws a Poco::NotFoundException if no algorithm with the given name exists. /// Throws a Poco::NotFoundException if no algorithm with the given name exists.
~DigestEngine(); ~DigestEngine();
/// Destroys the DigestEngine. /// Destroys the DigestEngine.
const std::string& algorithm() const; const std::string& algorithm() const;
/// Returns the name of the digest algorithm. /// Returns the name of the digest algorithm.
int nid() const; int nid() const;
/// Returns the NID (OpenSSL object identifier) of the digest algorithm. /// Returns the NID (OpenSSL object identifier) of the digest algorithm.
@ -56,7 +56,7 @@ public:
protected: protected:
void updateImpl(const void* data, std::size_t length); void updateImpl(const void* data, std::size_t length);
private: private:
std::string _name; std::string _name;
EVP_MD_CTX* _pContext; EVP_MD_CTX* _pContext;

View File

@ -62,8 +62,8 @@ public:
ECKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase); ECKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase);
/// Creates the ECKey, by reading public and private key from the given files and /// Creates the ECKey, by reading public and private key from the given files and
/// using the given passphrase for the private key. Can only by used for signing if /// using the given passphrase for the private key. Can only by used for signing if
/// a private key is available. /// a private key is available.
ECKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase); ECKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase);
/// Creates the ECKey. Can only by used for signing if pPrivKey /// Creates the ECKey. Can only by used for signing if pPrivKey
@ -91,7 +91,7 @@ public:
void save(const std::string& publicKeyFile, void save(const std::string& publicKeyFile,
const std::string& privateKeyFile = "", const std::string& privateKeyFile = "",
const std::string& privateKeyPassphrase = "") const; const std::string& privateKeyPassphrase = "") const;
/// Exports the public and private keys to the given files. /// Exports the public and private keys to the given files.
/// ///
/// If an empty filename is specified, the corresponding key /// If an empty filename is specified, the corresponding key
/// is not exported. /// is not exported.

View File

@ -220,7 +220,7 @@ private:
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4996) // deprecation warnings #pragma warning(disable:4996) // deprecation warnings
#endif #endif
pFile = fopen(keyFile.c_str(), "r"); pFile = fopen(keyFile.c_str(), "r");
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(pop) #pragma warning(pop)

View File

@ -56,7 +56,7 @@ public:
virtual void save(const std::string& publicKeyFile, virtual void save(const std::string& publicKeyFile,
const std::string& privateKeyFile = "", const std::string& privateKeyFile = "",
const std::string& privateKeyPassphrase = "") const = 0; const std::string& privateKeyPassphrase = "") const = 0;
/// Exports the public and private keys to the given files. /// Exports the public and private keys to the given files.
/// ///
/// If an empty filename is specified, the corresponding key /// If an empty filename is specified, the corresponding key
/// is not exported. /// is not exported.

View File

@ -39,7 +39,7 @@ class Crypto_API RSADigestEngine: public Poco::DigestEngine
/// signed. Then, the hash value is encrypted, using /// signed. Then, the hash value is encrypted, using
/// the RSA private key. /// the RSA private key.
/// ///
/// To verify a signature, pass it to the verify() /// To verify a signature, pass it to the verify()
/// member function. It will decrypt the signature /// member function. It will decrypt the signature
/// using the RSA public key and compare the resulting /// using the RSA public key and compare the resulting
/// hash with the actual hash of the data. /// hash with the actual hash of the data.
@ -50,7 +50,7 @@ public:
DIGEST_MD5, DIGEST_MD5,
DIGEST_SHA1 DIGEST_SHA1
}; };
//@ deprecated //@ deprecated
RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1); RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1);
/// Creates the RSADigestEngine with the given RSA key, /// Creates the RSADigestEngine with the given RSA key,
@ -74,11 +74,11 @@ public:
void reset(); void reset();
/// Resets the engine so that a new /// Resets the engine so that a new
/// digest can be computed. /// digest can be computed.
const DigestEngine::Digest& digest(); const DigestEngine::Digest& digest();
/// Finishes the computation of the digest /// Finishes the computation of the digest
/// (the first time it's called) and /// (the first time it's called) and
/// returns the message digest. /// returns the message digest.
/// ///
/// Can be called multiple times. /// Can be called multiple times.

View File

@ -65,8 +65,8 @@ public:
RSAKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase); RSAKeyImpl(const std::string& publicKeyFile, const std::string& privateKeyFile, const std::string& privateKeyPassphrase);
/// Creates the RSAKey, by reading public and private key from the given files and /// Creates the RSAKey, by reading public and private key from the given files and
/// using the given passphrase for the private key. Can only by used for signing if /// using the given passphrase for the private key. Can only by used for signing if
/// a private key is available. /// a private key is available.
RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase); RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKeyStream, const std::string& privateKeyPassphrase);
/// Creates the RSAKey. Can only by used for signing if pPrivKey /// Creates the RSAKey. Can only by used for signing if pPrivKey
@ -97,7 +97,7 @@ public:
void save(const std::string& publicKeyFile, void save(const std::string& publicKeyFile,
const std::string& privateKeyFile = "", const std::string& privateKeyFile = "",
const std::string& privateKeyPassphrase = "") const; const std::string& privateKeyPassphrase = "") const;
/// Exports the public and private keys to the given files. /// Exports the public and private keys to the given files.
/// ///
/// If an empty filename is specified, the corresponding key /// If an empty filename is specified, the corresponding key
/// is not exported. /// is not exported.

View File

@ -52,29 +52,29 @@ public:
{ {
Poco::Crypto::initializeCrypto(); Poco::Crypto::initializeCrypto();
} }
~RSAApp() ~RSAApp()
{ {
Poco::Crypto::uninitializeCrypto(); Poco::Crypto::uninitializeCrypto();
} }
protected: protected:
void initialize(Application& self) void initialize(Application& self)
{ {
loadConfiguration(); // load default configuration files, if present loadConfiguration(); // load default configuration files, if present
Application::initialize(self); Application::initialize(self);
} }
void uninitialize() void uninitialize()
{ {
Application::uninitialize(); Application::uninitialize();
} }
void reinitialize(Application& self) void reinitialize(Application& self)
{ {
Application::reinitialize(self); Application::reinitialize(self);
} }
void defineOptions(OptionSet& options) void defineOptions(OptionSet& options)
{ {
Application::defineOptions(options); Application::defineOptions(options);
@ -97,7 +97,7 @@ protected:
.repeatable(false) .repeatable(false)
.argument("512|1024|2048|4096") .argument("512|1024|2048|4096")
.callback(OptionCallback<RSAApp>(this, &RSAApp::handleKeyLength))); .callback(OptionCallback<RSAApp>(this, &RSAApp::handleKeyLength)));
options.addOption( options.addOption(
Option("exponent", "e", "defines the exponent of the key") Option("exponent", "e", "defines the exponent of the key")
.required(false) .required(false)
@ -119,14 +119,14 @@ protected:
.argument("pwd") .argument("pwd")
.callback(OptionCallback<RSAApp>(this, &RSAApp::handlePassword))); .callback(OptionCallback<RSAApp>(this, &RSAApp::handlePassword)));
} }
void handleHelp(const std::string& name, const std::string& value) void handleHelp(const std::string& name, const std::string& value)
{ {
_helpRequested = true; _helpRequested = true;
displayHelp(); displayHelp();
stopOptionsProcessing(); stopOptionsProcessing();
} }
void handleKeyLength(const std::string& name, const std::string& value) void handleKeyLength(const std::string& name, const std::string& value)
{ {
int keyLen = Poco::NumberParser::parse(value); int keyLen = Poco::NumberParser::parse(value);
@ -150,12 +150,12 @@ protected:
throw Poco::Util::IncompatibleOptionsException("Empty file prefix forbidden"); throw Poco::Util::IncompatibleOptionsException("Empty file prefix forbidden");
_name = value; _name = value;
} }
void handlePassword(const std::string& name, const std::string& value) void handlePassword(const std::string& name, const std::string& value)
{ {
_pwd = value; _pwd = value;
} }
void displayHelp() void displayHelp()
{ {
HelpFormatter helpFormatter(options()); HelpFormatter helpFormatter(options());
@ -176,14 +176,14 @@ protected:
logger().information("Generating key: DONE"); logger().information("Generating key: DONE");
std::string pubFile(_name + ".pub"); std::string pubFile(_name + ".pub");
std::string privFile(_name + ".priv"); std::string privFile(_name + ".priv");
logger().information("Saving key to " + pubFile + " and " + privFile); logger().information("Saving key to " + pubFile + " and " + privFile);
key.save(pubFile, privFile, _pwd); key.save(pubFile, privFile, _pwd);
logger().information("Key saved"); logger().information("Key saved");
} }
return Application::EXIT_OK; return Application::EXIT_OK;
} }
private: private:
bool _helpRequested; bool _helpRequested;
RSAKey::KeyLength _length; RSAKey::KeyLength _length;

View File

@ -28,7 +28,7 @@ CryptoTransform::~CryptoTransform()
{ {
} }
int CryptoTransform::setPadding(int padding) int CryptoTransform::setPadding(int padding)
{ {
return 1; return 1;

View File

@ -26,10 +26,10 @@ DigestEngine::DigestEngine(const std::string& name):
{ {
const EVP_MD* md = EVP_get_digestbyname(_name.c_str()); const EVP_MD* md = EVP_get_digestbyname(_name.c_str());
if (!md) throw Poco::NotFoundException(_name); if (!md) throw Poco::NotFoundException(_name);
EVP_DigestInit_ex(_pContext, md, NULL); EVP_DigestInit_ex(_pContext, md, NULL);
} }
DigestEngine::~DigestEngine() DigestEngine::~DigestEngine()
{ {
EVP_MD_CTX_destroy(_pContext); EVP_MD_CTX_destroy(_pContext);

View File

@ -51,7 +51,7 @@ void RSADigestEngine::reset()
_signature.clear(); _signature.clear();
} }
const DigestEngine::Digest& RSADigestEngine::digest() const DigestEngine::Digest& RSADigestEngine::digest()
{ {
if (_digest.empty()) if (_digest.empty())
@ -77,7 +77,7 @@ const DigestEngine::Digest& RSADigestEngine::signature()
return _signature; return _signature;
} }
bool RSADigestEngine::verify(const DigestEngine::Digest& sig) bool RSADigestEngine::verify(const DigestEngine::Digest& sig)
{ {
digest(); digest();

View File

@ -47,7 +47,7 @@ void DigestEngineTest::testMD5()
engine.update("abcdefghijklmnopqrstuvwxyz"); engine.update("abcdefghijklmnopqrstuvwxyz");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "c3fcd3d76192e4007dfb496cca67e13b"); assertTrue (DigestEngine::digestToHex(engine.digest()) == "c3fcd3d76192e4007dfb496cca67e13b");
engine.update("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); engine.update("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
engine.update("abcdefghijklmnopqrstuvwxyz0123456789"); engine.update("abcdefghijklmnopqrstuvwxyz0123456789");
assertTrue (DigestEngine::digestToHex(engine.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f"); assertTrue (DigestEngine::digestToHex(engine.digest()) == "d174ab98d277d9f5a5611c2c9f419d9f");

View File

@ -23,7 +23,7 @@ public:
{ {
Poco::Crypto::initializeCrypto(); Poco::Crypto::initializeCrypto();
} }
~CryptoInitializer() ~CryptoInitializer()
{ {
Poco::Crypto::uninitializeCrypto(); Poco::Crypto::uninitializeCrypto();
@ -34,7 +34,7 @@ public:
int main(int ac, char **av) int main(int ac, char **av)
{ {
CryptoInitializer ci; CryptoInitializer ci;
std::vector<std::string> args; std::vector<std::string> args;
for (int i = 0; i < ac; ++i) for (int i = 0; i < ac; ++i)
args.push_back(std::string(av[i])); args.push_back(std::string(av[i]));

View File

@ -251,7 +251,7 @@ void RSATest::testRSACipherLarge()
sizes.push_back (16383); sizes.push_back (16383);
sizes.push_back (16384); sizes.push_back (16384);
sizes.push_back (16385); sizes.push_back (16385);
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL)); Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
for (std::vector<std::size_t>::const_iterator it = sizes.begin(); it != sizes.end(); ++it) for (std::vector<std::size_t>::const_iterator it = sizes.begin(); it != sizes.end(); ++it)
{ {
@ -273,7 +273,7 @@ void RSATest::testCertificate()
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey); Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey);
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey); Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey);
std::string val("lets do some encryption"); std::string val("lets do some encryption");
std::string enc = pCipher->encryptString(val); std::string enc = pCipher->encryptString(val);
std::string dec = pCipher2->decryptString(enc); std::string dec = pCipher2->decryptString(enc);
assertTrue (dec == val); assertTrue (dec == val);

View File

@ -23,7 +23,7 @@ public:
{ {
Poco::Crypto::initializeCrypto(); Poco::Crypto::initializeCrypto();
} }
~CryptoInitializer() ~CryptoInitializer()
{ {
Poco::Crypto::uninitializeCrypto(); Poco::Crypto::uninitializeCrypto();
@ -42,7 +42,7 @@ int _tmain(int argc, wchar_t* argv[])
std::wcstombs(buffer, argv[i], sizeof(buffer)); std::wcstombs(buffer, argv[i], sizeof(buffer));
args.push_back(std::string(buffer)); args.push_back(std::string(buffer));
} }
CppUnit::TestRunner runner; CppUnit::TestRunner runner;
runner.addTest("CryptoTestSuite", CryptoTestSuite::suite()); runner.addTest("CryptoTestSuite", CryptoTestSuite::suite());
return runner.run(args) ? 0 : 1; return runner.run(args) ? 0 : 1;
} }

View File

@ -22,7 +22,7 @@ public:
{ {
Poco::Crypto::initializeCrypto(); Poco::Crypto::initializeCrypto();
} }
~CryptoInitializer() ~CryptoInitializer()
{ {
Poco::Crypto::uninitializeCrypto(); Poco::Crypto::uninitializeCrypto();

View File

@ -35,7 +35,7 @@ public:
Connector(); Connector();
/// Creates the Connector. /// Creates the Connector.
virtual ~Connector(); virtual ~Connector();
/// Destroys the Connector. /// Destroys the Connector.

View File

@ -40,10 +40,10 @@ class MySQL_API MySQLStatementImpl: public Poco::Data::StatementImpl
public: public:
MySQLStatementImpl(SessionImpl& s); MySQLStatementImpl(SessionImpl& s);
/// Creates the MySQLStatementImpl. /// Creates the MySQLStatementImpl.
~MySQLStatementImpl(); ~MySQLStatementImpl();
/// Destroys the MySQLStatementImpl. /// Destroys the MySQLStatementImpl.
protected: protected:
virtual std::size_t columnsReturned() const; virtual std::size_t columnsReturned() const;
/// Returns number of columns returned by query. /// Returns number of columns returned by query.
@ -51,32 +51,32 @@ protected:
virtual int affectedRowCount() const; virtual int affectedRowCount() const;
/// Returns the number of affected rows. /// Returns the number of affected rows.
/// Used to find out the number of rows affected by insert, delete or update. /// Used to find out the number of rows affected by insert, delete or update.
virtual const MetaColumn& metaColumn(std::size_t pos) const; virtual const MetaColumn& metaColumn(std::size_t pos) const;
/// Returns column meta data. /// Returns column meta data.
virtual bool hasNext(); virtual bool hasNext();
/// Returns true if a call to next() will return data. /// Returns true if a call to next() will return data.
virtual std::size_t next(); virtual std::size_t next();
/// Retrieves the next row from the resultset. /// Retrieves the next row from the resultset.
/// Will throw, if the resultset is empty. /// Will throw, if the resultset is empty.
virtual bool canBind() const; virtual bool canBind() const;
/// Returns true if a valid statement is set and we can bind. /// Returns true if a valid statement is set and we can bind.
virtual bool canCompile() const; virtual bool canCompile() const;
/// Returns true if another compile is possible. /// Returns true if another compile is possible.
virtual void compileImpl(); virtual void compileImpl();
/// Compiles the statement, doesn't bind yet /// Compiles the statement, doesn't bind yet
virtual void bindImpl(); virtual void bindImpl();
/// Binds parameters /// Binds parameters
virtual Poco::Data::AbstractExtractor::Ptr extractor(); virtual Poco::Data::AbstractExtractor::Ptr extractor();
/// Returns the concrete extractor used by the statement. /// Returns the concrete extractor used by the statement.
virtual Poco::Data::AbstractBinder::Ptr binder(); virtual Poco::Data::AbstractBinder::Ptr binder();
/// Returns the concrete binder used by the statement. /// Returns the concrete binder used by the statement.

View File

@ -78,16 +78,16 @@ namespace
default: default:
throw Poco::Data::MySQL::StatementException("unknown field type"); throw Poco::Data::MySQL::StatementException("unknown field type");
} }
} }
Poco::Data::MetaColumn::ColumnDataType fieldType(const MYSQL_FIELD& field) Poco::Data::MetaColumn::ColumnDataType fieldType(const MYSQL_FIELD& field)
/// Convert field MySQL-type to Poco-type /// Convert field MySQL-type to Poco-type
{ {
bool unsig = ((field.flags & UNSIGNED_FLAG) == UNSIGNED_FLAG); bool unsig = ((field.flags & UNSIGNED_FLAG) == UNSIGNED_FLAG);
switch (field.type) switch (field.type)
{ {
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
if (unsig) return Poco::Data::MetaColumn::FDT_UINT8; if (unsig) return Poco::Data::MetaColumn::FDT_UINT8;
return Poco::Data::MetaColumn::FDT_INT8; return Poco::Data::MetaColumn::FDT_INT8;
@ -96,32 +96,32 @@ namespace
return Poco::Data::MetaColumn::FDT_INT16; return Poco::Data::MetaColumn::FDT_INT16;
case MYSQL_TYPE_INT24: case MYSQL_TYPE_INT24:
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
if (unsig) return Poco::Data::MetaColumn::FDT_UINT32; if (unsig) return Poco::Data::MetaColumn::FDT_UINT32;
return Poco::Data::MetaColumn::FDT_INT32; return Poco::Data::MetaColumn::FDT_INT32;
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
return Poco::Data::MetaColumn::FDT_FLOAT; return Poco::Data::MetaColumn::FDT_FLOAT;
case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_DOUBLE:
return Poco::Data::MetaColumn::FDT_DOUBLE; return Poco::Data::MetaColumn::FDT_DOUBLE;
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
if (unsig) return Poco::Data::MetaColumn::FDT_UINT64; if (unsig) return Poco::Data::MetaColumn::FDT_UINT64;
return Poco::Data::MetaColumn::FDT_INT64; return Poco::Data::MetaColumn::FDT_INT64;
case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATE:
return Poco::Data::MetaColumn::FDT_DATE; return Poco::Data::MetaColumn::FDT_DATE;
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
return Poco::Data::MetaColumn::FDT_TIME; return Poco::Data::MetaColumn::FDT_TIME;
case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
return Poco::Data::MetaColumn::FDT_TIMESTAMP; return Poco::Data::MetaColumn::FDT_TIMESTAMP;
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
return Poco::Data::MetaColumn::FDT_STRING; return Poco::Data::MetaColumn::FDT_STRING;
@ -244,7 +244,7 @@ std::size_t ResultMetadata::length(std::size_t pos) const
} }
const unsigned char* ResultMetadata::rawData(std::size_t pos) const const unsigned char* ResultMetadata::rawData(std::size_t pos) const
{ {
if ((_lengths[pos] == 0) && (_row[pos].buffer == nullptr)) if ((_lengths[pos] == 0) && (_row[pos].buffer == nullptr))
return reinterpret_cast<const unsigned char*>(""); return reinterpret_cast<const unsigned char*>("");
@ -254,7 +254,7 @@ const unsigned char* ResultMetadata::rawData(std::size_t pos) const
} }
bool ResultMetadata::isNull(std::size_t pos) const bool ResultMetadata::isNull(std::size_t pos) const
{ {
return (_isNull[pos] != 0); return (_isNull[pos] != 0);
} }

View File

@ -10,7 +10,7 @@ include ODBC.make
objects = Binder ConnectionHandle Connector EnvironmentHandle \ objects = Binder ConnectionHandle Connector EnvironmentHandle \
Extractor ODBCException ODBCMetaColumn ODBCStatementImpl \ Extractor ODBCException ODBCMetaColumn ODBCStatementImpl \
Parameter Preparator SessionImpl TypeInfo Unicode Utility Parameter Preparator SessionImpl TypeInfo Unicode Utility
target = PocoDataODBC target = PocoDataODBC
target_version = $(LIBVERSION) target_version = $(LIBVERSION)

View File

@ -58,7 +58,7 @@ public:
/// ///
/// This can cause issues with SQL Server, resulting in an error /// This can cause issues with SQL Server, resulting in an error
/// ("The data types varchar and text are incompatible in the equal to operator") /// ("The data types varchar and text are incompatible in the equal to operator")
/// when comparing against a VARCHAR. /// when comparing against a VARCHAR.
/// ///
/// Set this to false to bind std::string to SQL_VARCHAR. /// Set this to false to bind std::string to SQL_VARCHAR.
/// ///

View File

@ -36,7 +36,7 @@ template <typename H, SQLSMALLINT handleType>
class Diagnostics class Diagnostics
/// Utility class providing functionality for retrieving ODBC diagnostic /// Utility class providing functionality for retrieving ODBC diagnostic
/// records. Diagnostics object must be created with corresponding handle /// records. Diagnostics object must be created with corresponding handle
/// as constructor argument. During construction, diagnostic records fields /// as constructor argument. During construction, diagnostic records fields
/// are populated and the object is ready for querying. /// are populated and the object is ready for querying.
{ {
public: public:
@ -92,7 +92,7 @@ public:
} }
std::string connectionName() const std::string connectionName() const
/// Returns the connection name. /// Returns the connection name.
/// If there is no active connection, connection name defaults to NONE. /// If there is no active connection, connection name defaults to NONE.
/// If connection name is not applicable for query context (such as when querying environment handle), /// If connection name is not applicable for query context (such as when querying environment handle),
/// connection name defaults to NOT_APPLICABLE. /// connection name defaults to NOT_APPLICABLE.
@ -146,54 +146,54 @@ public:
reset(); reset();
while (!Utility::isError(SQLGetDiagRec(handleType, while (!Utility::isError(SQLGetDiagRec(handleType,
_handle, _handle,
count, count,
df._sqlState, df._sqlState,
&df._nativeError, &df._nativeError,
df._message, df._message,
SQL_MESSAGE_LENGTH, SQL_MESSAGE_LENGTH,
&messageLength))) &messageLength)))
{ {
if (1 == count) if (1 == count)
{ {
// success of the following two calls is optional // success of the following two calls is optional
// (they fail if connection has not been established yet // (they fail if connection has not been established yet
// or return empty string if not applicable for the context) // or return empty string if not applicable for the context)
if (Utility::isError(SQLGetDiagField(handleType, if (Utility::isError(SQLGetDiagField(handleType,
_handle, _handle,
count, count,
SQL_DIAG_CONNECTION_NAME, SQL_DIAG_CONNECTION_NAME,
_connectionName, _connectionName,
sizeof(_connectionName), sizeof(_connectionName),
&messageLength))) &messageLength)))
{ {
std::size_t len = sizeof(_connectionName) > none.length() ? std::size_t len = sizeof(_connectionName) > none.length() ?
none.length() : sizeof(_connectionName) - 1; none.length() : sizeof(_connectionName) - 1;
std::memcpy(_connectionName, none.c_str(), len); std::memcpy(_connectionName, none.c_str(), len);
} }
else if (0 == _connectionName[0]) else if (0 == _connectionName[0])
{ {
std::size_t len = sizeof(_connectionName) > na.length() ? std::size_t len = sizeof(_connectionName) > na.length() ?
na.length() : sizeof(_connectionName) - 1; na.length() : sizeof(_connectionName) - 1;
std::memcpy(_connectionName, na.c_str(), len); std::memcpy(_connectionName, na.c_str(), len);
} }
if (Utility::isError(SQLGetDiagField(handleType, if (Utility::isError(SQLGetDiagField(handleType,
_handle, _handle,
count, count,
SQL_DIAG_SERVER_NAME, SQL_DIAG_SERVER_NAME,
_serverName, _serverName,
sizeof(_serverName), sizeof(_serverName),
&messageLength))) &messageLength)))
{ {
std::size_t len = sizeof(_serverName) > none.length() ? std::size_t len = sizeof(_serverName) > none.length() ?
none.length() : sizeof(_serverName) - 1; none.length() : sizeof(_serverName) - 1;
std::memcpy(_serverName, none.c_str(), len); std::memcpy(_serverName, none.c_str(), len);
} }
else if (0 == _serverName[0]) else if (0 == _serverName[0])
{ {
std::size_t len = sizeof(_serverName) > na.length() ? std::size_t len = sizeof(_serverName) > na.length() ?
na.length() : sizeof(_serverName) - 1; na.length() : sizeof(_serverName) - 1;
std::memcpy(_serverName, na.c_str(), len); std::memcpy(_serverName, na.c_str(), len);
} }

View File

@ -66,11 +66,11 @@ public:
std::string& toString(int index, std::string& str) const std::string& toString(int index, std::string& str) const
/// Generates the string for the diagnostic record. /// Generates the string for the diagnostic record.
{ {
if ((index < 0) || (index > (count() - 1))) if ((index < 0) || (index > (count() - 1)))
return str; return str;
std::string s; std::string s;
Poco::format(s, Poco::format(s,
"===========================\n" "===========================\n"
"ODBC Diagnostic record #%d:\n" "ODBC Diagnostic record #%d:\n"
"===========================\n" "===========================\n"
@ -90,7 +90,7 @@ public:
{ {
std::string str; std::string str;
Poco::format(str, Poco::format(str,
"Connection:%s\nServer:%s\n", "Connection:%s\nServer:%s\n",
_diagnostics.connectionName(), _diagnostics.connectionName(),
_diagnostics.serverName()); _diagnostics.serverName());

View File

@ -39,14 +39,14 @@ class Handle
/// ODBC handle class template /// ODBC handle class template
{ {
public: public:
Handle(const ConnectionHandle& rConnection): Handle(const ConnectionHandle& rConnection):
_rConnection(rConnection), _rConnection(rConnection),
_handle(0) _handle(0)
/// Creates the Handle. /// Creates the Handle.
{ {
if (Utility::isError(SQLAllocHandle(handleType, if (Utility::isError(SQLAllocHandle(handleType,
_rConnection, _rConnection,
&_handle))) &_handle)))
{ {
throw ODBCException("Could not allocate statement handle."); throw ODBCException("Could not allocate statement handle.");
} }
@ -58,7 +58,7 @@ public:
try try
{ {
#if defined(_DEBUG) #if defined(_DEBUG)
SQLRETURN rc = SQLRETURN rc =
#endif #endif
SQLFreeHandle(handleType, _handle); SQLFreeHandle(handleType, _handle);
// N.B. Destructors should not throw, but neither do we want to // N.B. Destructors should not throw, but neither do we want to

View File

@ -39,15 +39,15 @@ class ODBC_API ODBCMetaColumn: public MetaColumn
public: public:
explicit ODBCMetaColumn(const StatementHandle& rStmt, std::size_t position); explicit ODBCMetaColumn(const StatementHandle& rStmt, std::size_t position);
/// Creates the ODBCMetaColumn. /// Creates the ODBCMetaColumn.
~ODBCMetaColumn(); ~ODBCMetaColumn();
/// Destroys the ODBCMetaColumn. /// Destroys the ODBCMetaColumn.
std::size_t dataLength() const; std::size_t dataLength() const;
/// A numeric value that is either the maximum or actual character length of a character /// A numeric value that is either the maximum or actual character length of a character
/// string or binary data type. It is the maximum character length for a fixed-length data type, /// string or binary data type. It is the maximum character length for a fixed-length data type,
/// or the actual character length for a variable-length data type. Its value always excludes the /// or the actual character length for a variable-length data type. Its value always excludes the
/// null-termination byte that ends the character string. /// null-termination byte that ends the character string.
/// This information is returned from the SQL_DESC_LENGTH record field of the IRD. /// This information is returned from the SQL_DESC_LENGTH record field of the IRD.
bool isUnsigned() const; bool isUnsigned() const;

View File

@ -76,7 +76,7 @@ protected:
/// Returns true if another compile is possible. /// Returns true if another compile is possible.
void compileImpl(); void compileImpl();
/// Compiles the statement, doesn't bind yet. /// Compiles the statement, doesn't bind yet.
/// Does nothing if the statement has already been compiled. /// Does nothing if the statement has already been compiled.
void bindImpl(); void bindImpl();
@ -101,12 +101,12 @@ private:
typedef std::vector<ExtractorPtr> ExtractorVec; typedef std::vector<ExtractorPtr> ExtractorVec;
typedef std::vector<ODBCMetaColumn*> ColumnPtrVec; typedef std::vector<ODBCMetaColumn*> ColumnPtrVec;
typedef std::vector<ColumnPtrVec> ColumnPtrVecVec; typedef std::vector<ColumnPtrVec> ColumnPtrVecVec;
static const std::string INVALID_CURSOR_STATE; static const std::string INVALID_CURSOR_STATE;
void clear(); void clear();
/// Closes the cursor and resets indicator variables. /// Closes the cursor and resets indicator variables.
void doBind(); void doBind();
/// Binds parameters. /// Binds parameters.
@ -119,8 +119,8 @@ private:
void doPrepare(); void doPrepare();
/// Prepares placeholders for data returned by statement. /// Prepares placeholders for data returned by statement.
/// It is called during statement compilation for SQL statements /// It is called during statement compilation for SQL statements
/// returning data. For stored procedures returning datasets, /// returning data. For stored procedures returning datasets,
/// it is called upon the first check for data availability /// it is called upon the first check for data availability
/// (see hasNext() function). /// (see hasNext() function).
bool hasData() const; bool hasData() const;
@ -133,8 +133,8 @@ private:
/// Returns true if there is a row fetched but not yet extracted. /// Returns true if there is a row fetched but not yet extracted.
void putData(); void putData();
/// Called whenever SQLExecute returns SQL_NEED_DATA. This is expected /// Called whenever SQLExecute returns SQL_NEED_DATA. This is expected
/// behavior for PB_AT_EXEC binding mode. /// behavior for PB_AT_EXEC binding mode.
void addPreparator(); void addPreparator();
void fillColumns(); void fillColumns();

View File

@ -36,7 +36,7 @@ class ODBC_API Parameter
public: public:
explicit Parameter(const StatementHandle& rStmt, std::size_t colNum); explicit Parameter(const StatementHandle& rStmt, std::size_t colNum);
/// Creates the Parameter. /// Creates the Parameter.
~Parameter(); ~Parameter();
/// Destroys the Parameter. /// Destroys the Parameter.
@ -47,11 +47,11 @@ public:
/// Returns the SQL data type. /// Returns the SQL data type.
std::size_t columnSize() const; std::size_t columnSize() const;
/// Returns the the size of the column or expression of the corresponding /// Returns the the size of the column or expression of the corresponding
/// parameter marker as defined by the data source. /// parameter marker as defined by the data source.
std::size_t decimalDigits() const; std::size_t decimalDigits() const;
/// Returns the number of decimal digits of the column or expression /// Returns the number of decimal digits of the column or expression
/// of the corresponding parameter as defined by the data source. /// of the corresponding parameter as defined by the data source.
bool isNullable() const; bool isNullable() const;

View File

@ -54,15 +54,15 @@ public:
SessionImpl(const std::string& connect, SessionImpl(const std::string& connect,
std::size_t loginTimeout, std::size_t loginTimeout,
std::size_t maxFieldSize = ODBC_MAX_FIELD_SIZE, std::size_t maxFieldSize = ODBC_MAX_FIELD_SIZE,
bool autoBind = true, bool autoBind = true,
bool autoExtract = true); bool autoExtract = true);
/// Creates the SessionImpl. Opens a connection to the database. /// Creates the SessionImpl. Opens a connection to the database.
/// Throws NotConnectedException if connection was not succesful. /// Throws NotConnectedException if connection was not succesful.
//@ deprecated //@ deprecated
SessionImpl(const std::string& connect, SessionImpl(const std::string& connect,
Poco::Any maxFieldSize = ODBC_MAX_FIELD_SIZE, Poco::Any maxFieldSize = ODBC_MAX_FIELD_SIZE,
bool enforceCapability=false, bool enforceCapability=false,
bool autoBind = true, bool autoBind = true,
bool autoExtract = true); bool autoExtract = true);
@ -144,7 +144,7 @@ public:
void setMaxFieldSize(const std::string& rName, const Poco::Any& rValue); void setMaxFieldSize(const std::string& rName, const Poco::Any& rValue);
/// Sets the max field size (the default used when column size is unknown). /// Sets the max field size (the default used when column size is unknown).
Poco::Any getMaxFieldSize(const std::string& rName="") const; Poco::Any getMaxFieldSize(const std::string& rName="") const;
/// Returns the max field size (the default used when column size is unknown). /// Returns the max field size (the default used when column size is unknown).
@ -154,11 +154,11 @@ public:
void setQueryTimeout(const std::string&, const Poco::Any& value); void setQueryTimeout(const std::string&, const Poco::Any& value);
/// Sets the timeout (in seconds) for queries. /// Sets the timeout (in seconds) for queries.
/// Value must be of type int. /// Value must be of type int.
Poco::Any getQueryTimeout(const std::string&) const; Poco::Any getQueryTimeout(const std::string&) const;
/// Returns the timeout (in seconds) for queries, /// Returns the timeout (in seconds) for queries,
/// or -1 if no timeout has been set. /// or -1 if no timeout has been set.
int queryTimeout() const; int queryTimeout() const;
/// Returns the timeout (in seconds) for queries, /// Returns the timeout (in seconds) for queries,
/// or -1 if no timeout has been set. /// or -1 if no timeout has been set.
@ -230,7 +230,7 @@ inline void SessionImpl::setMaxFieldSize(const std::string& rName, const Poco::A
_maxFieldSize = rValue; _maxFieldSize = rValue;
} }
inline Poco::Any SessionImpl::getMaxFieldSize(const std::string& rName) const inline Poco::Any SessionImpl::getMaxFieldSize(const std::string& rName) const
{ {
return _maxFieldSize; return _maxFieldSize;
@ -242,7 +242,7 @@ inline void SessionImpl::setDataTypeInfo(const std::string& rName, const Poco::A
throw InvalidAccessException(); throw InvalidAccessException();
} }
inline Poco::Any SessionImpl::dataTypeInfo(const std::string& rName) const inline Poco::Any SessionImpl::dataTypeInfo(const std::string& rName) const
{ {
return &_dataTypes; return &_dataTypes;

View File

@ -89,12 +89,12 @@ public:
/// Returns information about specified data type as specified by parameter 'type'. /// Returns information about specified data type as specified by parameter 'type'.
/// The requested information is specified by parameter 'param'. /// The requested information is specified by parameter 'param'.
/// Will fail with a Poco::NotFoundException thrown if the param is not found /// Will fail with a Poco::NotFoundException thrown if the param is not found
bool tryGetInfo(SQLSMALLINT type, const std::string& param, DynamicAny& result) const; bool tryGetInfo(SQLSMALLINT type, const std::string& param, DynamicAny& result) const;
/// Returns information about specified data type as specified by parameter 'type' in param result. /// Returns information about specified data type as specified by parameter 'type' in param result.
/// The requested information is specified by parameter 'param'. /// The requested information is specified by parameter 'param'.
/// Will return false if the param is not found. The value of result will be not changed in this case. /// Will return false if the param is not found. The value of result will be not changed in this case.
void print(std::ostream& ostr); void print(std::ostream& ostr);
/// Prints all the types (as reported by the underlying database) /// Prints all the types (as reported by the underlying database)
@ -104,8 +104,8 @@ private:
void fillCTypes(); void fillCTypes();
void fillSQLTypes(); void fillSQLTypes();
DataTypeMap _cDataTypes; DataTypeMap _cDataTypes;
DataTypeMap _sqlDataTypes; DataTypeMap _sqlDataTypes;
TypeInfoVec _typeInfo; TypeInfoVec _typeInfo;
SQLHDBC* _pHDBC; SQLHDBC* _pHDBC;
}; };

View File

@ -27,7 +27,7 @@ inline void makeUTF16(SQLCHAR* pSQLChar, SQLINTEGER length, std::wstring& target
/// Utility function for conversion from UTF-8 to UTF-16 /// Utility function for conversion from UTF-8 to UTF-16
{ {
int len = length; int len = length;
if (SQL_NTS == len) if (SQL_NTS == len)
len = (int) std::strlen((const char *) pSQLChar); len = (int) std::strlen((const char *) pSQLChar);
UnicodeConverter::toUTF16((const char *) pSQLChar, len, target); UnicodeConverter::toUTF16((const char *) pSQLChar, len, target);
@ -45,7 +45,7 @@ inline void makeUTF8(Poco::Buffer<wchar_t>& buffer, SQLINTEGER length, SQLPOINTE
length /= sizeof(wchar_t); length /= sizeof(wchar_t);
std::string result; std::string result;
UnicodeConverter::toUTF8(buffer.begin(), length, result); UnicodeConverter::toUTF8(buffer.begin(), length, result);
std::memset(pTarget, 0, targetLength); std::memset(pTarget, 0, targetLength);
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(push) #pragma warning(push)

View File

@ -24,14 +24,14 @@ namespace Data {
namespace ODBC { namespace ODBC {
ConnectionHandle::ConnectionHandle(EnvironmentHandle* pEnvironment): ConnectionHandle::ConnectionHandle(EnvironmentHandle* pEnvironment):
_pEnvironment(pEnvironment ? pEnvironment : new EnvironmentHandle), _pEnvironment(pEnvironment ? pEnvironment : new EnvironmentHandle),
_hdbc(SQL_NULL_HDBC), _hdbc(SQL_NULL_HDBC),
_ownsEnvironment(pEnvironment ? false : true) _ownsEnvironment(pEnvironment ? false : true)
{ {
if (Utility::isError(SQLAllocHandle(SQL_HANDLE_DBC, if (Utility::isError(SQLAllocHandle(SQL_HANDLE_DBC,
_pEnvironment->handle(), _pEnvironment->handle(),
&_hdbc))) &_hdbc)))
{ {
throw ODBCException("Could not allocate connection handle."); throw ODBCException("Could not allocate connection handle.");
} }

View File

@ -26,12 +26,12 @@ namespace ODBC {
EnvironmentHandle::EnvironmentHandle(): _henv(SQL_NULL_HENV) EnvironmentHandle::EnvironmentHandle(): _henv(SQL_NULL_HENV)
{ {
if (Utility::isError(SQLAllocHandle(SQL_HANDLE_ENV, if (Utility::isError(SQLAllocHandle(SQL_HANDLE_ENV,
SQL_NULL_HANDLE, SQL_NULL_HANDLE,
&_henv)) || &_henv)) ||
Utility::isError(SQLSetEnvAttr(_henv, Utility::isError(SQLSetEnvAttr(_henv,
SQL_ATTR_ODBC_VERSION, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER) SQL_OV_ODBC3, (SQLPOINTER) SQL_OV_ODBC3,
0))) 0)))
{ {
throw ODBCException("Could not initialize environment."); throw ODBCException("Could not initialize environment.");

View File

@ -23,14 +23,14 @@ namespace Data {
namespace ODBC { namespace ODBC {
Parameter::Parameter(const StatementHandle& rStmt, std::size_t colNum) : Parameter::Parameter(const StatementHandle& rStmt, std::size_t colNum) :
_rStmt(rStmt), _rStmt(rStmt),
_number(colNum) _number(colNum)
{ {
init(); init();
} }
Parameter::~Parameter() Parameter::~Parameter()
{ {
} }
@ -38,8 +38,8 @@ Parameter::~Parameter()
void Parameter::init() void Parameter::init()
{ {
if (Utility::isError(SQLDescribeParam(_rStmt, if (Utility::isError(SQLDescribeParam(_rStmt,
(SQLUSMALLINT) _number + 1, (SQLUSMALLINT) _number + 1,
&_dataType, &_dataType,
&_columnSize, &_columnSize,
&_decimalDigits, &_decimalDigits,

View File

@ -31,7 +31,7 @@ SessionImpl::SessionImpl(const std::string& connect,
std::size_t loginTimeout, std::size_t loginTimeout,
std::size_t maxFieldSize, std::size_t maxFieldSize,
bool autoBind, bool autoBind,
bool autoExtract): bool autoExtract):
Poco::Data::AbstractSessionImpl<SessionImpl>(connect, loginTimeout), Poco::Data::AbstractSessionImpl<SessionImpl>(connect, loginTimeout),
_connector(Connector::KEY), _connector(Connector::KEY),
_maxFieldSize(maxFieldSize), _maxFieldSize(maxFieldSize),
@ -49,7 +49,7 @@ SessionImpl::SessionImpl(const std::string& connect,
SessionImpl::SessionImpl(const std::string& connect, SessionImpl::SessionImpl(const std::string& connect,
Poco::Any maxFieldSize, Poco::Any maxFieldSize,
bool enforceCapability, bool enforceCapability,
bool autoBind, bool autoBind,
bool autoExtract): Poco::Data::AbstractSessionImpl<SessionImpl>(connect), bool autoExtract): Poco::Data::AbstractSessionImpl<SessionImpl>(connect),
@ -136,20 +136,20 @@ void SessionImpl::open(const std::string& connect)
} }
_dataTypes.fillTypeInfo(_db); _dataTypes.fillTypeInfo(_db);
addProperty("dataTypeInfo", addProperty("dataTypeInfo",
&SessionImpl::setDataTypeInfo, &SessionImpl::setDataTypeInfo,
&SessionImpl::dataTypeInfo); &SessionImpl::dataTypeInfo);
addFeature("autoCommit", addFeature("autoCommit",
&SessionImpl::autoCommit, &SessionImpl::autoCommit,
&SessionImpl::isAutoCommit); &SessionImpl::isAutoCommit);
addFeature("autoBind", addFeature("autoBind",
&SessionImpl::autoBind, &SessionImpl::autoBind,
&SessionImpl::isAutoBind); &SessionImpl::isAutoBind);
addFeature("autoExtract", addFeature("autoExtract",
&SessionImpl::autoExtract, &SessionImpl::autoExtract,
&SessionImpl::isAutoExtract); &SessionImpl::isAutoExtract);
addProperty("maxFieldSize", addProperty("maxFieldSize",
@ -222,11 +222,11 @@ bool SessionImpl::canTransact() const
if (ODBC_TXN_CAPABILITY_UNKNOWN == _canTransact) if (ODBC_TXN_CAPABILITY_UNKNOWN == _canTransact)
{ {
SQLUSMALLINT ret; SQLUSMALLINT ret;
checkError(Poco::Data::ODBC::SQLGetInfo(_db, SQL_TXN_CAPABLE, &ret, 0, 0), checkError(Poco::Data::ODBC::SQLGetInfo(_db, SQL_TXN_CAPABLE, &ret, 0, 0),
"Failed to obtain transaction capability info."); "Failed to obtain transaction capability info.");
_canTransact = (SQL_TC_NONE != ret) ? _canTransact = (SQL_TC_NONE != ret) ?
ODBC_TXN_CAPABILITY_TRUE : ODBC_TXN_CAPABILITY_TRUE :
ODBC_TXN_CAPABILITY_FALSE; ODBC_TXN_CAPABILITY_FALSE;
} }
@ -329,10 +329,10 @@ Poco::UInt32 SessionImpl::transactionIsolation(SQLULEN isolation)
void SessionImpl::autoCommit(const std::string&, bool val) void SessionImpl::autoCommit(const std::string&, bool val)
{ {
checkError(Poco::Data::ODBC::SQLSetConnectAttr(_db, checkError(Poco::Data::ODBC::SQLSetConnectAttr(_db,
SQL_ATTR_AUTOCOMMIT, SQL_ATTR_AUTOCOMMIT,
val ? (SQLPOINTER) SQL_AUTOCOMMIT_ON : val ? (SQLPOINTER) SQL_AUTOCOMMIT_ON :
(SQLPOINTER) SQL_AUTOCOMMIT_OFF, (SQLPOINTER) SQL_AUTOCOMMIT_OFF,
SQL_IS_UINTEGER), "Failed to set automatic commit."); SQL_IS_UINTEGER), "Failed to set automatic commit.");
} }
@ -415,7 +415,7 @@ void SessionImpl::close()
{ {
commit(); commit();
} }
catch (ConnectionException&) catch (ConnectionException&)
{ {
} }
@ -433,7 +433,7 @@ int SessionImpl::maxStatementLength() const
0, 0,
0))) 0)))
{ {
throw ConnectionException(_db, throw ConnectionException(_db,
"SQLGetInfo(SQL_MAXIMUM_STATEMENT_LENGTH)"); "SQLGetInfo(SQL_MAXIMUM_STATEMENT_LENGTH)");
} }

View File

@ -110,7 +110,7 @@ void TypeInfo::fillTypeInfo(SQLHDBC pHDBC)
char literalSuffix[stringSize] = { 0 }; char literalSuffix[stringSize] = { 0 };
char createParams[stringSize] = { 0 }; char createParams[stringSize] = { 0 };
char localTypeName[stringSize] = { 0 }; char localTypeName[stringSize] = { 0 };
TypeInfoTup ti("TYPE_NAME", "", TypeInfoTup ti("TYPE_NAME", "",
"DATA_TYPE", 0, "DATA_TYPE", 0,
"COLUMN_SIZE", 0, "COLUMN_SIZE", 0,
@ -142,10 +142,10 @@ void TypeInfo::fillTypeInfo(SQLHDBC pHDBC)
ti.set<4>(literalSuffix); ti.set<4>(literalSuffix);
rc = SQLGetData(hstmt, 6, SQL_C_CHAR, createParams, sizeof(createParams), &ind); rc = SQLGetData(hstmt, 6, SQL_C_CHAR, createParams, sizeof(createParams), &ind);
ti.set<5>(createParams); ti.set<5>(createParams);
rc = SQLGetData(hstmt, 7, SQL_C_SSHORT, &ti.get<6>(), sizeof(SQLSMALLINT), &ind); rc = SQLGetData(hstmt, 7, SQL_C_SSHORT, &ti.get<6>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 8, SQL_C_SSHORT, &ti.get<7>(), sizeof(SQLSMALLINT), &ind); rc = SQLGetData(hstmt, 8, SQL_C_SSHORT, &ti.get<7>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 9, SQL_C_SSHORT, &ti.get<8>(), sizeof(SQLSMALLINT), &ind); rc = SQLGetData(hstmt, 9, SQL_C_SSHORT, &ti.get<8>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 10, SQL_C_SSHORT, &ti.get<9>(), sizeof(SQLSMALLINT), &ind); rc = SQLGetData(hstmt, 10, SQL_C_SSHORT, &ti.get<9>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 11, SQL_C_SSHORT, &ti.get<10>(), sizeof(SQLSMALLINT), &ind); rc = SQLGetData(hstmt, 11, SQL_C_SSHORT, &ti.get<10>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 12, SQL_C_SSHORT, &ti.get<11>(), sizeof(SQLSMALLINT), &ind); rc = SQLGetData(hstmt, 12, SQL_C_SSHORT, &ti.get<11>(), sizeof(SQLSMALLINT), &ind);
rc = SQLGetData(hstmt, 13, SQL_C_CHAR, localTypeName, sizeof(localTypeName), &ind); rc = SQLGetData(hstmt, 13, SQL_C_CHAR, localTypeName, sizeof(localTypeName), &ind);
@ -192,7 +192,7 @@ bool TypeInfo::tryGetInfo(SQLSMALLINT type, const std::string& param, DynamicAny
return true; return true;
} }
} }
return false; return false;
} }
@ -239,24 +239,24 @@ void TypeInfo::print(std::ostream& ostr)
for (; it != end; ++it) for (; it != end; ++it)
{ {
ostr << it->get<0>() << "\t" ostr << it->get<0>() << "\t"
<< it->get<1>() << "\t" << it->get<1>() << "\t"
<< it->get<2>() << "\t" << it->get<2>() << "\t"
<< it->get<3>() << "\t" << it->get<3>() << "\t"
<< it->get<4>() << "\t" << it->get<4>() << "\t"
<< it->get<5>() << "\t" << it->get<5>() << "\t"
<< it->get<6>() << "\t" << it->get<6>() << "\t"
<< it->get<7>() << "\t" << it->get<7>() << "\t"
<< it->get<8>() << "\t" << it->get<8>() << "\t"
<< it->get<9>() << "\t" << it->get<9>() << "\t"
<< it->get<10>() << "\t" << it->get<10>() << "\t"
<< it->get<11>() << "\t" << it->get<11>() << "\t"
<< it->get<12>() << "\t" << it->get<12>() << "\t"
<< it->get<13>() << "\t" << it->get<13>() << "\t"
<< it->get<14>() << "\t" << it->get<14>() << "\t"
<< it->get<15>() << "\t" << it->get<15>() << "\t"
<< it->get<16>() << "\t" << it->get<16>() << "\t"
<< it->get<17>() << "\t" << it->get<17>() << "\t"
<< it->get<18>() << std::endl; << it->get<18>() << std::endl;
} }
} }

View File

@ -38,7 +38,7 @@ namespace ODBC {
void makeUTF16(SQLCHAR* pSQLChar, SQLINTEGER length, std::string& target) void makeUTF16(SQLCHAR* pSQLChar, SQLINTEGER length, std::string& target)
{ {
int len = length; int len = length;
if (SQL_NTS == len) if (SQL_NTS == len)
len = (int) std::strlen((const char *) pSQLChar); len = (int) std::strlen((const char *) pSQLChar);
UTF8Encoding utf8Encoding; UTF8Encoding utf8Encoding;
@ -59,7 +59,7 @@ void makeUTF8(Poco::Buffer<SQLWCHAR>& buffer, SQLINTEGER length, SQLPOINTER pTar
std::string result; std::string result;
if (0 != converter.convert(buffer.begin(), length, result)) if (0 != converter.convert(buffer.begin(), length, result))
throw DataFormatException("Error converting UTF-16 to UTF-8"); throw DataFormatException("Error converting UTF-16 to UTF-8");
std::memset(pTarget, 0, targetLength); std::memset(pTarget, 0, targetLength);
std::strncpy((char*) pTarget, result.c_str(), result.size() < targetLength ? result.size() : targetLength); std::strncpy((char*) pTarget, result.c_str(), result.size() < targetLength ? result.size() : targetLength);
} }
@ -69,7 +69,7 @@ SQLRETURN SQLColAttribute(SQLHSTMT hstmt,
SQLUSMALLINT iCol, SQLUSMALLINT iCol,
SQLUSMALLINT iField, SQLUSMALLINT iField,
SQLPOINTER pCharAttr, SQLPOINTER pCharAttr,
SQLSMALLINT cbCharAttrMax, SQLSMALLINT cbCharAttrMax,
SQLSMALLINT* pcbCharAttr, SQLSMALLINT* pcbCharAttr,
NumAttrPtrType pNumAttr) NumAttrPtrType pNumAttr)
{ {
@ -93,7 +93,7 @@ SQLRETURN SQLColAttribute(SQLHSTMT hstmt,
iCol, iCol,
iField, iField,
pCharAttr, pCharAttr,
cbCharAttrMax, cbCharAttrMax,
pcbCharAttr, pcbCharAttr,
pNumAttr); pNumAttr);
} }
@ -133,8 +133,8 @@ SQLRETURN SQLConnect(SQLHDBC hdbc,
std::string sqlPWD; std::string sqlPWD;
makeUTF16(szAuthStr, cbAuthStr, sqlPWD); makeUTF16(szAuthStr, cbAuthStr, sqlPWD);
return SQLConnectW(hdbc, return SQLConnectW(hdbc,
(SQLWCHAR*) sqlDSN.c_str(), cbDSN, (SQLWCHAR*) sqlDSN.c_str(), cbDSN,
(SQLWCHAR*) sqlUID.c_str(), cbUID, (SQLWCHAR*) sqlUID.c_str(), cbUID,
(SQLWCHAR*) sqlPWD.c_str(), cbAuthStr); (SQLWCHAR*) sqlPWD.c_str(), cbAuthStr);
@ -211,7 +211,7 @@ SQLRETURN SQLGetConnectAttr(SQLHDBC hdbc,
makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax); makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax);
return rc; return rc;
} }
return SQLGetConnectAttrW(hdbc, return SQLGetConnectAttrW(hdbc,
fAttribute, fAttribute,
@ -231,9 +231,9 @@ SQLRETURN SQLGetCursorName(SQLHSTMT hstmt,
SQLRETURN SQLSetDescField(SQLHDESC hdesc, SQLRETURN SQLSetDescField(SQLHDESC hdesc,
SQLSMALLINT iRecord, SQLSMALLINT iRecord,
SQLSMALLINT iField, SQLSMALLINT iField,
SQLPOINTER rgbValue, SQLPOINTER rgbValue,
SQLINTEGER cbValueMax) SQLINTEGER cbValueMax)
{ {
if (isString(rgbValue, cbValueMax)) if (isString(rgbValue, cbValueMax))
@ -242,16 +242,16 @@ SQLRETURN SQLSetDescField(SQLHDESC hdesc,
makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str); makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str);
return SQLSetDescFieldW(hdesc, return SQLSetDescFieldW(hdesc,
iRecord, iRecord,
iField, iField,
(SQLPOINTER) str.c_str(), (SQLPOINTER) str.c_str(),
(SQLINTEGER) str.size() * sizeof(SQLWCHAR)); (SQLINTEGER) str.size() * sizeof(SQLWCHAR));
} }
return SQLSetDescFieldW(hdesc, return SQLSetDescFieldW(hdesc,
iRecord, iRecord,
iField, iField,
rgbValue, rgbValue,
cbValueMax); cbValueMax);
} }
@ -296,7 +296,7 @@ SQLRETURN SQLGetDescRec(SQLHDESC hdesc,
SQLSMALLINT* pfType, SQLSMALLINT* pfType,
SQLSMALLINT* pfSubType, SQLSMALLINT* pfSubType,
SQLLEN* pLength, SQLLEN* pLength,
SQLSMALLINT* pPrecision, SQLSMALLINT* pPrecision,
SQLSMALLINT* pScale, SQLSMALLINT* pScale,
SQLSMALLINT* pNullable) SQLSMALLINT* pNullable)
{ {
@ -391,7 +391,7 @@ SQLRETURN SQLSetConnectAttr(SQLHDBC hdbc,
return SQLSetConnectAttrW(hdbc, return SQLSetConnectAttrW(hdbc,
fAttribute, fAttribute,
(SQLWCHAR*) str.c_str(), (SQLWCHAR*) str.c_str(),
(SQLINTEGER) str.size() * sizeof(SQLWCHAR)); (SQLINTEGER) str.size() * sizeof(SQLWCHAR));
} }
@ -487,7 +487,7 @@ SQLRETURN SQLGetInfo(SQLHDBC hdbc,
pcbInfoValue); pcbInfoValue);
makeUTF8(buffer, *pcbInfoValue, rgbInfoValue, cbInfoValueMax); makeUTF8(buffer, *pcbInfoValue, rgbInfoValue, cbInfoValueMax);
return rc; return rc;
} }
@ -590,12 +590,12 @@ SQLRETURN SQLDriverConnect(SQLHDBC hdbc,
SQLUSMALLINT fDriverCompletion) SQLUSMALLINT fDriverCompletion)
{ {
SQLSMALLINT len = cbConnStrIn; SQLSMALLINT len = cbConnStrIn;
if (SQL_NTS == len) if (SQL_NTS == len)
len = (SQLSMALLINT) std::strlen((const char*) szConnStrIn) + 1; len = (SQLSMALLINT) std::strlen((const char*) szConnStrIn) + 1;
std::string connStrIn; std::string connStrIn;
makeUTF16(szConnStrIn, len, connStrIn); makeUTF16(szConnStrIn, len, connStrIn);
Buffer<SQLWCHAR> out(cbConnStrOutMax); Buffer<SQLWCHAR> out(cbConnStrOutMax);
SQLRETURN rc = SQLDriverConnectW(hdbc, SQLRETURN rc = SQLDriverConnectW(hdbc,
hwnd, hwnd,

View File

@ -97,7 +97,7 @@ SQLRETURN SQLConnect(SQLHDBC hdbc,
std::wstring sqlPWD; std::wstring sqlPWD;
makeUTF16(szAuthStr, cbAuthStr, sqlPWD); makeUTF16(szAuthStr, cbAuthStr, sqlPWD);
return SQLConnectW(hdbc, return SQLConnectW(hdbc,
(SQLWCHAR*) sqlDSN.c_str(), (SQLWCHAR*) sqlDSN.c_str(),
(SQLSMALLINT) sqlDSN.size(), (SQLSMALLINT) sqlDSN.size(),
@ -155,8 +155,8 @@ SQLRETURN SQLExecDirect(SQLHSTMT hstmt,
std::wstring sqlStr; std::wstring sqlStr;
makeUTF16(szSqlStr, cbSqlStr, sqlStr); makeUTF16(szSqlStr, cbSqlStr, sqlStr);
return SQLExecDirectW(hstmt, return SQLExecDirectW(hstmt,
(SQLWCHAR*) sqlStr.c_str(), (SQLWCHAR*) sqlStr.c_str(),
(SQLINTEGER) sqlStr.size()); (SQLINTEGER) sqlStr.size());
} }
@ -180,7 +180,7 @@ SQLRETURN SQLGetConnectAttr(SQLHDBC hdbc,
makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax); makeUTF8(buffer, *pcbValue, rgbValue, cbValueMax);
return rc; return rc;
} }
return SQLGetConnectAttrW(hdbc, return SQLGetConnectAttrW(hdbc,
fAttribute, fAttribute,
@ -200,9 +200,9 @@ SQLRETURN SQLGetCursorName(SQLHSTMT hstmt,
SQLRETURN SQLSetDescField(SQLHDESC hdesc, SQLRETURN SQLSetDescField(SQLHDESC hdesc,
SQLSMALLINT iRecord, SQLSMALLINT iRecord,
SQLSMALLINT iField, SQLSMALLINT iField,
SQLPOINTER rgbValue, SQLPOINTER rgbValue,
SQLINTEGER cbValueMax) SQLINTEGER cbValueMax)
{ {
if (isString(rgbValue, cbValueMax)) if (isString(rgbValue, cbValueMax))
@ -211,18 +211,18 @@ SQLRETURN SQLSetDescField(SQLHDESC hdesc,
makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str); makeUTF16((SQLCHAR*) rgbValue, cbValueMax, str);
SQLRETURN rc = SQLSetDescFieldW(hdesc, SQLRETURN rc = SQLSetDescFieldW(hdesc,
iRecord, iRecord,
iField, iField,
(SQLPOINTER) str.c_str(), (SQLPOINTER) str.c_str(),
(SQLINTEGER) str.size() * sizeof(std::wstring::value_type)); (SQLINTEGER) str.size() * sizeof(std::wstring::value_type));
return rc; return rc;
} }
return SQLSetDescFieldW(hdesc, return SQLSetDescFieldW(hdesc,
iRecord, iRecord,
iField, iField,
rgbValue, rgbValue,
cbValueMax); cbValueMax);
} }
@ -266,7 +266,7 @@ SQLRETURN SQLGetDescRec(SQLHDESC hdesc,
SQLSMALLINT* pfType, SQLSMALLINT* pfType,
SQLSMALLINT* pfSubType, SQLSMALLINT* pfSubType,
SQLLEN* pLength, SQLLEN* pLength,
SQLSMALLINT* pPrecision, SQLSMALLINT* pPrecision,
SQLSMALLINT* pScale, SQLSMALLINT* pScale,
SQLSMALLINT* pNullable) SQLSMALLINT* pNullable)
{ {
@ -344,8 +344,8 @@ SQLRETURN SQLPrepare(SQLHSTMT hstmt,
std::wstring sqlStr; std::wstring sqlStr;
makeUTF16(szSqlStr, cbSqlStr, sqlStr); makeUTF16(szSqlStr, cbSqlStr, sqlStr);
return SQLPrepareW(hstmt, return SQLPrepareW(hstmt,
(SQLWCHAR*) sqlStr.c_str(), (SQLWCHAR*) sqlStr.c_str(),
(SQLINTEGER) sqlStr.size()); (SQLINTEGER) sqlStr.size());
} }
@ -362,13 +362,13 @@ SQLRETURN SQLSetConnectAttr(SQLHDBC hdbc,
return SQLSetConnectAttrW(hdbc, return SQLSetConnectAttrW(hdbc,
fAttribute, fAttribute,
(SQLWCHAR*) str.c_str(), (SQLWCHAR*) str.c_str(),
(SQLINTEGER) str.size() * sizeof(std::wstring::value_type)); (SQLINTEGER) str.size() * sizeof(std::wstring::value_type));
} }
return SQLSetConnectAttrW(hdbc, return SQLSetConnectAttrW(hdbc,
fAttribute, fAttribute,
rgbValue, rgbValue,
cbValue); cbValue);
} }
@ -576,7 +576,7 @@ SQLRETURN SQLDriverConnect(SQLHDBC hdbc,
{ {
std::wstring connStrIn; std::wstring connStrIn;
int len = cbConnStrIn; int len = cbConnStrIn;
if (SQL_NTS == len) if (SQL_NTS == len)
len = (int) std::strlen((const char*) szConnStrIn); len = (int) std::strlen((const char*) szConnStrIn);
Poco::UnicodeConverter::toUTF16((const char *) szConnStrIn, len, connStrIn); Poco::UnicodeConverter::toUTF16((const char *) szConnStrIn, len, connStrIn);

View File

@ -41,7 +41,7 @@ Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
SQLSMALLINT len2 = length; SQLSMALLINT len2 = length;
RETCODE rc = 0; RETCODE rc = 0;
if (!Utility::isError(rc = SQLDrivers(henv, if (!Utility::isError(rc = SQLDrivers(henv,
SQL_FETCH_FIRST, SQL_FETCH_FIRST,
desc, desc,
length, length,
@ -52,12 +52,12 @@ Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
{ {
do do
{ {
driverMap.insert(DSNMap::value_type(std::string((char *) desc), driverMap.insert(DSNMap::value_type(std::string((char *) desc),
std::string((char *) attr))); std::string((char *) attr)));
std::memset(desc, 0, length); std::memset(desc, 0, length);
std::memset(attr, 0, length); std::memset(attr, 0, length);
len2 = length; len2 = length;
}while (!Utility::isError(rc = SQLDrivers(henv, }while (!Utility::isError(rc = SQLDrivers(henv,
SQL_FETCH_NEXT, SQL_FETCH_NEXT,
desc, desc,
length, length,
@ -67,7 +67,7 @@ Utility::DriverMap& Utility::drivers(Utility::DriverMap& driverMap)
&len2))); &len2)));
} }
if (SQL_NO_DATA != rc) if (SQL_NO_DATA != rc)
throw EnvironmentException(henv); throw EnvironmentException(henv);
return driverMap; return driverMap;
@ -88,7 +88,7 @@ Utility::DSNMap& Utility::dataSources(Utility::DSNMap& dsnMap)
SQLSMALLINT len2 = length; SQLSMALLINT len2 = length;
RETCODE rc = 0; RETCODE rc = 0;
while (!Utility::isError(rc = Poco::Data::ODBC::SQLDataSources(henv, while (!Utility::isError(rc = Poco::Data::ODBC::SQLDataSources(henv,
SQL_FETCH_NEXT, SQL_FETCH_NEXT,
dsn, dsn,
SQL_MAX_DSN_LENGTH, SQL_MAX_DSN_LENGTH,
@ -103,7 +103,7 @@ Utility::DSNMap& Utility::dataSources(Utility::DSNMap& dsnMap)
len2 = length; len2 = length;
} }
if (SQL_NO_DATA != rc) if (SQL_NO_DATA != rc)
throw EnvironmentException(henv); throw EnvironmentException(henv);
return dsnMap; return dsnMap;

View File

@ -40,7 +40,7 @@ std::string ODBCAccessTest::_dbConnString;
Poco::Data::ODBC::Utility::DriverMap ODBCAccessTest::_drivers; Poco::Data::ODBC::Utility::DriverMap ODBCAccessTest::_drivers;
ODBCAccessTest::ODBCAccessTest(const std::string& name): ODBCAccessTest::ODBCAccessTest(const std::string& name):
CppUnit::TestCase(name) CppUnit::TestCase(name)
{ {
} }
@ -123,13 +123,13 @@ bool ODBCAccessTest::canConnect(const std::string& driver, const std::string& ds
{ {
if (((itDrv->first).find(driver) != std::string::npos)) if (((itDrv->first).find(driver) != std::string::npos))
{ {
std::cout << "Driver found: " << itDrv->first std::cout << "Driver found: " << itDrv->first
<< " (" << itDrv->second << ')' << std::endl; << " (" << itDrv->second << ')' << std::endl;
break; break;
} }
} }
if (_drivers.end() == itDrv) if (_drivers.end() == itDrv)
{ {
std::cout << driver << " driver NOT found, tests not available." << std::endl; std::cout << driver << " driver NOT found, tests not available." << std::endl;
return false; return false;
@ -142,7 +142,7 @@ bool ODBCAccessTest::canConnect(const std::string& driver, const std::string& ds
{ {
if (itDSN->first == dsn && itDSN->second == driver) if (itDSN->first == dsn && itDSN->second == driver)
{ {
std::cout << "DSN found: " << itDSN->first std::cout << "DSN found: " << itDSN->first
<< " (" << itDSN->second << ')' << std::endl; << " (" << itDSN->second << ')' << std::endl;
format(_dbConnString, "DSN=%s", dsn); format(_dbConnString, "DSN=%s", dsn);
return true; return true;

View File

@ -25,7 +25,7 @@
class ODBCAccessTest: public CppUnit::TestCase class ODBCAccessTest: public CppUnit::TestCase
/// MS Access ODBC test class /// MS Access ODBC test class
/// Tested: /// Tested:
/// ///
/// Driver | DB | OS /// Driver | DB | OS
/// ------------+-----------+------------------------------------------ /// ------------+-----------+------------------------------------------
/// 4.00.6305.00| Jet 4.0 | MS Windows XP Professional x64 v.2003/SP1 /// 4.00.6305.00| Jet 4.0 | MS Windows XP Professional x64 v.2003/SP1

View File

@ -66,7 +66,7 @@ std::string ODBCDB2Test::_connectString = "Driver=" DB2_ODBC_DRIVER ";"
"Pwd=" DB2_PWD ";"; "Pwd=" DB2_PWD ";";
ODBCDB2Test::ODBCDB2Test(const std::string& name): ODBCDB2Test::ODBCDB2Test(const std::string& name):
ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString) ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString)
{ {
} }
@ -110,7 +110,7 @@ void ODBCDB2Test::testBareboneODBC()
void ODBCDB2Test::testBLOB() void ODBCDB2Test::testBLOB()
{ {
if (!_pSession) fail ("Test not available."); if (!_pSession) fail ("Test not available.");
const std::size_t maxFldSize = 1000000; const std::size_t maxFldSize = 1000000;
_pSession->setProperty("maxFieldSize", Poco::Any(maxFldSize-1)); _pSession->setProperty("maxFieldSize", Poco::Any(maxFldSize-1));
recreatePersonBLOBTable(); recreatePersonBLOBTable();
@ -120,7 +120,7 @@ void ODBCDB2Test::testBLOB()
_pExecutor->blob(maxFldSize); _pExecutor->blob(maxFldSize);
fail ("must fail"); fail ("must fail");
} }
catch (DataException&) catch (DataException&)
{ {
_pSession->setProperty("maxFieldSize", Poco::Any(maxFldSize)); _pSession->setProperty("maxFieldSize", Poco::Any(maxFldSize));
} }
@ -183,14 +183,14 @@ void ODBCDB2Test::testStoredProcedure()
"BEGIN " "BEGIN "
" SET outParam = inParam*inParam; " " SET outParam = inParam*inParam; "
"END" , now; "END" , now;
i = 2; i = 2;
int j = 0; int j = 0;
*_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now; *_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assertTrue (4 == j); assertTrue (4 == j);
dropObject("PROCEDURE", "storedProcedure"); dropObject("PROCEDURE", "storedProcedure");
*_pSession << "CREATE PROCEDURE storedProcedure(INOUT ioParam INTEGER) " *_pSession << "CREATE PROCEDURE storedProcedure(INOUT ioParam INTEGER) "
"BEGIN " "BEGIN "
" SET ioParam = ioParam*ioParam; " " SET ioParam = ioParam*ioParam; "
@ -209,7 +209,7 @@ void ODBCDB2Test::testStoredProcedure()
" SET outParam = inParam; " " SET outParam = inParam; "
"END" , now; "END" , now;
std::string inParam = std::string inParam =
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
@ -272,7 +272,7 @@ void ODBCDB2Test::testStoredProcedureDynamicAny()
for (int k = 0; k < 8;) for (int k = 0; k < 8;)
{ {
_pSession->setFeature("autoBind", bindValue(k)); _pSession->setFeature("autoBind", bindValue(k));
DynamicAny i = 2; DynamicAny i = 2;
DynamicAny j = 0; DynamicAny j = 0;
@ -319,12 +319,12 @@ void ODBCDB2Test::testStoredFunction()
*_pSession << "{? = call storedFunction()}", out(i), now; *_pSession << "{? = call storedFunction()}", out(i), now;
assertTrue (-1 == i); assertTrue (-1 == i);
dropObject("PROCEDURE", "storedFunction"); dropObject("PROCEDURE", "storedFunction");
*_pSession << "CREATE PROCEDURE storedFunction(inParam INTEGER) " *_pSession << "CREATE PROCEDURE storedFunction(inParam INTEGER) "
"BEGIN " "BEGIN "
" RETURN inParam*inParam; " " RETURN inParam*inParam; "
"END" , now; "END" , now;
i = 2; i = 2;
int result = 0; int result = 0;
*_pSession << "{? = call storedFunction(?)}", out(result), in(i), now; *_pSession << "{? = call storedFunction(?)}", out(result), in(i), now;
@ -342,7 +342,7 @@ void ODBCDB2Test::testStoredFunction()
result = 0; result = 0;
*_pSession << "{? = call storedFunction(?, ?)}", out(result), in(i), out(j), now; *_pSession << "{? = call storedFunction(?, ?)}", out(result), in(i), out(j), now;
assertTrue (4 == j); assertTrue (4 == j);
assertTrue (j == result); assertTrue (j == result);
dropObject("PROCEDURE", "storedFunction"); dropObject("PROCEDURE", "storedFunction");
*_pSession << "CREATE PROCEDURE storedFunction(INOUT param1 INTEGER, INOUT param2 INTEGER) " *_pSession << "CREATE PROCEDURE storedFunction(INOUT param1 INTEGER, INOUT param2 INTEGER) "
@ -360,7 +360,7 @@ void ODBCDB2Test::testStoredFunction()
*_pSession << "{? = call storedFunction(?, ?)}", out(result), io(i), io(j), now; *_pSession << "{? = call storedFunction(?, ?)}", out(result), io(i), io(j), now;
assertTrue (1 == j); assertTrue (1 == j);
assertTrue (2 == i); assertTrue (2 == i);
assertTrue (3 == result); assertTrue (3 == result);
Tuple<int, int> params(1, 2); Tuple<int, int> params(1, 2);
assertTrue (1 == params.get<0>()); assertTrue (1 == params.get<0>());
@ -369,7 +369,7 @@ void ODBCDB2Test::testStoredFunction()
*_pSession << "{? = call storedFunction(?, ?)}", out(result), io(params), now; *_pSession << "{? = call storedFunction(?, ?)}", out(result), io(params), now;
assertTrue (1 == params.get<1>()); assertTrue (1 == params.get<1>());
assertTrue (2 == params.get<0>()); assertTrue (2 == params.get<0>());
assertTrue (3 == result); assertTrue (3 == result);
dropObject("PROCEDURE", "storedFunction"); dropObject("PROCEDURE", "storedFunction");
@ -545,14 +545,14 @@ void ODBCDB2Test::recreateNullsTable(const std::string& notNull)
void ODBCDB2Test::recreateMiscTable() void ODBCDB2Test::recreateMiscTable()
{ {
dropObject("TABLE", "MiscTest"); dropObject("TABLE", "MiscTest");
try try
{ {
session() << "CREATE TABLE MiscTest " session() << "CREATE TABLE MiscTest "
"(First VARCHAR(30)," "(First VARCHAR(30),"
"Second BLOB," "Second BLOB,"
"Third INTEGER," "Third INTEGER,"
"Fourth FLOAT," "Fourth FLOAT,"
"Fifth TIMESTAMP)", now; "Fifth TIMESTAMP)", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); }
} }
@ -563,19 +563,19 @@ void ODBCDB2Test::recreateLogTable()
dropObject("TABLE", "T_POCO_LOG"); dropObject("TABLE", "T_POCO_LOG");
dropObject("TABLE", "T_POCO_LOG_ARCHIVE"); dropObject("TABLE", "T_POCO_LOG_ARCHIVE");
try try
{ {
std::string sql = "CREATE TABLE %s " std::string sql = "CREATE TABLE %s "
"(Source VARCHAR(100)," "(Source VARCHAR(100),"
"Name VARCHAR(100)," "Name VARCHAR(100),"
"ProcessId INTEGER," "ProcessId INTEGER,"
"Thread VARCHAR(100), " "Thread VARCHAR(100), "
"ThreadId INTEGER," "ThreadId INTEGER,"
"Priority INTEGER," "Priority INTEGER,"
"Text VARCHAR(100)," "Text VARCHAR(100),"
"DateTime TIMESTAMP)"; "DateTime TIMESTAMP)";
session() << sql, "T_POCO_LOG", now; session() << sql, "T_POCO_LOG", now;
session() << sql, "T_POCO_LOG_ARCHIVE", now; session() << sql, "T_POCO_LOG_ARCHIVE", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); }

View File

@ -21,7 +21,7 @@
class ODBCDB2Test: public ODBCTest class ODBCDB2Test: public ODBCTest
/// IBM DB2 UDB ODBC test class /// IBM DB2 UDB ODBC test class
/// Tested: /// Tested:
/// ///
/// Driver | DB | OS /// Driver | DB | OS
/// ------------+-------------------+------------------------------------------ /// ------------+-------------------+------------------------------------------
/// 9.01.00.356 | DB2 Express-C 9.1 | MS Windows XP Professional x64 v.2003/SP1 /// 9.01.00.356 | DB2 Express-C 9.1 | MS Windows XP Professional x64 v.2003/SP1

View File

@ -61,7 +61,7 @@ std::string ODBCMySQLTest::_connectString = "DRIVER={" MYSQL_ODBC_DRIVE
"PWD=" MYSQL_PWD ";"; "PWD=" MYSQL_PWD ";";
ODBCMySQLTest::ODBCMySQLTest(const std::string& name): ODBCMySQLTest::ODBCMySQLTest(const std::string& name):
ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString) ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString)
{ {
_pExecutor->execute("SET @@global.sql_mode= '';"); // disable strict mode _pExecutor->execute("SET @@global.sql_mode= '';"); // disable strict mode
@ -120,7 +120,7 @@ So, we skip this test.
void ODBCMySQLTest::testBLOB() void ODBCMySQLTest::testBLOB()
{ {
if (!_pSession) fail ("Test not available."); if (!_pSession) fail ("Test not available.");
const std::size_t maxFldSize = 65534; const std::size_t maxFldSize = 65534;
_pSession->setProperty("maxFieldSize", Poco::Any(maxFldSize-1)); _pSession->setProperty("maxFieldSize", Poco::Any(maxFldSize-1));
recreatePersonBLOBTable(); recreatePersonBLOBTable();
@ -130,7 +130,7 @@ void ODBCMySQLTest::testBLOB()
_pExecutor->blob(maxFldSize); _pExecutor->blob(maxFldSize);
fail ("must fail"); fail ("must fail");
} }
catch (DataException&) catch (DataException&)
{ {
_pSession->setProperty("maxFieldSize", Poco::Any(maxFldSize)); _pSession->setProperty("maxFieldSize", Poco::Any(maxFldSize));
} }
@ -182,10 +182,10 @@ void ODBCMySQLTest::testNull()
void ODBCMySQLTest::testStoredProcedure() void ODBCMySQLTest::testStoredProcedure()
{ {
//MySQL is currently buggy in this area: //MySQL is currently buggy in this area:
// http://bugs.mysql.com/bug.php?id=17898 // http://bugs.mysql.com/bug.php?id=17898
// http://bugs.mysql.com/bug.php?id=27632 // http://bugs.mysql.com/bug.php?id=27632
// Additionally, the standard ODBC stored procedure call syntax // Additionally, the standard ODBC stored procedure call syntax
// {call storedProcedure(?)} is currently (3.51.12.00) not supported. // {call storedProcedure(?)} is currently (3.51.12.00) not supported.
// See http://bugs.mysql.com/bug.php?id=26535 // See http://bugs.mysql.com/bug.php?id=26535
// Poco::Data support for MySQL ODBC is postponed until the above // Poco::Data support for MySQL ODBC is postponed until the above
@ -195,10 +195,10 @@ void ODBCMySQLTest::testStoredProcedure()
void ODBCMySQLTest::testStoredFunction() void ODBCMySQLTest::testStoredFunction()
{ {
//MySQL is currently buggy in this area: //MySQL is currently buggy in this area:
// http://bugs.mysql.com/bug.php?id=17898 // http://bugs.mysql.com/bug.php?id=17898
// http://bugs.mysql.com/bug.php?id=27632 // http://bugs.mysql.com/bug.php?id=27632
// Additionally, the standard ODBC stored procedure call syntax // Additionally, the standard ODBC stored procedure call syntax
// {call storedProcedure(?)} is currently (3.51.12.00) not supported. // {call storedProcedure(?)} is currently (3.51.12.00) not supported.
// See http://bugs.mysql.com/bug.php?id=26535 // See http://bugs.mysql.com/bug.php?id=26535
// Poco::Data support for MySQL ODBC is postponed until the above // Poco::Data support for MySQL ODBC is postponed until the above
@ -390,19 +390,19 @@ void ODBCMySQLTest::recreateLogTable()
dropObject("TABLE", "T_POCO_LOG"); dropObject("TABLE", "T_POCO_LOG");
dropObject("TABLE", "T_POCO_LOG_ARCHIVE"); dropObject("TABLE", "T_POCO_LOG_ARCHIVE");
try try
{ {
std::string sql = "CREATE TABLE %s " std::string sql = "CREATE TABLE %s "
"(Source VARCHAR(100)," "(Source VARCHAR(100),"
"Name VARCHAR(100)," "Name VARCHAR(100),"
"ProcessId INTEGER," "ProcessId INTEGER,"
"Thread VARCHAR(100), " "Thread VARCHAR(100), "
"ThreadId INTEGER," "ThreadId INTEGER,"
"Priority INTEGER," "Priority INTEGER,"
"Text VARCHAR(100)," "Text VARCHAR(100),"
"DateTime DATETIME)"; "DateTime DATETIME)";
session() << sql, "T_POCO_LOG", now; session() << sql, "T_POCO_LOG", now;
session() << sql, "T_POCO_LOG_ARCHIVE", now; session() << sql, "T_POCO_LOG_ARCHIVE", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); }

View File

@ -21,8 +21,8 @@
class ODBCMySQLTest: public ODBCTest class ODBCMySQLTest: public ODBCTest
/// MySQL ODBC test class /// MySQL ODBC test class
/// Tested: /// Tested:
/// ///
/// Driver | DB | OS | Driver Manager /// Driver | DB | OS | Driver Manager
/// ----------------+---------------------------+-------------------------------------------+--------------------- /// ----------------+---------------------------+-------------------------------------------+---------------------
/// 03.51.12.00 | MySQL 5.0.27-community-nt | MS Windows XP Professional x64 v.2003/SP1 | 3.526.3959.0 /// 03.51.12.00 | MySQL 5.0.27-community-nt | MS Windows XP Professional x64 v.2003/SP1 | 3.526.3959.0
/// 3.51.11.-6 | MySQL 5.0.27-community-nt | Ubuntu 7.04 (2.6.20-15-generic #2 SMP) | unixODBC 2.2.11.-13 /// 3.51.11.-6 | MySQL 5.0.27-community-nt | Ubuntu 7.04 (2.6.20-15-generic #2 SMP) | unixODBC 2.2.11.-13
@ -41,7 +41,7 @@ public:
void testStoredFunction(); void testStoredFunction();
void testNull(); void testNull();
void testMultipleResults(); void testMultipleResults();
void testFilter(); void testFilter();

View File

@ -81,7 +81,7 @@ std::string ODBCOracleTest::_connectString = "DRIVER={" ORACLE_ODBC_DRI
"APA=T;" // thread safety (T/F), default T "APA=T;" // thread safety (T/F), default T
"DBA=W;"; // write access (R/W) "DBA=W;"; // write access (R/W)
const std::string ODBCOracleTest::MULTI_INSERT = const std::string ODBCOracleTest::MULTI_INSERT =
"BEGIN " "BEGIN "
"INSERT INTO Test VALUES ('1', 2, 3.5);" "INSERT INTO Test VALUES ('1', 2, 3.5);"
"INSERT INTO Test VALUES ('2', 3, 4.5);" "INSERT INTO Test VALUES ('2', 3, 4.5);"
@ -94,7 +94,7 @@ const std::string ODBCOracleTest::MULTI_SELECT =
"{CALL multiResultsProcedure()}"; "{CALL multiResultsProcedure()}";
ODBCOracleTest::ODBCOracleTest(const std::string& name): ODBCOracleTest::ODBCOracleTest(const std::string& name):
ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString) ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString)
{ {
} }
@ -139,27 +139,27 @@ void ODBCOracleTest::testBarebone()
"OPEN ret5 FOR SELECT * FROM Test WHERE First = '5';" "OPEN ret5 FOR SELECT * FROM Test WHERE First = '5';"
"END multiResultsProcedure;" , now; "END multiResultsProcedure;" , now;
_pExecutor->bareboneODBCMultiResultTest(_connectString, _pExecutor->bareboneODBCMultiResultTest(_connectString,
tableCreateString, tableCreateString,
SQLExecutor::PB_IMMEDIATE, SQLExecutor::PB_IMMEDIATE,
SQLExecutor::DE_MANUAL, SQLExecutor::DE_MANUAL,
MULTI_INSERT, MULTI_INSERT,
MULTI_SELECT); MULTI_SELECT);
_pExecutor->bareboneODBCMultiResultTest(_connectString, _pExecutor->bareboneODBCMultiResultTest(_connectString,
tableCreateString, tableCreateString,
SQLExecutor::PB_IMMEDIATE, SQLExecutor::PB_IMMEDIATE,
SQLExecutor::DE_BOUND, SQLExecutor::DE_BOUND,
MULTI_INSERT, MULTI_INSERT,
MULTI_SELECT); MULTI_SELECT);
_pExecutor->bareboneODBCMultiResultTest(_connectString, _pExecutor->bareboneODBCMultiResultTest(_connectString,
tableCreateString, tableCreateString,
SQLExecutor::PB_AT_EXEC, SQLExecutor::PB_AT_EXEC,
SQLExecutor::DE_MANUAL, SQLExecutor::DE_MANUAL,
MULTI_INSERT, MULTI_INSERT,
MULTI_SELECT); MULTI_SELECT);
_pExecutor->bareboneODBCMultiResultTest(_connectString, _pExecutor->bareboneODBCMultiResultTest(_connectString,
tableCreateString, tableCreateString,
SQLExecutor::PB_AT_EXEC, SQLExecutor::PB_AT_EXEC,
SQLExecutor::DE_BOUND, SQLExecutor::DE_BOUND,
MULTI_INSERT, MULTI_INSERT,
MULTI_SELECT); MULTI_SELECT);
@ -178,7 +178,7 @@ void ODBCOracleTest::testBLOB()
executor().blob(maxFldSize); executor().blob(maxFldSize);
fail ("must fail"); fail ("must fail");
} }
catch (DataException&) catch (DataException&)
{ {
session().setProperty("maxFieldSize", Poco::Any(maxFldSize)); session().setProperty("maxFieldSize", Poco::Any(maxFldSize));
} }
@ -277,7 +277,7 @@ void ODBCOracleTest::testStoredProcedure()
k += 2; k += 2;
} }
//strings only work with auto-binding //strings only work with auto-binding
session().setFeature("autoBind", true); session().setFeature("autoBind", true);
@ -286,7 +286,7 @@ void ODBCOracleTest::testStoredProcedure()
" BEGIN outParam := inParam; " " BEGIN outParam := inParam; "
"END storedProcedure;" , now; "END storedProcedure;" , now;
std::string inParam = std::string inParam =
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
@ -342,7 +342,7 @@ void ODBCOracleTest::testStoredProcedureDynamicAny()
for (int k = 0; k < 8;) for (int k = 0; k < 8;)
{ {
session().setFeature("autoBind", bindValue(k)); session().setFeature("autoBind", bindValue(k));
DynamicAny i = 2; DynamicAny i = 2;
DynamicAny j = 0; DynamicAny j = 0;
@ -391,15 +391,15 @@ void ODBCOracleTest::testCursorStoredProcedure()
" OPEN ret FOR " " OPEN ret FOR "
" SELECT * " " SELECT * "
" FROM Person " " FROM Person "
" WHERE Age < ageLimit " " WHERE Age < ageLimit "
" ORDER BY Age DESC; " " ORDER BY Age DESC; "
" END storedCursorProcedure;" , now; " END storedCursorProcedure;" , now;
people.clear(); people.clear();
int age = 13; int age = 13;
*_pSession << "{call storedCursorProcedure(?)}", in(age), into(people), now; *_pSession << "{call storedCursorProcedure(?)}", in(age), into(people), now;
assertTrue (2 == people.size()); assertTrue (2 == people.size());
assertTrue (Person("Simpson", "Bart", "Springfield", 12) == people[0]); assertTrue (Person("Simpson", "Bart", "Springfield", 12) == people[0]);
assertTrue (Person("Simpson", "Lisa", "Springfield", 10) == people[1]); assertTrue (Person("Simpson", "Lisa", "Springfield", 10) == people[1]);
@ -460,7 +460,7 @@ void ODBCOracleTest::testStoredFunction()
result = 0; result = 0;
*_pSession << "{? = call storedFunction(?, ?)}", out(result), in(i), out(j), now; *_pSession << "{? = call storedFunction(?, ?)}", out(result), in(i), out(j), now;
assertTrue (4 == j); assertTrue (4 == j);
assertTrue (j == result); assertTrue (j == result);
dropObject("FUNCTION", "storedFunction"); dropObject("FUNCTION", "storedFunction");
*_pSession << "CREATE OR REPLACE " *_pSession << "CREATE OR REPLACE "
@ -475,8 +475,8 @@ void ODBCOracleTest::testStoredFunction()
*_pSession << "{? = call storedFunction(?, ?)}", out(result), io(i), io(j), now; *_pSession << "{? = call storedFunction(?, ?)}", out(result), io(i), io(j), now;
assertTrue (1 == j); assertTrue (1 == j);
assertTrue (2 == i); assertTrue (2 == i);
assertTrue (3 == result); assertTrue (3 == result);
Tuple<int, int> params(1, 2); Tuple<int, int> params(1, 2);
assertTrue (1 == params.get<0>()); assertTrue (1 == params.get<0>());
assertTrue (2 == params.get<1>()); assertTrue (2 == params.get<1>());
@ -484,9 +484,9 @@ void ODBCOracleTest::testStoredFunction()
*_pSession << "{? = call storedFunction(?, ?)}", out(result), io(params), now; *_pSession << "{? = call storedFunction(?, ?)}", out(result), io(params), now;
assertTrue (1 == params.get<1>()); assertTrue (1 == params.get<1>());
assertTrue (2 == params.get<0>()); assertTrue (2 == params.get<0>());
assertTrue (3 == result); assertTrue (3 == result);
dropObject("FUNCTION", "storedFunction"); dropObject("FUNCTION", "storedFunction");
k += 2; k += 2;
} }
@ -530,16 +530,16 @@ void ODBCOracleTest::testCursorStoredFunction()
" OPEN ret FOR " " OPEN ret FOR "
" SELECT * " " SELECT * "
" FROM Person " " FROM Person "
" WHERE Age < ageLimit " " WHERE Age < ageLimit "
" ORDER BY Age DESC; " " ORDER BY Age DESC; "
" RETURN ret; " " RETURN ret; "
" END storedCursorFunction;" , now; " END storedCursorFunction;" , now;
people.clear(); people.clear();
int age = 13; int age = 13;
*_pSession << "{call storedCursorFunction(?)}", in(age), into(people), now; *_pSession << "{call storedCursorFunction(?)}", in(age), into(people), now;
assertTrue (2 == people.size()); assertTrue (2 == people.size());
assertTrue (Person("Simpson", "Bart", "Springfield", 12) == people[0]); assertTrue (Person("Simpson", "Bart", "Springfield", 12) == people[0]);
assertTrue (Person("Simpson", "Lisa", "Springfield", 10) == people[1]); assertTrue (Person("Simpson", "Lisa", "Springfield", 10) == people[1]);
@ -553,7 +553,7 @@ void ODBCOracleTest::testCursorStoredFunction()
dropObject("TABLE", "Person"); dropObject("TABLE", "Person");
dropObject("FUNCTION", "storedCursorFunction"); dropObject("FUNCTION", "storedCursorFunction");
k += 2; k += 2;
} }
} }
@ -611,7 +611,7 @@ void ODBCOracleTest::testAutoTransaction()
assertTrue (0 == count); assertTrue (0 == count);
session().setFeature("autoCommit", false); session().setFeature("autoCommit", false);
try try
{ {
AutoTransaction at(session()); AutoTransaction at(session());
@ -794,14 +794,14 @@ void ODBCOracleTest::recreateNullsTable(const std::string& notNull)
void ODBCOracleTest::recreateMiscTable() void ODBCOracleTest::recreateMiscTable()
{ {
dropObject("TABLE", "MiscTest"); dropObject("TABLE", "MiscTest");
try try
{ {
session() << "CREATE TABLE MiscTest " session() << "CREATE TABLE MiscTest "
"(First VARCHAR(30)," "(First VARCHAR(30),"
"Second BLOB," "Second BLOB,"
"Third INTEGER," "Third INTEGER,"
"Fourth NUMBER," "Fourth NUMBER,"
"Fifth TIMESTAMP)", now; "Fifth TIMESTAMP)", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); }
} }
@ -812,20 +812,20 @@ void ODBCOracleTest::recreateLogTable()
dropObject("TABLE", "T_POCO_LOG"); dropObject("TABLE", "T_POCO_LOG");
dropObject("TABLE", "T_POCO_LOG_ARCHIVE"); dropObject("TABLE", "T_POCO_LOG_ARCHIVE");
try try
{ {
std::string sql = "CREATE TABLE %s " std::string sql = "CREATE TABLE %s "
"(Source VARCHAR(100)," "(Source VARCHAR(100),"
"Name VARCHAR(100)," "Name VARCHAR(100),"
"ProcessId INTEGER," "ProcessId INTEGER,"
"Thread VARCHAR(100), " "Thread VARCHAR(100), "
"ThreadId INTEGER," "ThreadId INTEGER,"
"Priority INTEGER," "Priority INTEGER,"
"Text VARCHAR(100)," "Text VARCHAR(100),"
"DateTime TIMESTAMP)"; "DateTime TIMESTAMP)";
session() << sql, "T_POCO_LOG", now; session() << sql, "T_POCO_LOG", now;
session() << sql, "T_POCO_LOG_ARCHIVE", now; session() << sql, "T_POCO_LOG_ARCHIVE", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateLogTable()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateLogTable()"); }

View File

@ -21,7 +21,7 @@
class ODBCOracleTest: public ODBCTest class ODBCOracleTest: public ODBCTest
/// Oracle ODBC test class /// Oracle ODBC test class
/// Tested: /// Tested:
/// ///
/// Driver | DB | OS /// Driver | DB | OS
/// ------------+-------------------------------+------------------------------------------ /// ------------+-------------------------------+------------------------------------------
/// 10.02.00.01 | Oracle9i Release 9.2.0.4.0 | MS Windows XP Professional x64 v.2003/SP1 /// 10.02.00.01 | Oracle9i Release 9.2.0.4.0 | MS Windows XP Professional x64 v.2003/SP1
@ -51,7 +51,7 @@ public:
private: private:
static void testBarebone(); static void testBarebone();
void dropObject(const std::string& type, const std::string& name); void dropObject(const std::string& type, const std::string& name);
void recreateNullableTable(); void recreateNullableTable();
void recreatePersonTable(); void recreatePersonTable();
@ -72,7 +72,7 @@ private:
static ODBCTest::SessionPtr _pSession; static ODBCTest::SessionPtr _pSession;
static ODBCTest::ExecPtr _pExecutor; static ODBCTest::ExecPtr _pExecutor;
static std::string _driver; static std::string _driver;
static std::string _dsn; static std::string _dsn;
static std::string _uid; static std::string _uid;

View File

@ -75,7 +75,7 @@ std::string ODBCPostgreSQLTest::_driver = POSTGRESQL_ODBC_DRIVER;
std::string ODBCPostgreSQLTest::_dsn = POSTGRESQL_DSN; std::string ODBCPostgreSQLTest::_dsn = POSTGRESQL_DSN;
std::string ODBCPostgreSQLTest::_uid = POSTGRESQL_UID; std::string ODBCPostgreSQLTest::_uid = POSTGRESQL_UID;
std::string ODBCPostgreSQLTest::_pwd = POSTGRESQL_PWD; std::string ODBCPostgreSQLTest::_pwd = POSTGRESQL_PWD;
std::string ODBCPostgreSQLTest::_connectString = std::string ODBCPostgreSQLTest::_connectString =
"DRIVER=" POSTGRESQL_ODBC_DRIVER ";" "DRIVER=" POSTGRESQL_ODBC_DRIVER ";"
"DATABASE=" POSTGRESQL_DB ";" "DATABASE=" POSTGRESQL_DB ";"
"SERVER=" POSTGRESQL_SERVER ";" "SERVER=" POSTGRESQL_SERVER ";"
@ -114,7 +114,7 @@ std::string ODBCPostgreSQLTest::_connectString =
"ReadOnly=0;"; "ReadOnly=0;";
ODBCPostgreSQLTest::ODBCPostgreSQLTest(const std::string& name): ODBCPostgreSQLTest::ODBCPostgreSQLTest(const std::string& name):
ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString) ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString)
{ {
} }
@ -179,7 +179,7 @@ void ODBCPostgreSQLTest::testBLOB()
executor().blob(maxFldSize); executor().blob(maxFldSize);
fail ("must fail"); fail ("must fail");
} }
catch (DataException&) catch (DataException&)
{ {
session().setProperty("maxFieldSize", Poco::Any(maxFldSize)); session().setProperty("maxFieldSize", Poco::Any(maxFldSize));
} }
@ -207,7 +207,7 @@ void ODBCPostgreSQLTest::testStoredFunction()
session().setFeature("autoExtract", bindValue(k+1)); session().setFeature("autoExtract", bindValue(k+1));
dropObject("FUNCTION", "storedFunction()"); dropObject("FUNCTION", "storedFunction()");
try try
{ {
session() << "CREATE FUNCTION storedFunction() RETURNS INTEGER AS '" session() << "CREATE FUNCTION storedFunction() RETURNS INTEGER AS '"
"BEGIN " "BEGIN "
@ -223,7 +223,7 @@ void ODBCPostgreSQLTest::testStoredFunction()
assertTrue (-1 == i); assertTrue (-1 == i);
dropObject("FUNCTION", "storedFunction()"); dropObject("FUNCTION", "storedFunction()");
try try
{ {
session() << "CREATE FUNCTION storedFunction(INTEGER) RETURNS INTEGER AS '" session() << "CREATE FUNCTION storedFunction(INTEGER) RETURNS INTEGER AS '"
"BEGIN " "BEGIN "
@ -241,7 +241,7 @@ void ODBCPostgreSQLTest::testStoredFunction()
dropObject("FUNCTION", "storedFunction(INTEGER)"); dropObject("FUNCTION", "storedFunction(INTEGER)");
dropObject("FUNCTION", "storedFunction(TIMESTAMP)"); dropObject("FUNCTION", "storedFunction(TIMESTAMP)");
try try
{ {
session() << "CREATE FUNCTION storedFunction(TIMESTAMP) RETURNS TIMESTAMP AS '" session() << "CREATE FUNCTION storedFunction(TIMESTAMP) RETURNS TIMESTAMP AS '"
"BEGIN " "BEGIN "
@ -259,23 +259,23 @@ void ODBCPostgreSQLTest::testStoredFunction()
dropObject("FUNCTION", "storedFunction(TIMESTAMP)"); dropObject("FUNCTION", "storedFunction(TIMESTAMP)");
dropObject("FUNCTION", "storedFunction(TEXT, TEXT)"); dropObject("FUNCTION", "storedFunction(TEXT, TEXT)");
try try
{ {
session() << "CREATE FUNCTION storedFunction(TEXT,TEXT) RETURNS TEXT AS '" session() << "CREATE FUNCTION storedFunction(TEXT,TEXT) RETURNS TEXT AS '"
"BEGIN " "BEGIN "
" RETURN $1 || '', '' || $2 || ''!'';" " RETURN $1 || '', '' || $2 || ''!'';"
"END;'" "END;'"
"LANGUAGE 'plpgsql'" , now; "LANGUAGE 'plpgsql'" , now;
} }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (func); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (func); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (func); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (func); }
std::string param1 = "Hello"; std::string param1 = "Hello";
std::string param2 = "world"; std::string param2 = "world";
std::string ret; std::string ret;
try try
{ {
session() << "{? = call storedFunction(?,?)}", out(ret), in(param1), in(param2), now; session() << "{? = call storedFunction(?,?)}", out(ret), in(param1), in(param2), now;
} }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (func); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (func); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (func); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (func); }
@ -346,13 +346,13 @@ void ODBCPostgreSQLTest::configurePLPgSQL()
"RETURNS OPAQUE " "RETURNS OPAQUE "
"AS '%splpgsql.dll' " "AS '%splpgsql.dll' "
"LANGUAGE 'C';", _libDir), now; "LANGUAGE 'C';", _libDir), now;
session() << "CREATE LANGUAGE 'plpgsql' " session() << "CREATE LANGUAGE 'plpgsql' "
"HANDLER plpgsql_call_handler " "HANDLER plpgsql_call_handler "
"LANCOMPILER 'PL/pgSQL'", now; "LANCOMPILER 'PL/pgSQL'", now;
}catch(StatementException& ex) }catch(StatementException& ex)
{ {
if (1 != ex.diagnostics().nativeError(0)) if (1 != ex.diagnostics().nativeError(0))
throw; throw;
} }
@ -522,15 +522,15 @@ void ODBCPostgreSQLTest::recreateBoolTable()
void ODBCPostgreSQLTest::recreateMiscTable() void ODBCPostgreSQLTest::recreateMiscTable()
{ {
dropObject("TABLE", "MiscTest"); dropObject("TABLE", "MiscTest");
try try
{ {
// Mammoth does not bind columns properly // Mammoth does not bind columns properly
session() << "CREATE TABLE MiscTest " session() << "CREATE TABLE MiscTest "
"(First VARCHAR(30)," "(First VARCHAR(30),"
"Second BYTEA," "Second BYTEA,"
"Third INTEGER," "Third INTEGER,"
"Fourth FLOAT," "Fourth FLOAT,"
"Fifth TIMESTAMP)", now; "Fifth TIMESTAMP)", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); }
} }
@ -541,20 +541,20 @@ void ODBCPostgreSQLTest::recreateLogTable()
dropObject("TABLE", "T_POCO_LOG"); dropObject("TABLE", "T_POCO_LOG");
dropObject("TABLE", "T_POCO_LOG_ARCHIVE"); dropObject("TABLE", "T_POCO_LOG_ARCHIVE");
try try
{ {
std::string sql = "CREATE TABLE %s " std::string sql = "CREATE TABLE %s "
"(Source VARCHAR," "(Source VARCHAR,"
"Name VARCHAR," "Name VARCHAR,"
"ProcessId INTEGER," "ProcessId INTEGER,"
"Thread VARCHAR, " "Thread VARCHAR, "
"ThreadId INTEGER," "ThreadId INTEGER,"
"Priority INTEGER," "Priority INTEGER,"
"Text VARCHAR," "Text VARCHAR,"
"DateTime TIMESTAMP)"; "DateTime TIMESTAMP)";
session() << sql, "T_POCO_LOG", now; session() << sql, "T_POCO_LOG", now;
session() << sql, "T_POCO_LOG_ARCHIVE", now; session() << sql, "T_POCO_LOG_ARCHIVE", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateLogTable()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateLogTable()"); }

View File

@ -25,15 +25,15 @@
class ODBCPostgreSQLTest: public ODBCTest class ODBCPostgreSQLTest: public ODBCTest
/// PostgreSQL ODBC test class /// PostgreSQL ODBC test class
/// Tested: /// Tested:
/// ///
/// Driver | DB | OS | Driver Manager |Notes /// Driver | DB | OS | Driver Manager |Notes
/// ---------------+----------------------+-------------------------------------------+--------------------+-------------------------- /// ---------------+----------------------+-------------------------------------------+--------------------+--------------------------
/// 07.03.02.60 | PostgreSQL 7.4.6 | MS Windows XP Professional x64 v.2003/SP1 | 3.526.3959.0 | BLOB fails (missing 'lo') /// 07.03.02.60 | PostgreSQL 7.4.6 | MS Windows XP Professional x64 v.2003/SP1 | 3.526.3959.0 | BLOB fails (missing 'lo')
/// 08.01.02.00 | PostgreSQL 8.1.5-1 | MS Windows XP Professional x64 v.2003/SP1 | 3.526.3959.0 | /// 08.01.02.00 | PostgreSQL 8.1.5-1 | MS Windows XP Professional x64 v.2003/SP1 | 3.526.3959.0 |
/// 1:08.01.0200-2 | PostgreSQL 8.1.5-1 | Ubuntu 7.04 (2.6.20-15-generic #2 SMP) | unixODBC 2.2.11.-13| /// 1:08.01.0200-2 | PostgreSQL 8.1.5-1 | Ubuntu 7.04 (2.6.20-15-generic #2 SMP) | unixODBC 2.2.11.-13|
/// Mammoth ODBCng | | | | /// Mammoth ODBCng | | | |
/// (0.99.00.122) | PostgreSQL 8.1.5-1 | MS Windows XP Professional x64 v.2003/SP1 | 3.526.3959.0 | /// (0.99.00.122) | PostgreSQL 8.1.5-1 | MS Windows XP Professional x64 v.2003/SP1 | 3.526.3959.0 |
/// ///
{ {
public: public:
ODBCPostgreSQLTest(const std::string& name); ODBCPostgreSQLTest(const std::string& name);
@ -71,8 +71,8 @@ private:
void configurePLPgSQL(); void configurePLPgSQL();
/// Configures PL/pgSQL in the database. A reasonable defaults /// Configures PL/pgSQL in the database. A reasonable defaults
/// for the interpreter location on WIN32 and POSIX platforms are /// for the interpreter location on WIN32 and POSIX platforms are
/// supplied (see installDir member variable). /// supplied (see installDir member variable).
/// If these do not work, user must determine the proper location, /// If these do not work, user must determine the proper location,
/// modify the function and recompile. /// modify the function and recompile.
/// Alternative is direct database configuration for PL/pgSQL usage. /// Alternative is direct database configuration for PL/pgSQL usage.

View File

@ -107,7 +107,7 @@ std::string ODBCSQLServerTest::_connectString = "DRIVER=" MS_SQL_SERVER_ODBC_DRI
; ;
ODBCSQLServerTest::ODBCSQLServerTest(const std::string& name): ODBCSQLServerTest::ODBCSQLServerTest(const std::string& name):
ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString) ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString)
{ {
} }
@ -128,13 +128,13 @@ void ODBCSQLServerTest::testBareboneODBC()
"Fifth FLOAT," "Fifth FLOAT,"
"Sixth DATETIME)"; "Sixth DATETIME)";
executor().bareboneODBCTest(dbConnString(), tableCreateString, executor().bareboneODBCTest(dbConnString(), tableCreateString,
SQLExecutor::PB_IMMEDIATE, SQLExecutor::DE_MANUAL, true, "CONVERT(VARBINARY(30),?)"); SQLExecutor::PB_IMMEDIATE, SQLExecutor::DE_MANUAL, true, "CONVERT(VARBINARY(30),?)");
executor().bareboneODBCTest(dbConnString(), tableCreateString, executor().bareboneODBCTest(dbConnString(), tableCreateString,
SQLExecutor::PB_IMMEDIATE, SQLExecutor::DE_BOUND, true, "CONVERT(VARBINARY(30),?)"); SQLExecutor::PB_IMMEDIATE, SQLExecutor::DE_BOUND, true, "CONVERT(VARBINARY(30),?)");
executor().bareboneODBCTest(dbConnString(), tableCreateString, executor().bareboneODBCTest(dbConnString(), tableCreateString,
SQLExecutor::PB_AT_EXEC, SQLExecutor::DE_MANUAL, true, "CONVERT(VARBINARY(30),?)"); SQLExecutor::PB_AT_EXEC, SQLExecutor::DE_MANUAL, true, "CONVERT(VARBINARY(30),?)");
executor().bareboneODBCTest(dbConnString(), tableCreateString, executor().bareboneODBCTest(dbConnString(), tableCreateString,
SQLExecutor::PB_AT_EXEC, SQLExecutor::DE_BOUND, true, "CONVERT(VARBINARY(30),?)"); SQLExecutor::PB_AT_EXEC, SQLExecutor::DE_BOUND, true, "CONVERT(VARBINARY(30),?)");
tableCreateString = "CREATE TABLE Test " tableCreateString = "CREATE TABLE Test "
@ -255,7 +255,7 @@ void ODBCSQLServerTest::testStoredProcedure()
"SET @outParam = -1; " "SET @outParam = -1; "
"END;" "END;"
, now; , now;
int i = 0; int i = 0;
session() << "{call storedProcedure(?)}", out(i), now; session() << "{call storedProcedure(?)}", out(i), now;
assertTrue (-1 == i); assertTrue (-1 == i);
@ -298,8 +298,8 @@ void ODBCSQLServerTest::testStoredProcedure()
} }
/*TODO - currently fails with following error: /*TODO - currently fails with following error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid parameter [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid parameter
2 (''): Data type 0x23 is a deprecated large object, or LOB, but is marked as output parameter. 2 (''): Data type 0x23 is a deprecated large object, or LOB, but is marked as output parameter.
Deprecated types are not supported as output parameters. Use current large object types instead. Deprecated types are not supported as output parameters. Use current large object types instead.
session().setFeature("autoBind", true); session().setFeature("autoBind", true);
@ -340,16 +340,16 @@ void ODBCSQLServerTest::testCursorStoredProcedure()
"BEGIN " "BEGIN "
" SELECT * " " SELECT * "
" FROM Person " " FROM Person "
" WHERE Age < @ageLimit " " WHERE Age < @ageLimit "
" ORDER BY Age DESC; " " ORDER BY Age DESC; "
"END;" "END;"
, now; , now;
people.clear(); people.clear();
int age = 13; int age = 13;
session() << "{call storedCursorProcedure(?)}", in(age), into(people), now; session() << "{call storedCursorProcedure(?)}", in(age), into(people), now;
assertTrue (2 == people.size()); assertTrue (2 == people.size());
assertTrue (Person("Simpson", "Bart", "Springfield", 12) == people[0]); assertTrue (Person("Simpson", "Bart", "Springfield", 12) == people[0]);
assertTrue (Person("Simpson", "Lisa", "Springfield", 10) == people[1]); assertTrue (Person("Simpson", "Lisa", "Springfield", 10) == people[1]);
@ -410,7 +410,7 @@ void ODBCSQLServerTest::testStoredProcedureDynamicAny()
for (int k = 0; k < 8;) for (int k = 0; k < 8;)
{ {
session().setFeature("autoBind", bindValue(k)); session().setFeature("autoBind", bindValue(k));
DynamicAny i = 2; DynamicAny i = 2;
DynamicAny j = 0; DynamicAny j = 0;
@ -507,7 +507,7 @@ void ODBCSQLServerTest::testStoredFunction()
session() << "{? = call storedFunction(?, ?)}", out(result), io(i), io(j), now; session() << "{? = call storedFunction(?, ?)}", out(result), io(i), io(j), now;
assertTrue (1 == j); assertTrue (1 == j);
assertTrue (2 == i); assertTrue (2 == i);
assertTrue (3 == result); assertTrue (3 == result);
Tuple<int, int> params(1, 2); Tuple<int, int> params(1, 2);
assertTrue (1 == params.get<0>()); assertTrue (1 == params.get<0>());
@ -516,7 +516,7 @@ void ODBCSQLServerTest::testStoredFunction()
session() << "{? = call storedFunction(?, ?)}", out(result), io(params), now; session() << "{? = call storedFunction(?, ?)}", out(result), io(params), now;
assertTrue (1 == params.get<1>()); assertTrue (1 == params.get<1>());
assertTrue (2 == params.get<0>()); assertTrue (2 == params.get<0>());
assertTrue (3 == result); assertTrue (3 == result);
dropObject("PROCEDURE", "storedFunction"); dropObject("PROCEDURE", "storedFunction");
@ -684,15 +684,15 @@ void ODBCSQLServerTest::recreateBoolTable()
void ODBCSQLServerTest::recreateMiscTable() void ODBCSQLServerTest::recreateMiscTable()
{ {
dropObject("TABLE", "MiscTest"); dropObject("TABLE", "MiscTest");
try try
{ {
session() << "CREATE TABLE MiscTest " session() << "CREATE TABLE MiscTest "
"(First VARCHAR(30)," "(First VARCHAR(30),"
"Second VARBINARY(30)," "Second VARBINARY(30),"
"Third INTEGER," "Third INTEGER,"
"Fourth FLOAT," "Fourth FLOAT,"
"Fifth DATETIME," "Fifth DATETIME,"
"Sixth BIT)", now; "Sixth BIT)", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); }
} }
@ -703,20 +703,20 @@ void ODBCSQLServerTest::recreateLogTable()
dropObject("TABLE", "T_POCO_LOG"); dropObject("TABLE", "T_POCO_LOG");
dropObject("TABLE", "T_POCO_LOG_ARCHIVE"); dropObject("TABLE", "T_POCO_LOG_ARCHIVE");
try try
{ {
std::string sql = "CREATE TABLE %s " std::string sql = "CREATE TABLE %s "
"(Source VARCHAR(max)," "(Source VARCHAR(max),"
"Name VARCHAR(max)," "Name VARCHAR(max),"
"ProcessId INTEGER," "ProcessId INTEGER,"
"Thread VARCHAR(max), " "Thread VARCHAR(max), "
"ThreadId INTEGER," "ThreadId INTEGER,"
"Priority INTEGER," "Priority INTEGER,"
"Text VARCHAR(max)," "Text VARCHAR(max),"
"DateTime DATETIME)"; "DateTime DATETIME)";
session() << sql, "T_POCO_LOG", now; session() << sql, "T_POCO_LOG", now;
session() << sql, "T_POCO_LOG_ARCHIVE", now; session() << sql, "T_POCO_LOG_ARCHIVE", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateLogTable()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateLogTable()"); }

View File

@ -25,7 +25,7 @@
class ODBCSQLServerTest: public ODBCTest class ODBCSQLServerTest: public ODBCTest
/// SQLServer ODBC test class /// SQLServer ODBC test class
/// Tested: /// Tested:
/// ///
/// Driver | DB | OS /// Driver | DB | OS
/// --------------------+-----------------------------------+------------------------------------------ /// --------------------+-----------------------------------+------------------------------------------
/// 2000.86.1830.00 | SQL Server Express 9.0.2047 | MS Windows XP Professional x64 v.2003/SP1 /// 2000.86.1830.00 | SQL Server Express 9.0.2047 | MS Windows XP Professional x64 v.2003/SP1
@ -48,7 +48,7 @@ public:
void testCursorStoredProcedure(); void testCursorStoredProcedure();
void testStoredProcedureAny(); void testStoredProcedureAny();
void testStoredProcedureDynamicAny(); void testStoredProcedureDynamicAny();
void testStoredFunction(); void testStoredFunction();
static CppUnit::Test* suite(); static CppUnit::Test* suite();

View File

@ -45,11 +45,11 @@ std::string ODBCSQLiteTest::_driver = SQLITE_ODBC_DRIVER;
std::string ODBCSQLiteTest::_dsn = SQLITE_DSN; std::string ODBCSQLiteTest::_dsn = SQLITE_DSN;
std::string ODBCSQLiteTest::_uid = ""; std::string ODBCSQLiteTest::_uid = "";
std::string ODBCSQLiteTest::_pwd = ""; std::string ODBCSQLiteTest::_pwd = "";
std::string ODBCSQLiteTest::_connectString = "Driver=" SQLITE_ODBC_DRIVER std::string ODBCSQLiteTest::_connectString = "Driver=" SQLITE_ODBC_DRIVER
";Database=" SQLITE_DB ";"; ";Database=" SQLITE_DB ";";
ODBCSQLiteTest::ODBCSQLiteTest(const std::string& name): ODBCSQLiteTest::ODBCSQLiteTest(const std::string& name):
ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString) ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString)
{ {
} }
@ -116,7 +116,7 @@ void ODBCSQLiteTest::testAffectedRows()
// why "WHERE 1" is necessary here // why "WHERE 1" is necessary here
_pExecutor->affectedRows("WHERE 1"); _pExecutor->affectedRows("WHERE 1");
i += 2; i += 2;
} }
} }
@ -156,7 +156,7 @@ void ODBCSQLiteTest::dropObject(const std::string& type, const std::string& name
} }
} }
if (!ignoreError) if (!ignoreError)
{ {
std::cout << ex.toString() << std::endl; std::cout << ex.toString() << std::endl;
throw; throw;
@ -273,15 +273,15 @@ void ODBCSQLiteTest::recreateNullsTable(const std::string& notNull)
void ODBCSQLiteTest::recreateMiscTable() void ODBCSQLiteTest::recreateMiscTable()
{ {
dropObject("TABLE", "MiscTest"); dropObject("TABLE", "MiscTest");
try try
{ {
// SQLite fails with BLOB bulk operations // SQLite fails with BLOB bulk operations
session() << "CREATE TABLE MiscTest " session() << "CREATE TABLE MiscTest "
"(First VARCHAR(30)," "(First VARCHAR(30),"
//"Second BLOB," //"Second BLOB,"
"Third INTEGER," "Third INTEGER,"
"Fourth REAL," "Fourth REAL,"
"Fifth DATETIME)", now; "Fifth DATETIME)", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateMiscTable()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateMiscTable()"); }
} }
@ -292,20 +292,20 @@ void ODBCSQLiteTest::recreateLogTable()
dropObject("TABLE", "T_POCO_LOG"); dropObject("TABLE", "T_POCO_LOG");
dropObject("TABLE", "T_POCO_LOG_ARCHIVE"); dropObject("TABLE", "T_POCO_LOG_ARCHIVE");
try try
{ {
std::string sql = "CREATE TABLE %s " std::string sql = "CREATE TABLE %s "
"(Source VARCHAR," "(Source VARCHAR,"
"Name VARCHAR," "Name VARCHAR,"
"ProcessId INTEGER," "ProcessId INTEGER,"
"Thread VARCHAR, " "Thread VARCHAR, "
"ThreadId INTEGER," "ThreadId INTEGER,"
"Priority INTEGER," "Priority INTEGER,"
"Text VARCHAR," "Text VARCHAR,"
"DateTime DATETIME)"; "DateTime DATETIME)";
session() << sql, "T_POCO_LOG", now; session() << sql, "T_POCO_LOG", now;
session() << sql, "T_POCO_LOG_ARCHIVE", now; session() << sql, "T_POCO_LOG_ARCHIVE", now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateLogTable()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateLogTable()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateLogTable()"); }

View File

@ -21,7 +21,7 @@
class ODBCSQLiteTest: public ODBCTest class ODBCSQLiteTest: public ODBCTest
/// SQLite3 ODBC test class /// SQLite3 ODBC test class
/// Tested: /// Tested:
/// ///
/// Driver | DB | OS /// Driver | DB | OS
/// ------------+---------------+------------------------------------------ /// ------------+---------------+------------------------------------------
/// 00.70.00.00 | SQLite 3.* | MS Windows XP Professional x64 v.2003/SP1 /// 00.70.00.00 | SQLite 3.* | MS Windows XP Professional x64 v.2003/SP1

View File

@ -49,7 +49,7 @@ using Poco::NotFoundException;
ODBCTest::Drivers ODBCTest::_drivers; ODBCTest::Drivers ODBCTest::_drivers;
const bool ODBCTest::_bindValues[8] = const bool ODBCTest::_bindValues[8] =
{true, true, true, false, false, true, false, false}; {true, true, true, false, false, true, false, false};
@ -59,7 +59,7 @@ ODBCTest::ODBCTest(const std::string& name,
std::string& rDSN, std::string& rDSN,
std::string& rUID, std::string& rUID,
std::string& rPwd, std::string& rPwd,
std::string& rConnectString): std::string& rConnectString):
CppUnit::TestCase(name), CppUnit::TestCase(name),
_pSession(pSession), _pSession(pSession),
_pExecutor(pExecutor), _pExecutor(pExecutor),
@ -212,7 +212,7 @@ void ODBCTest::testInsertVector()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->insertVector(); _pExecutor->insertVector();
i += 2; i += 2;
} }
} }
@ -227,7 +227,7 @@ void ODBCTest::testInsertEmptyVector()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->insertEmptyVector(); _pExecutor->insertEmptyVector();
i += 2; i += 2;
} }
} }
@ -257,7 +257,7 @@ void ODBCTest::testComplexTypeList()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->complexTypeList(); _pExecutor->complexTypeList();
i += 2; i += 2;
} }
} }
@ -272,7 +272,7 @@ void ODBCTest::testInsertList()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->insertList(); _pExecutor->insertList();
i += 2; i += 2;
} }
} }
@ -287,7 +287,7 @@ void ODBCTest::testInsertEmptyList()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->insertEmptyList(); _pExecutor->insertEmptyList();
i += 2; i += 2;
} }
} }
@ -317,7 +317,7 @@ void ODBCTest::testComplexTypeDeque()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->complexTypeDeque(); _pExecutor->complexTypeDeque();
i += 2; i += 2;
} }
} }
@ -332,7 +332,7 @@ void ODBCTest::testInsertDeque()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->insertDeque(); _pExecutor->insertDeque();
i += 2; i += 2;
} }
} }
@ -347,7 +347,7 @@ void ODBCTest::testInsertEmptyDeque()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->insertEmptyDeque(); _pExecutor->insertEmptyDeque();
i += 2; i += 2;
} }
} }
@ -362,7 +362,7 @@ void ODBCTest::testAffectedRows()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->affectedRows(); _pExecutor->affectedRows();
i += 2; i += 2;
} }
} }
@ -377,7 +377,7 @@ void ODBCTest::testInsertSingleBulk()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->insertSingleBulk(); _pExecutor->insertSingleBulk();
i += 2; i += 2;
} }
} }
@ -392,7 +392,7 @@ void ODBCTest::testInsertSingleBulkVec()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->insertSingleBulkVec(); _pExecutor->insertSingleBulkVec();
i += 2; i += 2;
} }
} }
@ -422,7 +422,7 @@ void ODBCTest::testLimitZero()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->limitZero(); _pExecutor->limitZero();
i += 2; i += 2;
} }
} }
@ -432,7 +432,7 @@ void ODBCTest::testLimitOnce()
recreateIntsTable(); recreateIntsTable();
_pExecutor->limitOnce(); _pExecutor->limitOnce();
} }
@ -579,7 +579,7 @@ void ODBCTest::testMultiSetComplex()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->multiSetComplex(); _pExecutor->multiSetComplex();
i += 2; i += 2;
} }
} }
@ -654,7 +654,7 @@ void ODBCTest::testSelectIntoSingleStep()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->selectIntoSingleStep(); _pExecutor->selectIntoSingleStep();
i += 2; i += 2;
} }
} }
@ -669,7 +669,7 @@ void ODBCTest::testSelectIntoSingleFail()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->selectIntoSingleFail(); _pExecutor->selectIntoSingleFail();
i += 2; i += 2;
} }
} }
@ -684,7 +684,7 @@ void ODBCTest::testLowerLimitOk()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->lowerLimitOk(); _pExecutor->lowerLimitOk();
i += 2; i += 2;
} }
} }
@ -699,7 +699,7 @@ void ODBCTest::testSingleSelect()
_pSession->setFeature("autoExtract", bindValue(i+1)); _pSession->setFeature("autoExtract", bindValue(i+1));
_pExecutor->singleSelect(); _pExecutor->singleSelect();
i += 2; i += 2;
} }
} }
@ -1300,13 +1300,13 @@ bool ODBCTest::canConnect(const std::string& driver,
{ {
if (((itDrv->first).find(driver) != std::string::npos)) if (((itDrv->first).find(driver) != std::string::npos))
{ {
std::cout << "Driver found: " << itDrv->first std::cout << "Driver found: " << itDrv->first
<< " (" << itDrv->second << ')' << std::endl; << " (" << itDrv->second << ')' << std::endl;
break; break;
} }
} }
if (_drivers.end() == itDrv) if (_drivers.end() == itDrv)
{ {
dsn = ""; dsn = "";
uid = ""; uid = "";
@ -1365,7 +1365,7 @@ ODBCTest::SessionPtr ODBCTest::init(const std::string& driver,
{ {
Utility::drivers(_drivers); Utility::drivers(_drivers);
if (!canConnect(driver, dsn, uid, pwd, dbConnString, db)) return 0; if (!canConnect(driver, dsn, uid, pwd, dbConnString, db)) return 0;
try try
{ {
std::cout << "Conecting to [" << dbConnString << ']' << std::endl; std::cout << "Conecting to [" << dbConnString << ']' << std::endl;

View File

@ -221,38 +221,38 @@ private:
// inlines // inlines
// //
inline void ODBCTest::testStoredProcedure() inline void ODBCTest::testStoredProcedure()
{ {
throw Poco::NotImplementedException("ODBCTest::testStoredProcedure()"); throw Poco::NotImplementedException("ODBCTest::testStoredProcedure()");
} }
inline void ODBCTest::testStoredProcedureAny() inline void ODBCTest::testStoredProcedureAny()
{ {
throw Poco::NotImplementedException("ODBCTest::testStoredProcedureAny()"); throw Poco::NotImplementedException("ODBCTest::testStoredProcedureAny()");
} }
inline void ODBCTest::testStoredProcedureDynamicAny() inline void ODBCTest::testStoredProcedureDynamicAny()
{ {
throw Poco::NotImplementedException("ODBCTest::testStoredProcedureDynamicAny()"); throw Poco::NotImplementedException("ODBCTest::testStoredProcedureDynamicAny()");
} }
inline void ODBCTest::testStoredFunction() inline void ODBCTest::testStoredFunction()
{ {
throw Poco::NotImplementedException("ODBCTest::testStoredFunction()"); throw Poco::NotImplementedException("ODBCTest::testStoredFunction()");
} }
inline void ODBCTest::testStoredFunctionAny() inline void ODBCTest::testStoredFunctionAny()
{ {
throw Poco::NotImplementedException("ODBCTest::testStoredFunctionAny()"); throw Poco::NotImplementedException("ODBCTest::testStoredFunctionAny()");
} }
inline void ODBCTest::testStoredFunctionDynamicAny() inline void ODBCTest::testStoredFunctionDynamicAny()
{ {
throw Poco::NotImplementedException("ODBCTest::testStoredFunctionDynamicAny()"); throw Poco::NotImplementedException("ODBCTest::testStoredFunctionDynamicAny()");
} }
@ -264,109 +264,109 @@ inline void ODBCTest::dropObject(const std::string& type, const std::string& nam
inline void ODBCTest::recreateNullableTable() inline void ODBCTest::recreateNullableTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateNullableTable()"); throw Poco::NotImplementedException("ODBCTest::recreateNullableTable()");
} }
inline void ODBCTest::recreatePersonTable() inline void ODBCTest::recreatePersonTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreatePersonTable()"); throw Poco::NotImplementedException("ODBCTest::recreatePersonTable()");
} }
inline void ODBCTest::recreatePersonTupleTable() inline void ODBCTest::recreatePersonTupleTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreatePersonTupleTable()"); throw Poco::NotImplementedException("ODBCTest::recreatePersonTupleTable()");
} }
inline void ODBCTest::recreatePersonBLOBTable() inline void ODBCTest::recreatePersonBLOBTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreatePersonBLOBTable()"); throw Poco::NotImplementedException("ODBCTest::recreatePersonBLOBTable()");
} }
inline void ODBCTest::recreatePersonDateTimeTable() inline void ODBCTest::recreatePersonDateTimeTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreatePersonDateTimeTable()"); throw Poco::NotImplementedException("ODBCTest::recreatePersonDateTimeTable()");
} }
inline void ODBCTest::recreatePersonDateTable() inline void ODBCTest::recreatePersonDateTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreatePersonDateTable()"); throw Poco::NotImplementedException("ODBCTest::recreatePersonDateTable()");
} }
inline void ODBCTest::recreatePersonTimeTable() inline void ODBCTest::recreatePersonTimeTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreatePersonTimeTable()"); throw Poco::NotImplementedException("ODBCTest::recreatePersonTimeTable()");
} }
inline void ODBCTest::recreateStringsTable() inline void ODBCTest::recreateStringsTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateStringsTable()"); throw Poco::NotImplementedException("ODBCTest::recreateStringsTable()");
} }
inline void ODBCTest::recreateIntsTable() inline void ODBCTest::recreateIntsTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateIntsTable()"); throw Poco::NotImplementedException("ODBCTest::recreateIntsTable()");
} }
inline void ODBCTest::recreateFloatsTable() inline void ODBCTest::recreateFloatsTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateFloatsTable()"); throw Poco::NotImplementedException("ODBCTest::recreateFloatsTable()");
} }
inline void ODBCTest::recreateUUIDsTable() inline void ODBCTest::recreateUUIDsTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateUUIDsTable()"); throw Poco::NotImplementedException("ODBCTest::recreateUUIDsTable()");
} }
inline void ODBCTest::recreateTuplesTable() inline void ODBCTest::recreateTuplesTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateTuplesTable()"); throw Poco::NotImplementedException("ODBCTest::recreateTuplesTable()");
} }
inline void ODBCTest::recreateVectorsTable() inline void ODBCTest::recreateVectorsTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateVectorsTable()"); throw Poco::NotImplementedException("ODBCTest::recreateVectorsTable()");
} }
inline void ODBCTest::recreateAnysTable() inline void ODBCTest::recreateAnysTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateAnysTable()"); throw Poco::NotImplementedException("ODBCTest::recreateAnysTable()");
} }
inline void ODBCTest::recreateNullsTable(const std::string&) inline void ODBCTest::recreateNullsTable(const std::string&)
{ {
throw Poco::NotImplementedException("ODBCTest::recreateNullsTable()"); throw Poco::NotImplementedException("ODBCTest::recreateNullsTable()");
} }
inline void ODBCTest::recreateBoolTable() inline void ODBCTest::recreateBoolTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateBoolTable()"); throw Poco::NotImplementedException("ODBCTest::recreateBoolTable()");
} }
inline void ODBCTest::recreateMiscTable() inline void ODBCTest::recreateMiscTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateMiscTable()"); throw Poco::NotImplementedException("ODBCTest::recreateMiscTable()");
} }
inline void ODBCTest::recreateLogTable() inline void ODBCTest::recreateLogTable()
{ {
throw Poco::NotImplementedException("ODBCTest::recreateLogTable()"); throw Poco::NotImplementedException("ODBCTest::recreateLogTable()");
} }
@ -383,48 +383,48 @@ inline void ODBCTest::recreateEncodingTables()
} }
inline bool ODBCTest::bindValue(int i) inline bool ODBCTest::bindValue(int i)
{ {
poco_assert (i < 8); poco_assert (i < 8);
return _bindValues[i]; return _bindValues[i];
} }
inline Poco::Data::Session& ODBCTest::session() inline Poco::Data::Session& ODBCTest::session()
{ {
poco_check_ptr (_pSession); poco_check_ptr (_pSession);
return *_pSession; return *_pSession;
} }
inline SQLExecutor& ODBCTest::executor() inline SQLExecutor& ODBCTest::executor()
{ {
poco_check_ptr (_pExecutor); poco_check_ptr (_pExecutor);
return *_pExecutor; return *_pExecutor;
} }
inline const std::string& ODBCTest::dsn() inline const std::string& ODBCTest::dsn()
{ {
return _rDSN; return _rDSN;
} }
inline const std::string& ODBCTest::uid() inline const std::string& ODBCTest::uid()
{ {
return _rUID; return _rUID;
} }
inline const std::string& ODBCTest::pwd() inline const std::string& ODBCTest::pwd()
{ {
return _rPwd; return _rPwd;
} }
inline const std::string& ODBCTest::dbConnString() inline const std::string& ODBCTest::dbConnString()
{ {
return _rConnectString; return _rConnectString;
} }

View File

@ -26,15 +26,15 @@ CppUnit::Test* ODBCTestSuite::suite()
// WARNING! // WARNING!
// On Win XP Pro, the PostgreSQL connection fails if attempted after DB2 w/ following error: // On Win XP Pro, the PostgreSQL connection fails if attempted after DB2 w/ following error:
// //
// sqlState="IM003" // sqlState="IM003"
// message="Specified driver could not be loaded due to system error 127 (PostgreSQL ANSI)." // message="Specified driver could not be loaded due to system error 127 (PostgreSQL ANSI)."
// nativeError=160 // nativeError=160
// System error 127 is "The specified procedure could not be found." // System error 127 is "The specified procedure could not be found."
// This problem does not manifest with Mammoth ODBCng PostgreSQL driver. // This problem does not manifest with Mammoth ODBCng PostgreSQL driver.
// //
// Oracle tests do not exit cleanly if Oracle driver is loaded after DB2. // Oracle tests do not exit cleanly if Oracle driver is loaded after DB2.
// //
// For the time being, the workaround is to connect to DB2 after connecting to PostgreSQL and Oracle. // For the time being, the workaround is to connect to DB2 after connecting to PostgreSQL and Oracle.
addTest(pSuite, ODBCMySQLTest::suite()); addTest(pSuite, ODBCMySQLTest::suite());

View File

@ -180,9 +180,9 @@ template <>
class TypeHandler<Person> class TypeHandler<Person>
{ {
public: public:
static void bind(std::size_t pos, static void bind(std::size_t pos,
const Person& obj, const Person& obj,
AbstractBinder::Ptr pBinder, AbstractBinder::Ptr pBinder,
AbstractBinder::Direction dir = AbstractBinder::PD_IN) AbstractBinder::Direction dir = AbstractBinder::PD_IN)
{ {
// the table is defined as Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3)) // the table is defined as Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))
@ -231,9 +231,9 @@ template <>
class TypeHandler<RefCountedPerson> class TypeHandler<RefCountedPerson>
{ {
public: public:
static void bind(std::size_t pos, static void bind(std::size_t pos,
const RefCountedPerson& obj, const RefCountedPerson& obj,
AbstractBinder::Ptr pBinder, AbstractBinder::Ptr pBinder,
AbstractBinder::Direction dir = AbstractBinder::PD_IN) AbstractBinder::Direction dir = AbstractBinder::PD_IN)
{ {
// the table is defined as Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3)) // the table is defined as Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))
@ -281,7 +281,7 @@ private:
} } // namespace Poco::Data } } // namespace Poco::Data
const std::string SQLExecutor::MULTI_INSERT = const std::string SQLExecutor::MULTI_INSERT =
"INSERT INTO Test VALUES ('1', 2, 3.5);" "INSERT INTO Test VALUES ('1', 2, 3.5);"
"INSERT INTO Test VALUES ('2', 3, 4.5);" "INSERT INTO Test VALUES ('2', 3, 4.5);"
"INSERT INTO Test VALUES ('3', 4, 5.5);" "INSERT INTO Test VALUES ('3', 4, 5.5);"
@ -309,9 +309,9 @@ SQLExecutor::~SQLExecutor()
} }
void SQLExecutor::bareboneODBCTest(const std::string& dbConnString, void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
const std::string& tableCreateString, const std::string& tableCreateString,
SQLExecutor::DataBinding bindMode, SQLExecutor::DataBinding bindMode,
SQLExecutor::DataExtraction extractMode, SQLExecutor::DataExtraction extractMode,
bool doTime, bool doTime,
const std::string& blobPlaceholder) const std::string& blobPlaceholder)
@ -349,7 +349,7 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
rc = SQLGetTypeInfo(hstmt, SQL_TYPE_TIMESTAMP); rc = SQLGetTypeInfo(hstmt, SQL_TYPE_TIMESTAMP);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLFetch(hstmt); rc = SQLFetch(hstmt);
assertTrue (SQL_SUCCEEDED(rc) || SQL_NO_DATA == rc); assertTrue (SQL_SUCCEEDED(rc) || SQL_NO_DATA == rc);
@ -414,15 +414,15 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
if (SQLExecutor::PB_AT_EXEC == bindMode) if (SQLExecutor::PB_AT_EXEC == bindMode)
li[0] = SQL_LEN_DATA_AT_EXEC(size); li[0] = SQL_LEN_DATA_AT_EXEC(size);
rc = SQLBindParameter(hstmt, rc = SQLBindParameter(hstmt,
(SQLUSMALLINT) 1, (SQLUSMALLINT) 1,
SQL_PARAM_INPUT, SQL_PARAM_INPUT,
SQL_C_CHAR, SQL_C_CHAR,
SQL_LONGVARCHAR, SQL_LONGVARCHAR,
(SQLUINTEGER) size, (SQLUINTEGER) size,
0, 0,
(SQLPOINTER) str[0].c_str(), (SQLPOINTER) str[0].c_str(),
size, size,
&li[0]); &li[0]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
@ -431,15 +431,15 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
li[1] = SQL_LEN_DATA_AT_EXEC(size); li[1] = SQL_LEN_DATA_AT_EXEC(size);
else li[1] = SQL_NTS; else li[1] = SQL_NTS;
rc = SQLBindParameter(hstmt, rc = SQLBindParameter(hstmt,
(SQLUSMALLINT) 2, (SQLUSMALLINT) 2,
SQL_PARAM_INPUT, SQL_PARAM_INPUT,
SQL_C_CHAR, SQL_C_CHAR,
SQL_LONGVARCHAR, SQL_LONGVARCHAR,
(SQLUINTEGER) size, (SQLUINTEGER) size,
0, 0,
(SQLPOINTER) str[1].c_str(), (SQLPOINTER) str[1].c_str(),
size, size,
&li[1]); &li[1]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
@ -448,39 +448,39 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
li[2] = SQL_LEN_DATA_AT_EXEC(size); li[2] = SQL_LEN_DATA_AT_EXEC(size);
else li[2] = size; else li[2] = size;
rc = SQLBindParameter(hstmt, rc = SQLBindParameter(hstmt,
(SQLUSMALLINT) 3, (SQLUSMALLINT) 3,
SQL_PARAM_INPUT, SQL_PARAM_INPUT,
SQL_C_BINARY, SQL_C_BINARY,
SQL_LONGVARBINARY, SQL_LONGVARBINARY,
(SQLUINTEGER) size, (SQLUINTEGER) size,
0, 0,
(SQLPOINTER) str[2].data(), (SQLPOINTER) str[2].data(),
size, size,
&li[2]); &li[2]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindParameter(hstmt, rc = SQLBindParameter(hstmt,
(SQLUSMALLINT) 4, (SQLUSMALLINT) 4,
SQL_PARAM_INPUT, SQL_PARAM_INPUT,
SQL_C_SLONG, SQL_C_SLONG,
SQL_INTEGER, SQL_INTEGER,
0, 0,
0, 0,
(SQLPOINTER) &fourth, (SQLPOINTER) &fourth,
0, 0,
0); 0);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindParameter(hstmt, rc = SQLBindParameter(hstmt,
(SQLUSMALLINT) 5, (SQLUSMALLINT) 5,
SQL_PARAM_INPUT, SQL_PARAM_INPUT,
SQL_C_FLOAT, SQL_C_FLOAT,
SQL_REAL, SQL_REAL,
0, 0,
1, 1,
(SQLPOINTER) &fifth, (SQLPOINTER) &fifth,
0, 0,
0); 0);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
@ -499,14 +499,14 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
else else
std::cerr << '[' << name() << ']' << " Warning: could not get SQL_TYPE_TIMESTAMP parameter description." << std::endl; std::cerr << '[' << name() << ']' << " Warning: could not get SQL_TYPE_TIMESTAMP parameter description." << std::endl;
rc = SQLBindParameter(hstmt, rc = SQLBindParameter(hstmt,
(SQLUSMALLINT) 6, (SQLUSMALLINT) 6,
SQL_PARAM_INPUT, SQL_PARAM_INPUT,
SQL_C_TYPE_TIMESTAMP, SQL_C_TYPE_TIMESTAMP,
SQL_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP,
dateTimeColSize, dateTimeColSize,
dateTimeDecDigits, dateTimeDecDigits,
(SQLPOINTER) &sixth, (SQLPOINTER) &sixth,
0, 0,
0); 0);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
@ -520,9 +520,9 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam))) while (SQL_NEED_DATA == (rc = SQLParamData(hstmt, &pParam)))
{ {
SQLINTEGER dataSize = 0; SQLINTEGER dataSize = 0;
// Data size should be ignored for non-null, // Data size should be ignored for non-null,
// non-variable length fields, but SQLite ODBC // non-variable length fields, but SQLite ODBC
// driver insists on it always being the actual // driver insists on it always being the actual
// data length // data length
if (pParam == (SQLPOINTER) str[0].c_str()) if (pParam == (SQLPOINTER) str[0].c_str())
@ -558,55 +558,55 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
if (SQLExecutor::DE_BOUND == extractMode) if (SQLExecutor::DE_BOUND == extractMode)
{ {
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 1, (SQLUSMALLINT) 1,
SQL_C_CHAR, SQL_C_CHAR,
(SQLPOINTER) chr[0], (SQLPOINTER) chr[0],
(SQLINTEGER) sizeof(chr[0]), (SQLINTEGER) sizeof(chr[0]),
&lengths[0]); &lengths[0]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 2, (SQLUSMALLINT) 2,
SQL_C_CHAR, SQL_C_CHAR,
(SQLPOINTER) chr[1], (SQLPOINTER) chr[1],
(SQLINTEGER) sizeof(chr[1]), (SQLINTEGER) sizeof(chr[1]),
&lengths[1]); &lengths[1]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 3, (SQLUSMALLINT) 3,
SQL_C_BINARY, SQL_C_BINARY,
(SQLPOINTER) chr[2], (SQLPOINTER) chr[2],
(SQLINTEGER) sizeof(chr[2]), (SQLINTEGER) sizeof(chr[2]),
&lengths[2]); &lengths[2]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 4, (SQLUSMALLINT) 4,
SQL_C_SLONG, SQL_C_SLONG,
(SQLPOINTER) &fourth, (SQLPOINTER) &fourth,
(SQLINTEGER) 0, (SQLINTEGER) 0,
&lengths[3]); &lengths[3]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 5, (SQLUSMALLINT) 5,
SQL_C_FLOAT, SQL_C_FLOAT,
(SQLPOINTER) &fifth, (SQLPOINTER) &fifth,
(SQLINTEGER) 0, (SQLINTEGER) 0,
&lengths[4]); &lengths[4]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 6, (SQLUSMALLINT) 6,
SQL_C_TYPE_TIMESTAMP, SQL_C_TYPE_TIMESTAMP,
(SQLPOINTER) &sixth, (SQLPOINTER) &sixth,
(SQLINTEGER) 0, (SQLINTEGER) 0,
&lengths[5]); &lengths[5]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
} }
rc = SQLExecute(hstmt); rc = SQLExecute(hstmt);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLFetch(hstmt); rc = SQLFetch(hstmt);
@ -615,67 +615,67 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
if (SQLExecutor::DE_MANUAL == extractMode) if (SQLExecutor::DE_MANUAL == extractMode)
{ {
SQLLEN len = lengths[0] = 0; SQLLEN len = lengths[0] = 0;
while (SQL_SUCCESS_WITH_INFO == (rc = SQLGetData(hstmt, while (SQL_SUCCESS_WITH_INFO == (rc = SQLGetData(hstmt,
(SQLUSMALLINT) 1, (SQLUSMALLINT) 1,
SQL_C_CHAR, SQL_C_CHAR,
chr[0] + len, chr[0] + len,
sizeof(chr[0]) - len, sizeof(chr[0]) - len,
&lengths[0]))) &lengths[0])))
{ {
len += lengths[0]; len += lengths[0];
if (!lengths[0] || len >= sizeof(chr[1])) if (!lengths[0] || len >= sizeof(chr[1]))
break; break;
} }
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
len = lengths[1] = 0; len = lengths[1] = 0;
while (SQL_SUCCESS_WITH_INFO == (rc = SQLGetData(hstmt, while (SQL_SUCCESS_WITH_INFO == (rc = SQLGetData(hstmt,
(SQLUSMALLINT) 2, (SQLUSMALLINT) 2,
SQL_C_CHAR, SQL_C_CHAR,
chr[1] + len, chr[1] + len,
sizeof(chr[1]) - len, sizeof(chr[1]) - len,
&lengths[1]))) &lengths[1])))
{ {
len += lengths[1]; len += lengths[1];
if (!lengths[1] || len >= sizeof(chr[1])) if (!lengths[1] || len >= sizeof(chr[1]))
break; break;
} }
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
len = lengths[2] = 0; len = lengths[2] = 0;
while (SQL_SUCCESS_WITH_INFO == (rc = SQLGetData(hstmt, while (SQL_SUCCESS_WITH_INFO == (rc = SQLGetData(hstmt,
(SQLUSMALLINT) 3, (SQLUSMALLINT) 3,
SQL_C_BINARY, SQL_C_BINARY,
chr[2] + len, chr[2] + len,
sizeof(chr[2]) - len, sizeof(chr[2]) - len,
&lengths[2]))) &lengths[2])))
{ {
len += lengths[1]; len += lengths[1];
if (!lengths[2] || len >= sizeof(chr[2])) if (!lengths[2] || len >= sizeof(chr[2]))
break; break;
} }
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLGetData(hstmt, rc = SQLGetData(hstmt,
(SQLUSMALLINT) 4, (SQLUSMALLINT) 4,
SQL_C_SLONG, SQL_C_SLONG,
&fourth, &fourth,
0, 0,
&lengths[3]); &lengths[3]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLGetData(hstmt, rc = SQLGetData(hstmt,
(SQLUSMALLINT) 5, (SQLUSMALLINT) 5,
SQL_C_FLOAT, SQL_C_FLOAT,
&fifth, &fifth,
0, 0,
&lengths[4]); &lengths[4]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLGetData(hstmt, rc = SQLGetData(hstmt,
(SQLUSMALLINT) 6, (SQLUSMALLINT) 6,
SQL_C_TYPE_TIMESTAMP, SQL_C_TYPE_TIMESTAMP,
&sixth, &sixth,
0, 0,
&lengths[5]); &lengths[5]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
@ -728,9 +728,9 @@ void SQLExecutor::bareboneODBCTest(const std::string& dbConnString,
} }
void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString, void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
const std::string& tableCreateString, const std::string& tableCreateString,
SQLExecutor::DataBinding bindMode, SQLExecutor::DataBinding bindMode,
SQLExecutor::DataExtraction extractMode, SQLExecutor::DataExtraction extractMode,
const std::string& insert, const std::string& insert,
const std::string& select) const std::string& select)
@ -802,11 +802,11 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
if (SQLExecutor::DE_BOUND == extractMode) if (SQLExecutor::DE_BOUND == extractMode)
{ {
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 1, (SQLUSMALLINT) 1,
SQL_C_SLONG, SQL_C_SLONG,
(SQLPOINTER) &count, (SQLPOINTER) &count,
(SQLINTEGER) 0, (SQLINTEGER) 0,
&length); &length);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
} }
@ -819,10 +819,10 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
if (SQLExecutor::DE_MANUAL == extractMode) if (SQLExecutor::DE_MANUAL == extractMode)
{ {
rc = SQLGetData(hstmt, rc = SQLGetData(hstmt,
(SQLUSMALLINT) 1, (SQLUSMALLINT) 1,
SQL_C_SLONG, SQL_C_SLONG,
&count, &count,
0, 0,
&length); &length);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
@ -841,34 +841,34 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
SQLLEN lengths[3] = { 0 }; SQLLEN lengths[3] = { 0 };
int second = 0; int second = 0;
float third = 0.0f; float third = 0.0f;
if (SQLExecutor::DE_BOUND == extractMode) if (SQLExecutor::DE_BOUND == extractMode)
{ {
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 1, (SQLUSMALLINT) 1,
SQL_C_CHAR, SQL_C_CHAR,
(SQLPOINTER) chr, (SQLPOINTER) chr,
(SQLINTEGER) 4, (SQLINTEGER) 4,
&lengths[0]); &lengths[0]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 2, (SQLUSMALLINT) 2,
SQL_C_SLONG, SQL_C_SLONG,
(SQLPOINTER) &second, (SQLPOINTER) &second,
(SQLINTEGER) 0, (SQLINTEGER) 0,
&lengths[1]); &lengths[1]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLBindCol(hstmt, rc = SQLBindCol(hstmt,
(SQLUSMALLINT) 3, (SQLUSMALLINT) 3,
SQL_C_FLOAT, SQL_C_FLOAT,
(SQLPOINTER) &third, (SQLPOINTER) &third,
(SQLINTEGER) 0, (SQLINTEGER) 0,
&lengths[2]); &lengths[2]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
} }
rc = SQLExecute(hstmt); rc = SQLExecute(hstmt);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
@ -884,26 +884,26 @@ void SQLExecutor::bareboneODBCMultiResultTest(const std::string& dbConnString,
if (SQLExecutor::DE_MANUAL == extractMode) if (SQLExecutor::DE_MANUAL == extractMode)
{ {
rc = SQLGetData(hstmt, rc = SQLGetData(hstmt,
(SQLUSMALLINT) 1, (SQLUSMALLINT) 1,
SQL_C_CHAR, SQL_C_CHAR,
chr, chr,
4, 4,
&lengths[0]); &lengths[0]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLGetData(hstmt, rc = SQLGetData(hstmt,
(SQLUSMALLINT) 2, (SQLUSMALLINT) 2,
SQL_C_SLONG, SQL_C_SLONG,
&second, &second,
0, 0,
&lengths[1]); &lengths[1]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
rc = SQLGetData(hstmt, rc = SQLGetData(hstmt,
(SQLUSMALLINT) 3, (SQLUSMALLINT) 3,
SQL_C_FLOAT, SQL_C_FLOAT,
&third, &third,
0, 0,
&lengths[2]); &lengths[2]);
poco_odbc_check_stmt (rc, hstmt); poco_odbc_check_stmt (rc, hstmt);
@ -1568,7 +1568,7 @@ void SQLExecutor::insertSingleBulkVec()
{ {
std::string funct = "insertSingleBulkVec()"; std::string funct = "insertSingleBulkVec()";
std::vector<int> data; std::vector<int> data;
for (int x = 0; x < 100; ++x) for (int x = 0; x < 100; ++x)
data.push_back(x); data.push_back(x);
@ -1674,9 +1674,9 @@ void SQLExecutor::limitPrepare()
data.push_back(x); data.push_back(x);
} }
try try
{ {
Statement stmt = (session() << "INSERT INTO Strings VALUES (?)", use(data)); Statement stmt = (session() << "INSERT INTO Strings VALUES (?)", use(data));
assertTrue (100 == stmt.execute()); assertTrue (100 == stmt.execute());
} }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
@ -1738,13 +1738,13 @@ void SQLExecutor::doBulkPerformance(Poco::UInt32 size)
std::vector<std::string> strings(size, "abc"); std::vector<std::string> strings(size, "abc");
std::vector<double> floats(size, .5); std::vector<double> floats(size, .5);
std::vector<DateTime> dateTimes(size); std::vector<DateTime> dateTimes(size);
Stopwatch sw; Stopwatch sw;
try try
{ {
sw.start(); sw.start();
session() << "INSERT INTO MiscTest (First, Third, Fourth, Fifth) VALUES (?,?,?,?)", session() << "INSERT INTO MiscTest (First, Third, Fourth, Fifth) VALUES (?,?,?,?)",
use(strings), use(strings),
use(ints), use(ints),
use(floats), use(floats),
use(dateTimes), now; use(dateTimes), now;
@ -1758,18 +1758,18 @@ void SQLExecutor::doBulkPerformance(Poco::UInt32 size)
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try try
{ {
sw.restart(); sw.restart();
session() << "INSERT INTO MiscTest (First, Third, Fourth, Fifth) VALUES (?,?,?,?)", session() << "INSERT INTO MiscTest (First, Third, Fourth, Fifth) VALUES (?,?,?,?)",
use(strings, bulk), use(strings, bulk),
use(ints, bulk), use(ints, bulk),
use(floats, bulk), use(floats, bulk),
use(dateTimes, bulk), now; use(dateTimes, bulk), now;
sw.stop(); sw.stop();
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
double bulkTime = sw.elapsed() / 1000.0; double bulkTime = sw.elapsed() / 1000.0;
double speedup; double speedup;
@ -1781,10 +1781,10 @@ void SQLExecutor::doBulkPerformance(Poco::UInt32 size)
else else
speedup = time / bulkTime; speedup = time / bulkTime;
std::cout << "INSERT => Size:" << size std::cout << "INSERT => Size:" << size
<< ", Time: " << time << ", Time: " << time
<< ", Bulk Time: " << bulkTime << ", Bulk Time: " << bulkTime
<< " [ms], Speedup: " << speedup << " [ms], Speedup: " << speedup
<< 'x' << std::endl; << 'x' << std::endl;
ints.clear(); ints.clear();
@ -1792,19 +1792,19 @@ void SQLExecutor::doBulkPerformance(Poco::UInt32 size)
floats.clear(); floats.clear();
dateTimes.clear(); dateTimes.clear();
try try
{ {
sw.restart(); sw.restart();
session() << "SELECT First, Third, Fourth, Fifth FROM MiscTest", session() << "SELECT First, Third, Fourth, Fifth FROM MiscTest",
into(strings), into(strings),
into(ints), into(ints),
into(floats), into(floats),
into(dateTimes), into(dateTimes),
now; now;
sw.stop(); sw.stop();
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
time = sw.elapsed() / 1000.0; time = sw.elapsed() / 1000.0;
assertTrue (ints.size() == size); assertTrue (ints.size() == size);
@ -1813,20 +1813,20 @@ void SQLExecutor::doBulkPerformance(Poco::UInt32 size)
strings.clear(); strings.clear();
floats.clear(); floats.clear();
dateTimes.clear(); dateTimes.clear();
try try
{ {
sw.restart(); sw.restart();
session() << "SELECT First, Third, Fourth, Fifth FROM MiscTest", session() << "SELECT First, Third, Fourth, Fifth FROM MiscTest",
into(strings, bulk(size)), into(strings, bulk(size)),
into(ints, bulk(size)), into(ints, bulk(size)),
into(floats, bulk(size)), into(floats, bulk(size)),
into(dateTimes, bulk(size)), into(dateTimes, bulk(size)),
now; now;
sw.stop(); sw.stop();
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
bulkTime = sw.elapsed() / 1000.0; bulkTime = sw.elapsed() / 1000.0;
assertTrue (ints.size() == size); assertTrue (ints.size() == size);
@ -1839,10 +1839,10 @@ void SQLExecutor::doBulkPerformance(Poco::UInt32 size)
else else
speedup = time / bulkTime; speedup = time / bulkTime;
std::cout << "SELECT => Size:" << size std::cout << "SELECT => Size:" << size
<< ", Time: " << time << ", Time: " << time
<< ", Bulk Time: " << bulkTime << ", Bulk Time: " << bulkTime
<< " [ms], Speedup: " << speedup << " [ms], Speedup: " << speedup
<< 'x' << std::endl; << 'x' << std::endl;
} }
@ -2078,7 +2078,7 @@ void SQLExecutor::multiMapComplex()
people.insert(std::make_pair("LN1", p1)); people.insert(std::make_pair("LN1", p1));
people.insert(std::make_pair("LN1", p1)); people.insert(std::make_pair("LN1", p1));
people.insert(std::make_pair("LN2", p2)); people.insert(std::make_pair("LN2", p2));
try { session() << "INSERT INTO Person VALUES (?,?,?,?)", use(people), now; } try { session() << "INSERT INTO Person VALUES (?,?,?,?)", use(people), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
@ -2140,7 +2140,7 @@ void SQLExecutor::selectIntoSingleStep()
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
assertTrue (count == 2); assertTrue (count == 2);
Person result; Person result;
Statement stmt = (session() << "SELECT * FROM Person", into(result), limit(1)); Statement stmt = (session() << "SELECT * FROM Person", into(result), limit(1));
stmt.execute(); stmt.execute();
assertTrue (result == p1); assertTrue (result == p1);
assertTrue (!stmt.done()); assertTrue (!stmt.done());
@ -2406,7 +2406,7 @@ void SQLExecutor::blob(int bigSize, const std::string& blobPlaceholder)
CLOB img("0123456789", 10); CLOB img("0123456789", 10);
int count = 0; int count = 0;
try { session() << format("INSERT INTO Person VALUES (?,?,?,%s)", blobPlaceholder), try { session() << format("INSERT INTO Person VALUES (?,?,?,%s)", blobPlaceholder),
use(lastName), use(firstName), use(address), use(img), now; } use(lastName), use(firstName), use(address), use(img), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
@ -2432,7 +2432,7 @@ void SQLExecutor::blob(int bigSize, const std::string& blobPlaceholder)
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try { session() << format("INSERT INTO Person VALUES (?,?,?,%s)", blobPlaceholder), try { session() << format("INSERT INTO Person VALUES (?,?,?,%s)", blobPlaceholder),
use(lastName), use(firstName), use(address), use(big), now; } use(lastName), use(firstName), use(address), use(big), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
@ -2510,11 +2510,11 @@ void SQLExecutor::date()
Date bornDate(1965, 6, 18); Date bornDate(1965, 6, 18);
int count = 0; int count = 0;
try { session() << "INSERT INTO Person VALUES (?,?,?,?)", try { session() << "INSERT INTO Person VALUES (?,?,?,?)",
use(lastName), use(lastName),
use(firstName), use(firstName),
use(address), use(address),
use(bornDate), use(bornDate),
now; } now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
@ -2549,11 +2549,11 @@ void SQLExecutor::time()
Time bornTime (5, 35, 1); Time bornTime (5, 35, 1);
int count = 0; int count = 0;
try { session() << "INSERT INTO Person VALUES (?,?,?,?)", try { session() << "INSERT INTO Person VALUES (?,?,?,?)",
use(lastName), use(lastName),
use(firstName), use(firstName),
use(address), use(address),
use(bornTime), use(bornTime),
now; } now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
@ -2601,7 +2601,7 @@ void SQLExecutor::tupleVector()
typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType; typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType;
std::string funct = "tupleVector()"; std::string funct = "tupleVector()";
TupleType t(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19); TupleType t(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int>
t10(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29); t10(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29);
TupleType t100(100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119); TupleType t100(100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119);
std::vector<TupleType> v; std::vector<TupleType> v;
@ -2640,8 +2640,8 @@ void SQLExecutor::internalExtraction()
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try try
{ {
Statement stmt = (session() << "SELECT * FROM Vectors", now); Statement stmt = (session() << "SELECT * FROM Vectors", now);
RecordSet rset(stmt); RecordSet rset(stmt);
@ -2697,7 +2697,7 @@ void SQLExecutor::internalExtraction()
i = rset.value("str0", 2); i = rset.value("str0", 2);
assertTrue (5 == i); assertTrue (5 == i);
const Column<std::deque<int> >& col = rset.column<std::deque<int> >(0); const Column<std::deque<int> >& col = rset.column<std::deque<int> >(0);
Column<std::deque<int> >::Iterator it = col.begin(); Column<std::deque<int> >::Iterator it = col.begin();
Column<std::deque<int> >::Iterator end = col.end(); Column<std::deque<int> >::Iterator end = col.end();
@ -2737,7 +2737,7 @@ void SQLExecutor::internalExtraction()
try { rset.value<std::string>(0,0); fail ("must fail"); } try { rset.value<std::string>(0,0); fail ("must fail"); }
catch (BadCastException&) { } catch (BadCastException&) { }
stmt = (session() << "DELETE FROM Vectors", now); stmt = (session() << "DELETE FROM Vectors", now);
rset = stmt; rset = stmt;
@ -2762,8 +2762,8 @@ void SQLExecutor::filter(const std::string& query, const std::string& intFldName
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try try
{ {
Statement stmt = (session() << query, now); Statement stmt = (session() << query, now);
RecordSet rset(stmt); RecordSet rset(stmt);
assertTrue (rset.totalRowCount() == 4); assertTrue (rset.totalRowCount() == 4);
@ -2773,11 +2773,11 @@ void SQLExecutor::filter(const std::string& query, const std::string& intFldName
assertTrue (!pRF->isEmpty()); assertTrue (!pRF->isEmpty());
Var da; Var da;
try try
{ {
da = rset.value(0, 1); da = rset.value(0, 1);
fail ("must fail"); fail ("must fail");
} catch (InvalidAccessException&) } catch (InvalidAccessException&)
{ {
da = rset.value(0, 1, false); da = rset.value(0, 1, false);
assertTrue (2 == da); assertTrue (2 == da);
@ -2846,22 +2846,22 @@ void SQLExecutor::internalBulkExtraction()
age[i] = i; age[i] = i;
} }
try try
{ {
session() << "INSERT INTO Person VALUES (?,?,?,?)", session() << "INSERT INTO Person VALUES (?,?,?,?)",
use(lastName, bulk), use(lastName, bulk),
use(firstName, bulk), use(firstName, bulk),
use(address, bulk), use(address, bulk),
use(age, bulk), use(age, bulk),
now; now;
} }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try try
{ {
Statement stmt = (session() << "SELECT * FROM Person", bulk(size), now); Statement stmt = (session() << "SELECT * FROM Person", bulk(size), now);
RecordSet rset(stmt); RecordSet rset(stmt);
assertTrue (size == rset.rowCount()); assertTrue (size == rset.rowCount());
assertTrue ("LN0" == rset["LastName"]); assertTrue ("LN0" == rset["LastName"]);
assertTrue (0 == rset["Age"]); assertTrue (0 == rset["Age"]);
@ -2875,10 +2875,10 @@ void SQLExecutor::internalBulkExtraction()
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try try
{ {
Statement stmt = (session() << "SELECT * FROM Person", limit(size), bulk, now); Statement stmt = (session() << "SELECT * FROM Person", limit(size), bulk, now);
RecordSet rset(stmt); RecordSet rset(stmt);
assertTrue (size == rset.rowCount()); assertTrue (size == rset.rowCount());
assertTrue ("LN0" == rset["LastName"]); assertTrue ("LN0" == rset["LastName"]);
assertTrue (0 == rset["Age"]); assertTrue (0 == rset["Age"]);
@ -2971,8 +2971,8 @@ void SQLExecutor::internalStorageType()
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try try
{ {
std::vector<Statement::Manipulator>::iterator it = manips.begin(); std::vector<Statement::Manipulator>::iterator it = manips.begin();
std::vector<Statement::Manipulator>::iterator end = manips.end(); std::vector<Statement::Manipulator>::iterator end = manips.end();
@ -3029,15 +3029,15 @@ void SQLExecutor::notNulls(const std::string& sqlState)
{ {
session() << "INSERT INTO NullTest (i,r,v) VALUES (?,?,?)", use(null), use(null), use(null), now; session() << "INSERT INTO NullTest (i,r,v) VALUES (?,?,?)", use(null), use(null), use(null), now;
fail ("must fail"); fail ("must fail");
}catch (StatementException& se) }catch (StatementException& se)
{ {
//double check if we're failing for the right reason //double check if we're failing for the right reason
//default sqlState value is "23502"; some drivers report "HY???" codes //default sqlState value is "23502"; some drivers report "HY???" codes
if (se.diagnostics().fields().size()) if (se.diagnostics().fields().size())
{ {
std::string st = se.diagnostics().sqlState(0); std::string st = se.diagnostics().sqlState(0);
if (sqlState != st) if (sqlState != st)
std::cerr << '[' << name() << ']' << " Warning: expected SQL state [" << sqlState << std::cerr << '[' << name() << ']' << " Warning: expected SQL state [" << sqlState <<
"], received [" << se.diagnostics().sqlState(0) << "] instead." << std::endl; "], received [" << se.diagnostics().sqlState(0) << "] instead." << std::endl;
} }
} }
@ -3185,7 +3185,7 @@ void SQLExecutor::rowIterator()
std::ostringstream osLoop; std::ostringstream osLoop;
RecordSet::Iterator it = rset.begin(); RecordSet::Iterator it = rset.begin();
RecordSet::Iterator end = rset.end(); RecordSet::Iterator end = rset.end();
for (int i = 1; it != end; ++it, ++i) for (int i = 1; it != end; ++it, ++i)
{ {
assertTrue (it->get(0) == i); assertTrue (it->get(0) == i);
osLoop << *it; osLoop << *it;
@ -3202,7 +3202,7 @@ void SQLExecutor::rowIterator()
assertTrue (!pRF->isEmpty()); assertTrue (!pRF->isEmpty());
it = rset.begin(); it = rset.begin();
end = rset.end(); end = rset.end();
for (int i = 1; it != end; ++it, ++i) for (int i = 1; it != end; ++it, ++i)
{ {
assertTrue (it->get(0) == i); assertTrue (it->get(0) == i);
assertTrue (1 == i); assertTrue (1 == i);
@ -3279,7 +3279,7 @@ void SQLExecutor::asynchronous(int rowCount)
Statement::Result result = stmt.executeAsync(); Statement::Result result = stmt.executeAsync();
assertTrue (!stmt.isAsync()); assertTrue (!stmt.isAsync());
result.wait(); result.wait();
Statement stmt1 = (tmp << "SELECT * FROM Strings", into(data), async, now); Statement stmt1 = (tmp << "SELECT * FROM Strings", into(data), async, now);
assertTrue (stmt1.isAsync()); assertTrue (stmt1.isAsync());
assertTrue (stmt1.wait() == rowCount); assertTrue (stmt1.wait() == rowCount);
@ -3302,7 +3302,7 @@ void SQLExecutor::asynchronous(int rowCount)
assertTrue (stmt.isAsync()); assertTrue (stmt.isAsync());
stmt.wait(); stmt.wait();
assertTrue (stmt.execute() == 0); assertTrue (stmt.execute() == 0);
// +++ if this part of the test case fails, increase the rowCount until achieved // +++ if this part of the test case fails, increase the rowCount until achieved
// that first execute is still executing when the second one is called // that first execute is still executing when the second one is called
try { try {
@ -3338,7 +3338,7 @@ void SQLExecutor::asynchronous(int rowCount)
assertTrue (data.size() == 0); assertTrue (data.size() == 0);
assertTrue (!stmt2.done()); assertTrue (!stmt2.done());
std::size_t rows = 0; std::size_t rows = 0;
for (int i = 0; !stmt2.done(); i += step) for (int i = 0; !stmt2.done(); i += step)
{ {
stmt2.execute(); stmt2.execute();
@ -3504,8 +3504,8 @@ void SQLExecutor::sqlChannel(const std::string& connect)
rs2.moveNext(); rs2.moveNext();
assertTrue ("WarningSource" == rs2["Source"]); assertTrue ("WarningSource" == rs2["Source"]);
assertTrue ("f Warning sync message" == rs2["Text"]); assertTrue ("f Warning sync message" == rs2["Text"]);
} }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("sqlChannel()"); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("sqlChannel()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("sqlChannel()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("sqlChannel()"); }
} }
@ -3518,7 +3518,7 @@ void SQLExecutor::sqlLogger(const std::string& connect)
Logger& root = Logger::root(); Logger& root = Logger::root();
root.setChannel(new SQLChannel(Poco::Data::ODBC::Connector::KEY, connect, "TestSQLChannel")); root.setChannel(new SQLChannel(Poco::Data::ODBC::Connector::KEY, connect, "TestSQLChannel"));
root.setLevel(Message::PRIO_INFORMATION); root.setLevel(Message::PRIO_INFORMATION);
root.information("a Informational message"); root.information("a Informational message");
root.warning("b Warning message"); root.warning("b Warning message");
root.debug("Debug message"); root.debug("Debug message");
@ -3532,26 +3532,26 @@ void SQLExecutor::sqlLogger(const std::string& connect)
assertTrue ("TestSQLChannel" == rs["Source"]); assertTrue ("TestSQLChannel" == rs["Source"]);
assertTrue ("b Warning message" == rs["Text"]); assertTrue ("b Warning message" == rs["Text"]);
root.setChannel(nullptr); root.setChannel(nullptr);
} }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("sqlLogger()"); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("sqlLogger()"); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("sqlLogger()"); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("sqlLogger()"); }
} }
void SQLExecutor::setTransactionIsolation(Session& session, Poco::UInt32 ti) void SQLExecutor::setTransactionIsolation(Session& session, Poco::UInt32 ti)
{ {
if (session.hasTransactionIsolation(ti)) if (session.hasTransactionIsolation(ti))
{ {
std::string funct = "setTransactionIsolation()"; std::string funct = "setTransactionIsolation()";
try try
{ {
Transaction t(session, false); Transaction t(session, false);
t.setIsolation(ti); t.setIsolation(ti);
assertTrue (ti == t.getIsolation()); assertTrue (ti == t.getIsolation());
assertTrue (t.isIsolation(ti)); assertTrue (t.isIsolation(ti));
assertTrue (ti == session.getTransactionIsolation()); assertTrue (ti == session.getTransactionIsolation());
assertTrue (session.isTransactionIsolation(ti)); assertTrue (session.isTransactionIsolation(ti));
} }
@ -3714,11 +3714,11 @@ void SQLExecutor::transaction(const std::string& connect)
Transaction trans(session()); Transaction trans(session());
assertTrue (trans.isActive()); assertTrue (trans.isActive());
assertTrue (session().isTransaction()); assertTrue (session().isTransaction());
try { session() << "INSERT INTO Person VALUES (?,?,?,?)", use(lastNames), use(firstNames), use(addresses), use(ages), now; } try { session() << "INSERT INTO Person VALUES (?,?,?,?)", use(lastNames), use(firstNames), use(addresses), use(ages), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
assertTrue (session().isTransaction()); assertTrue (session().isTransaction());
assertTrue (trans.isActive()); assertTrue (trans.isActive());
@ -3770,7 +3770,7 @@ void SQLExecutor::transaction(const std::string& connect)
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
assertTrue (0 == count); assertTrue (0 == count);
try try
{ {
stmt1.wait(5000); stmt1.wait(5000);
if (local.getTransactionIsolation() == Session::TRANSACTION_READ_UNCOMMITTED) if (local.getTransactionIsolation() == Session::TRANSACTION_READ_UNCOMMITTED)
@ -3818,7 +3818,7 @@ void SQLExecutor::transaction(const std::string& connect)
assertTrue (0 == count); assertTrue (0 == count);
trans.execute(sql); trans.execute(sql);
Statement stmt3 = (local << "SELECT COUNT(*) FROM Person", into(locCount), now); Statement stmt3 = (local << "SELECT COUNT(*) FROM Person", into(locCount), now);
assertTrue (2 == locCount); assertTrue (2 == locCount);
@ -3870,7 +3870,7 @@ void SQLExecutor::transactor()
try { session() << "DELETE FROM Person", now; session().commit();} try { session() << "DELETE FROM Person", now; session().commit();}
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try { session() << "SELECT count(*) FROM Person", into(count), now; } try { session() << "SELECT count(*) FROM Person", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
@ -3961,7 +3961,7 @@ void SQLExecutor::nullable()
assertTrue (rs.isNull("EmptyInteger")); assertTrue (rs.isNull("EmptyInteger"));
assertTrue (rs.isNull("EmptyFloat")); assertTrue (rs.isNull("EmptyFloat"));
assertTrue (rs.isNull("EmptyDateTime")); assertTrue (rs.isNull("EmptyDateTime"));
Var di = 1; Var di = 1;
Var df = 1.5; Var df = 1.5;
Var ds = "abc"; Var ds = "abc";
@ -3971,7 +3971,7 @@ void SQLExecutor::nullable()
assertTrue (!df.isEmpty()); assertTrue (!df.isEmpty());
assertTrue (!ds.isEmpty()); assertTrue (!ds.isEmpty());
assertTrue (!dd.isEmpty()); assertTrue (!dd.isEmpty());
Statement stmt = (session() << "SELECT EmptyString, EmptyInteger, EmptyFloat, EmptyDateTime FROM NullableTest", into(ds), into(di), into(df), into(dd), now); Statement stmt = (session() << "SELECT EmptyString, EmptyInteger, EmptyFloat, EmptyDateTime FROM NullableTest", into(ds), into(di), into(df), into(dd), now);
assertTrue (di.isEmpty()); assertTrue (di.isEmpty());
@ -4004,9 +4004,9 @@ void SQLExecutor::reconnect()
assertTrue (session().isConnected()); assertTrue (session().isConnected());
session().close(); session().close();
assertTrue (!session().isConnected()); assertTrue (!session().isConnected());
try try
{ {
session() << "SELECT LastName FROM Person", into(result), now; session() << "SELECT LastName FROM Person", into(result), now;
fail ("must fail"); fail ("must fail");
} }
catch(NotConnectedException&){ } catch(NotConnectedException&){ }

View File

@ -80,7 +80,7 @@ public:
PB_IMMEDIATE, PB_IMMEDIATE,
PB_AT_EXEC PB_AT_EXEC
}; };
enum DataExtraction enum DataExtraction
{ {
DE_MANUAL, DE_MANUAL,
@ -95,22 +95,22 @@ public:
void bareboneODBCTest(const std::string& dbConnString, void bareboneODBCTest(const std::string& dbConnString,
const std::string& tableCreateString, const std::string& tableCreateString,
DataBinding bindMode, DataBinding bindMode,
DataExtraction extractMode, DataExtraction extractMode,
bool doTime=true, bool doTime=true,
const std::string& blobPlaceholder="?"); const std::string& blobPlaceholder="?");
void bareboneODBCMultiResultTest(const std::string& dbConnString, void bareboneODBCMultiResultTest(const std::string& dbConnString,
const std::string& tableCreateString, const std::string& tableCreateString,
SQLExecutor::DataBinding bindMode, SQLExecutor::DataBinding bindMode,
SQLExecutor::DataExtraction extractMode, SQLExecutor::DataExtraction extractMode,
const std::string& insert = MULTI_INSERT, const std::string& insert = MULTI_INSERT,
const std::string& select = MULTI_SELECT); const std::string& select = MULTI_SELECT);
/// The above two functions use "bare bone" ODBC API calls /// The above two functions use "bare bone" ODBC API calls
/// (i.e. calls are not "wrapped" in PocoData framework structures). /// (i.e. calls are not "wrapped" in PocoData framework structures).
/// The purpose of the functions is to verify that a driver behaves /// The purpose of the functions is to verify that a driver behaves
/// correctly as well as to determine its capabilities /// correctly as well as to determine its capabilities
/// (e.g. SQLGetData() restrictions relaxation policy, if any). /// (e.g. SQLGetData() restrictions relaxation policy, if any).
/// If these test pass, subsequent tests failures are likely ours. /// If these test pass, subsequent tests failures are likely ours.
void zeroRows(); void zeroRows();
@ -158,7 +158,7 @@ public:
C4 floats; C4 floats;
C5 dateTimes(size); C5 dateTimes(size);
C6 bools; C6 bools;
for (int i = 0; i < size; ++i) for (int i = 0; i < size; ++i)
{ {
ints.push_back(i); ints.push_back(i);
@ -168,12 +168,12 @@ public:
bools.push_back(0 == i % 2); bools.push_back(0 == i % 2);
} }
try try
{ {
session() << session() <<
Poco::format("INSERT INTO MiscTest VALUES (?,%s,?,?,?,?)", blobPlaceholder), Poco::format("INSERT INTO MiscTest VALUES (?,%s,?,?,?,?)", blobPlaceholder),
use(strings), use(strings),
use(blobs), use(blobs),
use(ints), use(ints),
use(floats), use(floats),
use(dateTimes), use(dateTimes),
@ -185,12 +185,12 @@ public:
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try try
{ {
session() << session() <<
Poco::format("INSERT INTO MiscTest VALUES (?,%s,?,?,?,?)", blobPlaceholder), Poco::format("INSERT INTO MiscTest VALUES (?,%s,?,?,?,?)", blobPlaceholder),
use(strings, bulk), use(strings, bulk),
use(blobs, bulk), use(blobs, bulk),
use(ints, bulk), use(ints, bulk),
use(floats, bulk), use(floats, bulk),
use(dateTimes, bulk), use(dateTimes, bulk),
@ -204,20 +204,20 @@ public:
floats.clear(); floats.clear();
dateTimes.clear(); dateTimes.clear();
bools.clear(); bools.clear();
try try
{ {
session() << "SELECT * FROM MiscTest ORDER BY Third", session() << "SELECT * FROM MiscTest ORDER BY Third",
into(strings), into(strings),
into(blobs), into(blobs),
into(ints), into(ints),
into(floats), into(floats),
into(dateTimes), into(dateTimes),
into(bools), into(bools),
now; now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
std::string number = Poco::NumberFormatter::format(size - 1); std::string number = Poco::NumberFormatter::format(size - 1);
assert (size == ints.size()); assert (size == ints.size());
assert (0 == ints.front()); assert (0 == ints.front());
@ -235,16 +235,16 @@ public:
ints.clear(); ints.clear();
try try
{ {
session() << "SELECT First FROM MiscTest", into(ints, bulk(size)), limit(size+1), now; session() << "SELECT First FROM MiscTest", into(ints, bulk(size)), limit(size+1), now;
fail ("must fail"); fail ("must fail");
} }
catch(Poco::InvalidArgumentException&){ } catch(Poco::InvalidArgumentException&){ }
try try
{ {
session() << "SELECT First FROM MiscTest", into(ints), bulk(size), now; session() << "SELECT First FROM MiscTest", into(ints), bulk(size), now;
fail ("must fail"); fail ("must fail");
} }
catch(Poco::InvalidAccessException&){ } catch(Poco::InvalidAccessException&){ }
@ -258,17 +258,17 @@ public:
dateTimes.clear(); dateTimes.clear();
bools.clear(); bools.clear();
bools.resize(size); bools.resize(size);
try try
{ {
session() << "SELECT First, Second, Third, Fourth, Fifth, Sixth FROM MiscTest ORDER BY Third", session() << "SELECT First, Second, Third, Fourth, Fifth, Sixth FROM MiscTest ORDER BY Third",
into(strings, bulk), into(strings, bulk),
into(blobs, bulk(size)), into(blobs, bulk(size)),
into(ints, bulk(size)), into(ints, bulk(size)),
into(floats, bulk), into(floats, bulk),
into(dateTimes, bulk(size)), into(dateTimes, bulk(size)),
into(bools, bulk), into(bools, bulk),
now; now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
@ -300,7 +300,7 @@ public:
C3 blobs; C3 blobs;
C4 floats; C4 floats;
C5 dateTimes(size); C5 dateTimes(size);
for (int i = 0; i < size; ++i) for (int i = 0; i < size; ++i)
{ {
ints.push_back(i); ints.push_back(i);
@ -309,11 +309,11 @@ public:
floats.push_back(i + .5); floats.push_back(i + .5);
} }
try try
{ {
session() << "INSERT INTO MiscTest VALUES (?,?,?,?,?)", session() << "INSERT INTO MiscTest VALUES (?,?,?,?,?)",
use(strings), use(strings),
use(blobs), use(blobs),
use(ints), use(ints),
use(floats), use(floats),
use(dateTimes), now; use(dateTimes), now;
@ -324,35 +324,35 @@ public:
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
try try
{ {
session() << "INSERT INTO MiscTest VALUES (?,?,?,?,?)", session() << "INSERT INTO MiscTest VALUES (?,?,?,?,?)",
use(strings, bulk), use(strings, bulk),
use(blobs, bulk), use(blobs, bulk),
use(ints, bulk), use(ints, bulk),
use(floats, bulk), use(floats, bulk),
use(dateTimes, bulk), now; use(dateTimes, bulk), now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
ints.clear(); ints.clear();
strings.clear(); strings.clear();
blobs.clear(); blobs.clear();
floats.clear(); floats.clear();
dateTimes.clear(); dateTimes.clear();
try try
{ {
session() << "SELECT * FROM MiscTest ORDER BY First", session() << "SELECT * FROM MiscTest ORDER BY First",
into(strings), into(strings),
into(blobs), into(blobs),
into(ints), into(ints),
into(floats), into(floats),
into(dateTimes), into(dateTimes),
now; now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
std::string number = Poco::NumberFormatter::format(size - 1); std::string number = Poco::NumberFormatter::format(size - 1);
assert (size == ints.size()); assert (size == ints.size());
assert (0 == ints.front()); assert (0 == ints.front());
@ -368,16 +368,16 @@ public:
ints.clear(); ints.clear();
try try
{ {
session() << "SELECT First FROM MiscTest", into(ints, bulk(size)), limit(size+1), now; session() << "SELECT First FROM MiscTest", into(ints, bulk(size)), limit(size+1), now;
fail ("must fail"); fail ("must fail");
} }
catch(Poco::InvalidArgumentException&){ } catch(Poco::InvalidArgumentException&){ }
try try
{ {
session() << "SELECT First FROM MiscTest", into(ints), bulk(size), now; session() << "SELECT First FROM MiscTest", into(ints), bulk(size), now;
fail ("must fail"); fail ("must fail");
} }
catch(Poco::InvalidAccessException&){ } catch(Poco::InvalidAccessException&){ }
@ -387,19 +387,19 @@ public:
blobs.clear(); blobs.clear();
floats.clear(); floats.clear();
dateTimes.clear(); dateTimes.clear();
try try
{ {
session() << "SELECT * FROM MiscTest ORDER BY First", session() << "SELECT * FROM MiscTest ORDER BY First",
into(strings, bulk(size)), into(strings, bulk(size)),
into(blobs, bulk(size)), into(blobs, bulk(size)),
into(ints, bulk(size)), into(ints, bulk(size)),
into(floats, bulk(size)), into(floats, bulk(size)),
into(dateTimes, bulk(size)), into(dateTimes, bulk(size)),
now; now;
} catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } } catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
assert (size == ints.size()); assert (size == ints.size());
assert (0 == ints.front()); assert (0 == ints.front());
assert (size - 1 == ints.back()); assert (size - 1 == ints.back());
@ -474,7 +474,7 @@ public:
void tupleVector(); void tupleVector();
void internalExtraction(); void internalExtraction();
void filter(const std::string& query = void filter(const std::string& query =
"SELECT * FROM Vectors ORDER BY int0 ASC", "SELECT * FROM Vectors ORDER BY int0 ASC",
const std::string& intFldName = "int0"); const std::string& intFldName = "int0");
@ -487,11 +487,11 @@ public:
void stdVectorBool(); void stdVectorBool();
void asynchronous(int rowCount = 500); void asynchronous(int rowCount = 500);
void any(); void any();
void dynamicAny(); void dynamicAny();
void multipleResults(const std::string& sql = void multipleResults(const std::string& sql =
"SELECT * FROM Person WHERE Age = ?; " "SELECT * FROM Person WHERE Age = ?; "
"SELECT Age FROM Person WHERE FirstName = 'Bart'; " "SELECT Age FROM Person WHERE FirstName = 'Bart'; "
"SELECT * FROM Person WHERE Age = ? OR Age = ? ORDER BY Age;"); "SELECT * FROM Person WHERE Age = ? OR Age = ? ORDER BY Age;");

Some files were not shown because too many files have changed in this diff Show More