newer standards prefer nullptr over NULL - this is most of them but there are others too

This commit is contained in:
DarthArgus
2016-02-11 15:16:14 -06:00
parent a7f2d0ea6a
commit 3e4cc36e7e
937 changed files with 14983 additions and 14983 deletions
@@ -1,13 +1,13 @@
/* Bindable.h
*
* Defines classes based on built-in simple types that know how to bind themselves to
* database queries and support null values.
* database queries and support nullptr values.
*
* Each class supports the following functions:
* bool isNull -- test whether the value is null
* void setToNull -- set the value to null
* getValue -- return the value (make sure you test for null before calling this. The results
* are undefined if the Bindable is null.)
* bool isNull -- test whether the value is nullptr
* void setToNull -- set the value to nullptr
* getValue -- return the value (make sure you test for nullptr before calling this. The results
* are undefined if the Bindable is nullptr.)
* setValue -- set the value
*
* ODBC version
@@ -31,7 +31,7 @@ namespace DB {
explicit Bindable(int _indicator);
/**
* The size of the data, or -1 for NULL.
* The size of the data, or -1 for nullptr.
*/
int indicator;
};
@@ -18,7 +18,7 @@
namespace DB {
/** Represents a bool in C++, bound to a CHAR(1) column. The column can have the values 'Y' or 'N'.
* TODO: use a boolean type in the database, if we can find one that allows NULL's and is fairly
* TODO: use a boolean type in the database, if we can find one that allows nullptr's and is fairly
* portable. (May not exist -- according to the docs, Oracle does not have a boolean datatype.)
*/
class BindableBool : public Bindable
@@ -133,11 +133,11 @@ namespace DB
std::string getValueASCII() const;
/** Allocate a new string and copy the buffer to it. The caller takes responsibility
for delete[]ing it later. (If the string is NULL, this returns a null pointer.)
for delete[]ing it later. (If the string is nullptr, this returns a nullptr pointer.)
*/
char *makeCopyOfValue() const;
/** Set the value of the bindable string from another (null-terminated) string
/** Set the value of the bindable string from another (nullptr-terminated) string
If the source buffer is too big, it FATAL's. Another alternative would be to have
it truncate the string. Right now, it's better to FATAL to avoid hard-to-find bugs
@@ -168,7 +168,7 @@ namespace DB
private:
char m_value[S+1]; // column of size S, plus one byte for a trailing null
char m_value[S+1]; // column of size S, plus one byte for a trailing nullptr
};
// ======================================================================
@@ -206,7 +206,7 @@ namespace DB
{
if (isNull())
{
return strncpy(buffer,"\0",1); // in the database, a zero-length string and a NULL aren't really
return strncpy(buffer,"\0",1); // in the database, a zero-length string and a nullptr aren't really
// the same thing, but this is the closest we can do here.
}
return strncpy(buffer,m_value,(bufsize>(S+1))?(S+1):bufsize);
@@ -259,7 +259,7 @@ namespace DB
}
FATAL((i==S+1) && (m_value[S]!='\0'),("Attempt to save string \"%s\" to the database. It is too long for the column.",buffer));
indicator=i; // set indicator to actual length of string
// m_value[S]='\0'; // guarantee null terminator -- uncomment if you remove the above FATAL
// m_value[S]='\0'; // guarantee nullptr terminator -- uncomment if you remove the above FATAL
}
template<int S>
@@ -143,7 +143,7 @@ namespace DB
private:
char m_value[S+1]; // column of size S, plus one byte for a trailing null
char m_value[S+1]; // column of size S, plus one byte for a trailing nullptr
};
// ======================================================================
@@ -33,9 +33,9 @@ namespace DB
* Combines the values in this row with the values in newRow.
*
* For each column:
* If the column is null in newRow, do nothing. (Leave the value
* If the column is nullptr in newRow, do nothing. (Leave the value
* in this row unchanged.)
* If the column is not null in newRow, replace the value in this
* If the column is not nullptr in newRow, replace the value in this
* row with the value in newRow.
*/
virtual void combine(const DB::Row &newRow) =0;
@@ -29,7 +29,7 @@ using namespace DB;
Mutex Server::ms_profileMutex;
bool Server::ms_enableProfiling = false;
bool Server::ms_enableVerboseMode = false;
DB::Profiler *Server::ms_profiler = NULL;
DB::Profiler *Server::ms_profiler = nullptr;
int Server::ms_reconnectTime=0;
int Server::ms_maxErrorCountBeforeDisconnect=5;
int Server::ms_maxErrorCountBeforeBailout=10;
@@ -51,7 +51,7 @@ Server::SesListElem::SesListElem (Session *_ses, SesListElem *_next) : ses (_ses
// ----------------------------------------------------------------------
Server::Server(const char *_dsn, const char *_uid, const char *_pwd, bool useMemoryManager) :
sessionList (NULL),
sessionList (nullptr),
sessionListLock(),
m_useMemoryManager(useMemoryManager)
{
@@ -194,7 +194,7 @@ Session *Server::popSession()
else
{
sessionListLock.leave();
return NULL;
return nullptr;
}
}
@@ -294,7 +294,7 @@ void Server::endProfiling()
{
ms_profileMutex.enter();
delete ms_profiler;
ms_profiler = NULL;
ms_profiler = nullptr;
ms_enableProfiling = false;
ms_profileMutex.leave();
}
@@ -15,7 +15,7 @@
// ======================================================================
/**
* A unicode-string-compatible class that encodes a null value as a single space
* A unicode-string-compatible class that encodes a nullptr value as a single space
*/
class NullEncodedStandardString
{
@@ -15,7 +15,7 @@
// ======================================================================
/**
* A unicode-string-compatible class that encodes a null value as a single space
* A unicode-string-compatible class that encodes a nullptr value as a single space
*/
class NullEncodedUnicodeString
{
@@ -22,9 +22,9 @@ using namespace DB;
BindableVarray::BindableVarray() :
m_initialized(false),
m_tdo (NULL),
m_data (NULL),
m_session (NULL)
m_tdo (nullptr),
m_data (nullptr),
m_session (nullptr)
{
}
@@ -52,7 +52,7 @@ bool BindableVarray::create(DB::Session *session, const std::string &name, const
schema.length(),
reinterpret_cast<OraText*>(const_cast<char*>(name.c_str())),
name.length(),
NULL,
nullptr,
0,
OCI_DURATION_SESSION,
OCI_TYPEGET_HEADER,
@@ -64,7 +64,7 @@ bool BindableVarray::create(DB::Session *session, const std::string &name, const
localSession->errhp,
localSession->svchp,
OCI_TYPECODE_VARRAY,
m_tdo, NULL,
m_tdo, nullptr,
OCI_DURATION_DEFAULT,
true,
reinterpret_cast<void**>(&m_data)))))
@@ -86,9 +86,9 @@ void BindableVarray::free()
OCIObjectFree (localSession->envhp,
localSession->errhp, m_data, 0)));
m_initialized = false;
m_tdo=NULL;
m_data=NULL;
m_session=NULL;
m_tdo=nullptr;
m_data=nullptr;
m_session=nullptr;
}
// ----------------------------------------------------------------------
@@ -354,7 +354,7 @@ std::string BindableVarrayNumber::outputValue() const
if (exists)
{
if (*indicator == OCI_IND_NULL)
result += "NULL";
result += "nullptr";
else
{
double value;
@@ -400,7 +400,7 @@ bool BindableVarrayString::push_back(const Unicode::String &value)
bool BindableVarrayString::push_back(const std::string &value)
{
OCIString *buffer = NULL;
OCIString *buffer = nullptr;
OCIInd buffer_indicator (OCI_IND_NOTNULL);
OCISession *localSession = safe_cast<OCISession*>(m_session);
@@ -437,7 +437,7 @@ bool BindableVarrayString::push_back(bool bvalue)
else
value = "N";
OCIString *buffer = NULL;
OCIString *buffer = nullptr;
OCIInd buffer_indicator (OCI_IND_NOTNULL);
OCISession *localSession = safe_cast<OCISession*>(m_session);
@@ -469,7 +469,7 @@ bool BindableVarrayString::push_back(bool IsNULL, const Unicode::String &value)
bool BindableVarrayString::push_back(bool IsNULL, const std::string &value)
{
OCIString *buffer = NULL;
OCIString *buffer = nullptr;
OCIInd buffer_indicator;
if ( IsNULL )
{
@@ -515,7 +515,7 @@ bool BindableVarrayString::push_back(bool IsNULL, bool bvalue)
else
value = "N";
OCIString *buffer = NULL;
OCIString *buffer = nullptr;
OCIInd buffer_indicator;
if ( IsNULL )
{
@@ -568,14 +568,14 @@ std::string BindableVarrayString::outputValue() const
if (exists)
{
if (*indicator == OCI_IND_NULL)
result += "NULL";
result += "nullptr";
else
{
OraText * text = OCIStringPtr(localSession->envhp, *element);
if (text)
result += '"' + std::string(reinterpret_cast<char*>(text)) + '"';
else
result += "NULL";
result += "nullptr";
}
}
else
@@ -49,13 +49,13 @@ bool DB::OCIQueryImpl::setup(Session *session)
{
// setSession(session);
DEBUG_FATAL(m_session!=0,("m_session was not NULL"));
DEBUG_FATAL(m_server!=0,("m_server was not NULL"));
DEBUG_FATAL(m_session!=0,("m_session was not nullptr"));
DEBUG_FATAL(m_server!=0,("m_server was not nullptr"));
DEBUG_FATAL(m_stmthp!=0,("m_stmthp was not 0"));
DEBUG_FATAL(m_cursorhp!=0,("m_cursorhp was not 0"));
m_session=dynamic_cast<DB::OCISession*>(session);
FATAL((m_session==0),("Must pass a non-NULL OCISession to setup()."));
FATAL((m_session==0),("Must pass a non-nullptr OCISession to setup()."));
m_server=m_session->m_server;
NOT_NULL(m_server);
@@ -180,7 +180,7 @@ bool DB::OCIQueryImpl::exec()
m_session->setOkToFetch();
m_session->setLastQueryStatement(m_sql);
sword status=OCIStmtExecute(m_session->svchp, m_stmthp, m_session->errhp, 1, 0,
NULL, NULL, OCI_DEFAULT);
nullptr, nullptr, OCI_DEFAULT);
if (status == OCI_NO_DATA)
{
@@ -393,8 +393,8 @@ DB::OCIQueryImpl::BindRec::BindRec(size_t numElements) :
length(0),
stringAdjust(false),
m_numElements(numElements),
m_indicatorArray(NULL),
m_lengthArray(NULL)
m_indicatorArray(nullptr),
m_lengthArray(nullptr)
{
// This is ugly, but it avoids having to create two different kinds of bindrecs that inherit from an abstract base class
if (m_numElements > 1)
@@ -714,11 +714,11 @@ bool DB::OCIQueryImpl::bindParameter(BindableVarray &buffer)
&(br->bindp),
m_session->errhp,
nextParameter++,
NULL,
nullptr,
0,
SQLT_NTY,
NULL,
NULL,
nullptr,
nullptr,
0,
0,
0,
@@ -63,7 +63,7 @@ bool DB::OCIServer::checkerr(OCISession const & session, int status)
text errbuf[512];
sb4 errcode = 0;
OCIErrorGet((dvoid *)(session.errhp), (ub4) 1, (text *) NULL, &errcode,
OCIErrorGet((dvoid *)(session.errhp), (ub4) 1, (text *) nullptr, &errcode,
errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
WARNING(true,("Database error: %.*s",512,errbuf));
@@ -56,11 +56,11 @@ static void freeHook(dvoid *, dvoid *memptr)
DB::OCISession::OCISession(DB::OCIServer *server) :
m_server(server),
envhp(NULL),
errhp(NULL),
srvhp(NULL),
sesp(NULL),
svchp(NULL),
envhp(nullptr),
errhp(nullptr),
srvhp(nullptr),
sesp(nullptr),
svchp(nullptr),
autoCommitMode(true),
m_resetTime(server->getReconnectTime()==0 ? 0 : time(0) + server->getReconnectTime()),
m_okToFetch(true)
@@ -235,11 +235,11 @@ bool DB::OCISession::disconnect()
success = false;
}
svchp = NULL;
sesp = NULL;
srvhp = NULL;
errhp = NULL;
envhp = NULL;
svchp = nullptr;
sesp = nullptr;
srvhp = nullptr;
errhp = nullptr;
envhp = nullptr;
connectLock.leave();
return success;