Commit 1d6aa957 authored by Max Lyon's avatar Max Lyon

remove some c++11 features. intermediate commit.

parent 7d9f65ec
......@@ -28,8 +28,12 @@
#include "Base/Utils/OStringStream.hh"
#include <string>
#include <sstream>
#include <vector>
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#include <array>
#endif
namespace Debug {
......@@ -83,7 +87,7 @@ public:
public:
//! Constructor.
Stream(
const char* _flnm = nullptr, //!< [in] Filename if file based.
const char* _flnm = NULL, //!< [in] Filename if file based.
const uint _flags = APPEND //!< [in] bit-field type identifier
);
~Stream();
......@@ -147,8 +151,23 @@ extern void error(const std::string& _err, const ::Base::CodeLink& _lnk);
// ostream streamer to DEB_out a class as text without exploiting any
// numeric processing or custom Stream streamers then use this macro thus
// DEB_out(1, "my_class is " << DEB_os_str(my_c) )
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#define DEB_os_str(AA) \
dynamic_cast<std::ostringstream &&>((std::ostringstream() << AA )).str()
#else
namespace Debug
{
template <typename T>
std::string toString(const T& t)
{
std::ostringstream ss;
ss << t;
return ss.str();
}
}// namespace Debug
#define DEB_os_str(AA) \
Debug::toString(AA)
#endif
#endif // DEB_ON
......
......@@ -26,6 +26,10 @@
#define sprintf_s snprintf
#endif
#ifndef nullptr
#define nullptr NULL
#endif
namespace {
// TODO: make this use std::string; check for html extension; case insensitive
......@@ -85,7 +89,15 @@ void add_to_string(const Enter* _deb, std::string& _str,
if (!_with_counts)
_str.append("*");
else
{
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
_str.append(std::to_string(_deb->nmbr_));
#else
std::stringstream ss;
ss << _deb->nmbr_;
_str.append(ss.str());
#endif
}
_str.append("]");
}
......@@ -112,7 +124,7 @@ public:
const Enter* call(int _up = 0) const
{
auto num = calls_.size();
int num = calls_.size();
if (_up < num)
return calls_[num - 1 - _up];
else
......@@ -228,8 +240,8 @@ public:
char prev_char() const
{
if (!current_.empty()) return current_.back();
if (!output_.empty()) return output_.back();
if (!current_.empty()) return *current_.rbegin();
if (!output_.empty()) return *output_.rbegin();
return '\0';
}
......@@ -596,8 +608,9 @@ public:
int permission(const char* const _flnm)
{
int lev = lev_;
for (const auto& fltrs : level_selc_map_)
for (std::map<int, FilterLevelSelector>::const_iterator fltrs_it = level_selc_map_.begin(); fltrs_it != level_selc_map_.end(); ++fltrs_it)
{
const std::pair<int, FilterLevelSelector>& fltrs = *fltrs_it;
if (fltrs.second.select_file(_flnm) ||
fltrs.second.select_function(call_stack_.call()->fnct_))
{// continue this iteration until the maximum allowed level if found
......@@ -615,7 +628,7 @@ public:
void read_debug_config()
{
const auto flnm =
const std::string flnm =
System::Environment::variable("REFORM_DEB_CONFIG", "reform_deb.cfg");
std::ifstream deb_stream(flnm.c_str());
......@@ -664,7 +677,7 @@ private:
{
std::string flnm(_flnm);
const std::string root_dir("ReForm");
auto pos = flnm.rfind(root_dir);
size_t pos = flnm.rfind(root_dir);
if (pos != std::string::npos)
flnm = flnm.substr(pos + root_dir.size());
return search(flnm, file_selct_strngs_);
......@@ -679,8 +692,9 @@ private:
static bool search(const std::string& _flnm,
const std::list<std::string>& _sel_strings)
{
for (const auto& sel : _sel_strings)
for (std::list<std::string>::const_iterator sel_it = _sel_strings.begin(); sel_it != _sel_strings.end(); ++sel_it)
{
const std::string& sel = *sel_it;
if (_flnm.find(sel) != std::string::npos)
return true;
}
......
......@@ -5,7 +5,9 @@
#include <string>
#include <vector>
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#include <array>
#endif
namespace boost {
namespace filesystem {
......@@ -75,12 +77,16 @@ template< typename ElementT>
IOutputStream& operator<<(IOutputStream& _ds, const std::vector<ElementT>& _vec)
{
_ds << "[ ";
for (const auto el : _vec)
for (typename std::vector<ElementT>::const_iterator el_it = _vec.begin(); el_it != _vec.end(); ++el_it)
{
const ElementT el = *el_it;
_ds << el << " ";
}
_ds << "]";
return _ds;
}
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__))
// IStream operator for std::array<>
template< typename ElementT, size_t _el_nmbr>
IOutputStream& operator<<(IOutputStream& _ds,
......@@ -92,14 +98,15 @@ IOutputStream& operator<<(IOutputStream& _ds,
_ds << "]";
return _ds;
}
#endif
// IStream operator for fixed size arrays
template <typename ElementT, size_t _el_nmbr>
IOutputStream& operator<<(IOutputStream& _ds, const ElementT(&_arr)[_el_nmbr])
{
_ds << "[ ";
for (const auto el : _arr)
_ds << el << " ";
for (size_t i = 0; i < _el_nmbr; ++i)
_ds << _arr[i] << " ";
_ds << "]";
return _ds;
}
......@@ -124,9 +131,9 @@ public:
#else
OutputStreamAdaptT() {}
//TODO: get rid of move constructor, cannot submit C++11 code in Base for now
OutputStreamAdaptT(OutputStreamAdaptT&& _oth) : strm_(std::move(_oth.strm_))
{}
// //TODO: get rid of move constructor, cannot submit C++11 code in Base for now
// OutputStreamAdaptT(OutputStreamAdaptT&& _oth) : strm_(std::move(_oth.strm_))
// {}
template <typename ArgT>
OutputStreamAdaptT(const ArgT& _arg) : strm_(_arg) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment