openddl: latest greatest.

This commit is contained in:
Kim Kulling
2020-10-25 10:34:43 +01:00
parent 831af12974
commit 57e691e28e
21 changed files with 1940 additions and 1364 deletions

View File

@@ -1,7 +1,7 @@
/*-----------------------------------------------------------------------------------------------
The MIT License (MIT)
Copyright (c) 2014-2015 Kim Kulling
Copyright (c) 2014-2020 Kim Kulling
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
@@ -37,22 +37,22 @@ std::string StreamFormatterBase::format(const std::string &statement) {
return tmp;
}
IOStreamBase::IOStreamBase(StreamFormatterBase *formatter)
: m_formatter(formatter)
, m_file(ddl_nullptr) {
if (ddl_nullptr == m_formatter) {
IOStreamBase::IOStreamBase(StreamFormatterBase *formatter) :
m_formatter(formatter),
m_file(nullptr) {
if (nullptr == m_formatter) {
m_formatter = new StreamFormatterBase;
}
}
IOStreamBase::~IOStreamBase() {
delete m_formatter;
m_formatter = ddl_nullptr;
m_formatter = nullptr;
}
bool IOStreamBase::open(const std::string &name) {
m_file = ::fopen(name.c_str(), "a");
if (m_file == ddl_nullptr) {
if (m_file == nullptr) {
return false;
}
@@ -60,33 +60,33 @@ bool IOStreamBase::open(const std::string &name) {
}
bool IOStreamBase::close() {
if (ddl_nullptr == m_file) {
if (nullptr == m_file) {
return false;
}
::fclose(m_file);
m_file = ddl_nullptr;
m_file = nullptr;
return true;
}
bool IOStreamBase::isOpen() const {
return ( ddl_nullptr != m_file );
return (nullptr != m_file);
}
size_t IOStreamBase::read( size_t sizeToRead, std::string &statement ) {
if (ddl_nullptr == m_file) {
size_t IOStreamBase::read(size_t sizeToRead, std::string &statement) {
if (nullptr == m_file) {
return 0;
}
statement.resize(sizeToRead);
const size_t readBytes = ::fread( &statement[0], 1, sizeToRead, m_file );
const size_t readBytes = ::fread(&statement[0], 1, sizeToRead, m_file);
return readBytes;
}
size_t IOStreamBase::write(const std::string &statement) {
if (ddl_nullptr == m_file) {
if (nullptr == m_file) {
return 0;
}
std::string formatStatement = m_formatter->format(statement);