AnalysisDataModuleInterface *module);
//! List of modules added to the data.
- ModuleList _modules;
+ ModuleList modules_;
//! true if all modules support missing data.
- bool _bAllowMissing;
+ bool bAllowMissing_;
//! Whether notifyDataStart() has been called.
- mutable bool _bDataStart;
+ mutable bool bDataStart_;
//! Whether new data is being added.
- mutable bool _bInData;
+ mutable bool bInData_;
//! Whether data for a frame is being added.
- mutable bool _bInFrame;
+ mutable bool bInFrame_;
//! Index of the currently active frame.
- mutable int _currIndex;
+ mutable int currIndex_;
/*! \brief
* Total number of frames in the data.
*
* The counter is incremented in notifyFrameFinish().
*/
- int _nframes;
+ int nframes_;
};
AbstractAnalysisData::Impl::Impl()
- : _bAllowMissing(true), _bDataStart(false), _bInData(false), _bInFrame(false),
- _currIndex(-1), _nframes(0)
+ : bAllowMissing_(true), bDataStart_(false), bInData_(false), bInFrame_(false),
+ currIndex_(-1), nframes_(0)
{
}
AnalysisDataModuleInterface *module)
{
module->dataStarted(data);
- bool bCheckMissing = _bAllowMissing
+ bool bCheckMissing = bAllowMissing_
&& !(module->flags() & AnalysisDataModuleInterface::efAllowMissing);
for (int i = 0; i < data->frameCount(); ++i)
{
module->pointsAdded(frame.points());
module->frameFinished(frame.header());
}
- if (!_bInData)
+ if (!bInData_)
{
module->dataFinished();
}
*/
/*! \cond libapi */
AbstractAnalysisData::AbstractAnalysisData()
- : _impl(new Impl()), _ncol(0), _bMultiPoint(false)
+ : impl_(new Impl()), columnCount_(0), bMultiPoint_(false)
{
}
//! \endcond
int
AbstractAnalysisData::frameCount() const
{
- return _impl->_nframes;
+ return impl_->nframes_;
}
GMX_THROW(APIError("Data module not compatible with data object properties"));
}
- if (_impl->_bDataStart)
+ if (impl_->bDataStart_)
{
- GMX_RELEASE_ASSERT(!_impl->_bInFrame,
+ GMX_RELEASE_ASSERT(!impl_->bInFrame_,
"Cannot add data modules in mid-frame");
- _impl->presentData(this, module.get());
+ impl_->presentData(this, module.get());
}
if (!(module->flags() & AnalysisDataModuleInterface::efAllowMissing))
{
- _impl->_bAllowMissing = false;
+ impl_->bAllowMissing_ = false;
}
- _impl->_modules.push_back(module);
+ impl_->modules_.push_back(module);
}
AbstractAnalysisData::addColumnModule(int col, int span,
AnalysisDataModulePointer module)
{
- GMX_RELEASE_ASSERT(col >= 0 && span >= 1 && col + span <= _ncol,
+ GMX_RELEASE_ASSERT(col >= 0 && span >= 1 && col + span <= columnCount_,
"Invalid columns specified for a column module");
- if (_impl->_bDataStart)
+ if (impl_->bDataStart_)
{
GMX_THROW(NotImplementedError("Cannot add column modules after data"));
}
{
GMX_THROW(APIError("Data module not compatible with data object properties"));
}
- GMX_RELEASE_ASSERT(_impl->_bDataStart && !_impl->_bInData,
+ GMX_RELEASE_ASSERT(impl_->bDataStart_ && !impl_->bInData_,
"Data module can only be applied to ready data");
- _impl->presentData(this, module);
+ impl_->presentData(this, module);
}
/*! \cond libapi */
void
-AbstractAnalysisData::setColumnCount(int ncol)
+AbstractAnalysisData::setColumnCount(int columnCount)
{
- GMX_RELEASE_ASSERT(ncol > 0, "Invalid data column count");
- GMX_RELEASE_ASSERT(_ncol == 0 || _impl->_modules.empty(),
+ GMX_RELEASE_ASSERT(columnCount > 0, "Invalid data column count");
+ GMX_RELEASE_ASSERT(columnCount_ == 0 || impl_->modules_.empty(),
"Data column count cannot be changed after modules are added");
- GMX_RELEASE_ASSERT(!_impl->_bDataStart,
+ GMX_RELEASE_ASSERT(!impl_->bDataStart_,
"Data column count cannot be changed after data has been added");
- _ncol = ncol;
+ columnCount_ = columnCount;
}
void
AbstractAnalysisData::setMultipoint(bool multipoint)
{
- GMX_RELEASE_ASSERT(_impl->_modules.empty(),
+ GMX_RELEASE_ASSERT(impl_->modules_.empty(),
"Data type cannot be changed after modules are added");
- GMX_RELEASE_ASSERT(!_impl->_bDataStart,
+ GMX_RELEASE_ASSERT(!impl_->bDataStart_,
"Data type cannot be changed after data has been added");
- _bMultiPoint = multipoint;
+ bMultiPoint_ = multipoint;
}
void
AbstractAnalysisData::notifyDataStart()
{
- GMX_RELEASE_ASSERT(!_impl->_bDataStart,
+ GMX_RELEASE_ASSERT(!impl_->bDataStart_,
"notifyDataStart() called more than once");
- GMX_RELEASE_ASSERT(_ncol > 0, "Data column count is not set");
- _impl->_bDataStart = _impl->_bInData = true;
+ GMX_RELEASE_ASSERT(columnCount_ > 0, "Data column count is not set");
+ impl_->bDataStart_ = impl_->bInData_ = true;
Impl::ModuleList::const_iterator i;
- for (i = _impl->_modules.begin(); i != _impl->_modules.end(); ++i)
+ for (i = impl_->modules_.begin(); i != impl_->modules_.end(); ++i)
{
- if (_ncol > 1 && !((*i)->flags() & AnalysisDataModuleInterface::efAllowMulticolumn))
+ if (columnCount_ > 1 && !((*i)->flags() & AnalysisDataModuleInterface::efAllowMulticolumn))
{
GMX_THROW(APIError("Data module not compatible with data object properties"));
}
void
AbstractAnalysisData::notifyFrameStart(const AnalysisDataFrameHeader &header) const
{
- GMX_ASSERT(_impl->_bInData, "notifyDataStart() not called");
- GMX_ASSERT(!_impl->_bInFrame,
+ GMX_ASSERT(impl_->bInData_, "notifyDataStart() not called");
+ GMX_ASSERT(!impl_->bInFrame_,
"notifyFrameStart() called while inside a frame");
- GMX_ASSERT(header.index() == _impl->_nframes,
+ GMX_ASSERT(header.index() == impl_->nframes_,
"Out of order frames");
- _impl->_bInFrame = true;
- _impl->_currIndex = header.index();
+ impl_->bInFrame_ = true;
+ impl_->currIndex_ = header.index();
Impl::ModuleList::const_iterator i;
- for (i = _impl->_modules.begin(); i != _impl->_modules.end(); ++i)
+ for (i = impl_->modules_.begin(); i != impl_->modules_.end(); ++i)
{
(*i)->frameStarted(header);
}
void
AbstractAnalysisData::notifyPointsAdd(const AnalysisDataPointSetRef &points) const
{
- GMX_ASSERT(_impl->_bInData, "notifyDataStart() not called");
- GMX_ASSERT(_impl->_bInFrame, "notifyFrameStart() not called");
+ GMX_ASSERT(impl_->bInData_, "notifyDataStart() not called");
+ GMX_ASSERT(impl_->bInFrame_, "notifyFrameStart() not called");
GMX_ASSERT(points.lastColumn() < columnCount(), "Invalid columns");
- GMX_ASSERT(points.frameIndex() == _impl->_currIndex,
+ GMX_ASSERT(points.frameIndex() == impl_->currIndex_,
"Points do not correspond to current frame");
- if (!_impl->_bAllowMissing && !points.allPresent())
+ if (!impl_->bAllowMissing_ && !points.allPresent())
{
GMX_THROW(APIError("Missing data not supported by a module"));
}
Impl::ModuleList::const_iterator i;
- for (i = _impl->_modules.begin(); i != _impl->_modules.end(); ++i)
+ for (i = impl_->modules_.begin(); i != impl_->modules_.end(); ++i)
{
(*i)->pointsAdded(points);
}
void
AbstractAnalysisData::notifyFrameFinish(const AnalysisDataFrameHeader &header)
{
- GMX_ASSERT(_impl->_bInData, "notifyDataStart() not called");
- GMX_ASSERT(_impl->_bInFrame, "notifyFrameStart() not called");
- GMX_ASSERT(header.index() == _impl->_currIndex,
+ GMX_ASSERT(impl_->bInData_, "notifyDataStart() not called");
+ GMX_ASSERT(impl_->bInFrame_, "notifyFrameStart() not called");
+ GMX_ASSERT(header.index() == impl_->currIndex_,
"Header does not correspond to current frame");
- _impl->_bInFrame = false;
- _impl->_currIndex = -1;
+ impl_->bInFrame_ = false;
+ impl_->currIndex_ = -1;
// Increment the counter before notifications to allow frame access from
// modules.
- ++_impl->_nframes;
+ ++impl_->nframes_;
Impl::ModuleList::const_iterator i;
- for (i = _impl->_modules.begin(); i != _impl->_modules.end(); ++i)
+ for (i = impl_->modules_.begin(); i != impl_->modules_.end(); ++i)
{
(*i)->frameFinished(header);
}
void
AbstractAnalysisData::notifyDataFinish() const
{
- GMX_RELEASE_ASSERT(_impl->_bInData, "notifyDataStart() not called");
- GMX_RELEASE_ASSERT(!_impl->_bInFrame,
+ GMX_RELEASE_ASSERT(impl_->bInData_, "notifyDataStart() not called");
+ GMX_RELEASE_ASSERT(!impl_->bInFrame_,
"notifyDataFinish() called while inside a frame");
- _impl->_bInData = false;
+ impl_->bInData_ = false;
Impl::ModuleList::const_iterator i;
- for (i = _impl->_modules.begin(); i != _impl->_modules.end(); ++i)
+ for (i = impl_->modules_.begin(); i != impl_->modules_.end(); ++i)
{
(*i)->dataFinished();
}
*
* Does not throw.
*/
- bool isMultipoint() const { return _bMultiPoint; }
+ bool isMultipoint() const { return bMultiPoint_; }
/*! \brief
* Returns the number of columns in the data.
*
*
* Does not throw.
*/
- int columnCount() const { return _ncol; }
+ int columnCount() const { return columnCount_; }
/*! \brief
* Returns the total number of frames in the data.
*
/*! \brief
* Sets the number of columns.
*
- * \param[in] ncol Number of columns in the data (must be > 0).
+ * \param[in] columnCount Number of columns in the data (must be > 0).
*
* Can be called only before notifyDataStart(), otherwise asserts.
* Multiple calls are only allowed if all of them occur before
*
* \see columnCount()
*/
- void setColumnCount(int ncol);
+ void setColumnCount(int columnCount);
/*! \brief
* Sets whether the data has multiple points per column in a frame.
*
private:
class Impl;
- PrivateImplPointer<Impl> _impl;
- int _ncol;
- bool _bMultiPoint;
+ PrivateImplPointer<Impl> impl_;
+ int columnCount_;
+ bool bMultiPoint_;
/*! \brief
* Needed to provide access to notification methods.
{
AbstractAnalysisArrayData::AbstractAnalysisArrayData()
- : _nrows(0), _xstart(0.0), _xstep(1.0), _bReady(false)
+ : rowCount_(0), xstart_(0.0), xstep_(1.0), bReady_(false)
{
}
return AnalysisDataFrameRef();
}
std::vector<AnalysisDataValue>::const_iterator begin
- = _value.begin() + index * columnCount();
+ = value_.begin() + index * columnCount();
return AnalysisDataFrameRef(
AnalysisDataFrameHeader(index, xvalue(index), 0.0),
AnalysisDataValuesRef(begin, begin + columnCount()));
void
-AbstractAnalysisArrayData::setRowCount(int nrows)
+AbstractAnalysisArrayData::setRowCount(int rowCount)
{
- GMX_RELEASE_ASSERT(nrows > 0, "Invalid number of rows");
+ GMX_RELEASE_ASSERT(rowCount > 0, "Invalid number of rows");
GMX_RELEASE_ASSERT(!isAllocated(),
"Cannot change row count after data has been allocated");
- _nrows = nrows;
+ rowCount_ = rowCount;
}
GMX_RELEASE_ASSERT(!isAllocated(), "Can only allocate values once");
GMX_RELEASE_ASSERT(rowCount() > 0 && columnCount() > 0,
"Row and column counts must be set before allocating values");
- _value.resize(rowCount() * columnCount());
+ value_.resize(rowCount() * columnCount());
std::vector<AnalysisDataValue>::iterator i;
- for (i = _value.begin(); i != _value.end(); ++i)
+ for (i = value_.begin(); i != value_.end(); ++i)
{
i->setValue(0.0);
}
void
AbstractAnalysisArrayData::setXAxis(real start, real step)
{
- GMX_RELEASE_ASSERT(!_bReady, "X axis cannot be set after data is finished");
- _xstart = start;
- _xstep = step;
+ GMX_RELEASE_ASSERT(!bReady_, "X axis cannot be set after data is finished");
+ xstart_ = start;
+ xstep_ = step;
}
AbstractAnalysisArrayData::valuesReady()
{
GMX_RELEASE_ASSERT(isAllocated(), "There must be some data");
- if (_bReady)
+ if (bReady_)
{
return;
}
- _bReady = true;
+ bReady_ = true;
- std::vector<AnalysisDataValue>::const_iterator valueIter = _value.begin();
+ std::vector<AnalysisDataValue>::const_iterator valueIter = value_.begin();
notifyDataStart();
for (int i = 0; i < rowCount(); ++i, valueIter += columnCount())
{
dest->setRowCount(src->rowCount());
dest->allocateValues();
dest->setXAxis(src->xstart(), src->xstep());
- std::copy(src->_value.begin(), src->_value.end(), dest->_value.begin());
+ std::copy(src->value_.begin(), src->value_.end(), dest->value_.begin());
}
} // namespace gmx
* This function is identical to frameCount(), except that frameCount()
* returns 0 before valuesReady() has been called.
*/
- int rowCount() const { return _nrows; }
+ int rowCount() const { return rowCount_; }
//! Returns true if values have been allocated.
- bool isAllocated() const { return !_value.empty(); }
+ bool isAllocated() const { return !value_.empty(); }
//! Returns the x value of the first frame.
- real xstart() const { return _xstart; }
+ real xstart() const { return xstart_; }
//! Returns the step between frame x values.
- real xstep() const { return _xstep; }
+ real xstep() const { return xstep_; }
//! Returns the x value of a row.
real xvalue(int row) const
{
GMX_ASSERT(row >= 0 && row < rowCount(), "Row index out of range");
GMX_ASSERT(col >= 0 && col < columnCount(), "Column index out of range");
GMX_ASSERT(isAllocated(), "Data array not allocated");
- return _value[row * columnCount() + col].value();
+ return value_[row * columnCount() + col].value();
}
protected:
/*! \brief
* Sets the number of rows in the data array.
*
- * \param[in] nrows Number of rows in the data.
+ * \param[in] rowCount Number of rows in the data.
*
* Cannot be called after allocateValues().
*
* Does not throw.
*/
- void setRowCount(int nrows);
+ void setRowCount(int rowCount);
/*! \brief
* Allocates memory for the values.
*
GMX_ASSERT(row >= 0 && row < rowCount(), "Row index out of range");
GMX_ASSERT(col >= 0 && col < columnCount(), "Column index out of range");
GMX_ASSERT(isAllocated(), "Data array not allocated");
- return _value[row * columnCount() + col].value();
+ return value_[row * columnCount() + col].value();
}
/*! \brief
* Sets the value of an element in the array.
virtual AnalysisDataFrameRef tryGetDataFrameInternal(int index) const;
virtual bool requestStorageInternal(int nframes);
- int _nrows;
- std::vector<AnalysisDataValue> _value;
- real _xstart;
- real _xstep;
- bool _bReady;
+ int rowCount_;
+ std::vector<AnalysisDataValue> value_;
+ real xstart_;
+ real xstep_;
+ bool bReady_;
// Copy and assign disallowed by base.
};
namespace gmx
{
-AnalysisDataProxy::AnalysisDataProxy(int col, int span,
+AnalysisDataProxy::AnalysisDataProxy(int firstColumn, int columnSpan,
AbstractAnalysisData *data)
- : _source(*data), _col(col), _span(span)
+ : source_(*data), firstColumn_(firstColumn), columnSpan_(columnSpan)
{
GMX_RELEASE_ASSERT(data, "Source data must not be NULL");
- GMX_RELEASE_ASSERT(col >= 0 && span > 0, "Invalid proxy column");
- setColumnCount(span);
- setMultipoint(_source.isMultipoint());
+ GMX_RELEASE_ASSERT(firstColumn >= 0 && columnSpan > 0, "Invalid proxy column");
+ setColumnCount(columnSpan);
+ setMultipoint(source_.isMultipoint());
}
AnalysisDataFrameRef
AnalysisDataProxy::tryGetDataFrameInternal(int index) const
{
- AnalysisDataFrameRef frame = _source.tryGetDataFrame(index);
+ AnalysisDataFrameRef frame = source_.tryGetDataFrame(index);
if (!frame.isValid())
{
return AnalysisDataFrameRef();
}
- return AnalysisDataFrameRef(frame, _col, _span);
+ return AnalysisDataFrameRef(frame, firstColumn_, columnSpan_);
}
bool
AnalysisDataProxy::requestStorageInternal(int nframes)
{
- return _source.requestStorage(nframes);
+ return source_.requestStorage(nframes);
}
void
AnalysisDataProxy::dataStarted(AbstractAnalysisData *data)
{
- GMX_RELEASE_ASSERT(data == &_source, "Source data mismatch");
- GMX_RELEASE_ASSERT(_col + _span <= _source.columnCount(),
+ GMX_RELEASE_ASSERT(data == &source_, "Source data mismatch");
+ GMX_RELEASE_ASSERT(firstColumn_ + columnSpan_ <= source_.columnCount(),
"Invalid column(s) specified");
notifyDataStart();
}
void
AnalysisDataProxy::pointsAdded(const AnalysisDataPointSetRef &points)
{
- AnalysisDataPointSetRef columns(points, _col, _span);
+ AnalysisDataPointSetRef columns(points, firstColumn_, columnSpan_);
if (columns.columnCount() > 0)
{
notifyPointsAdd(columns);
/*! \brief
* Creates a proxy object that only presents certain columns.
*
- * \param[in] col First column to present.
- * \param[in] span Number of columns to present.
- * \param[in] data Data object that should be wrapped.
+ * \param[in] firstColumn First column to present.
+ * \param[in] columnSpan Number of columns to present.
+ * \param[in] data Data object that should be wrapped.
*
* Does not throw.
*/
- AnalysisDataProxy(int col, int span, AbstractAnalysisData *data);
+ AnalysisDataProxy(int firstColumn, int columnSpan,
+ AbstractAnalysisData *data);
virtual int flags() const;
virtual AnalysisDataFrameRef tryGetDataFrameInternal(int index) const;
virtual bool requestStorageInternal(int nframes);
- AbstractAnalysisData &_source;
- int _col;
- int _span;
+ AbstractAnalysisData &source_;
+ int firstColumn_;
+ int columnSpan_;
// Copy and assign disallowed by base.
};
void closeFile();
- AnalysisDataPlotSettings settings;
- std::string fnm;
- FILE *fp;
-
- bool bPlain;
- bool bOmitX;
- std::string title;
- std::string subtitle;
- std::string xlabel;
- std::string ylabel;
- std::vector<std::string> leg;
- char xfmt[15];
- char yfmt[15];
- real xscale;
+ AnalysisDataPlotSettings settings_;
+ std::string filename_;
+ FILE *fp_;
+
+ bool bPlain_;
+ bool gOmitX_;
+ std::string title_;
+ std::string subtitle_;
+ std::string xlabel_;
+ std::string ylabel_;
+ std::vector<std::string> legend_;
+ char xformat_[15];
+ char yformat_[15];
+ real xscale_;
};
AbstractPlotModule::Impl::Impl(const AnalysisDataPlotSettings &settings)
- : settings(settings), fp(NULL), bPlain(false), bOmitX(false), xscale(1.0)
+ : settings_(settings), fp_(NULL), bPlain_(false), gOmitX_(false),
+ xscale_(1.0)
{
- strcpy(xfmt, "%11.3f");
- strcpy(yfmt, " %8.3f");
+ strcpy(xformat_, "%11.3f");
+ strcpy(yformat_, " %8.3f");
}
AbstractPlotModule::Impl::~Impl()
void
AbstractPlotModule::Impl::closeFile()
{
- if (fp != NULL)
+ if (fp_ != NULL)
{
- if (bPlain)
+ if (bPlain_)
{
- gmx_fio_fclose(fp);
+ gmx_fio_fclose(fp_);
}
else
{
- xvgrclose(fp);
+ xvgrclose(fp_);
}
- fp = NULL;
+ fp_ = NULL;
}
}
*/
/*! \cond libapi */
AbstractPlotModule::AbstractPlotModule()
- : _impl(new Impl(AnalysisDataPlotSettings()))
+ : impl_(new Impl(AnalysisDataPlotSettings()))
{
}
AbstractPlotModule::AbstractPlotModule(const AnalysisDataPlotSettings &settings)
- : _impl(new Impl(settings))
+ : impl_(new Impl(settings))
{
}
//! \endcond
void
AbstractPlotModule::setSettings(const AnalysisDataPlotSettings &settings)
{
- _impl->settings = settings;
+ impl_->settings_ = settings;
}
void
-AbstractPlotModule::setFileName(const std::string &fnm)
+AbstractPlotModule::setFileName(const std::string &filename)
{
- _impl->fnm = fnm;
+ impl_->filename_ = filename;
}
void
AbstractPlotModule::setPlainOutput(bool bPlain)
{
- _impl->bPlain = bPlain;
+ impl_->bPlain_ = bPlain;
}
void
AbstractPlotModule::setOmitX(bool bOmitX)
{
- _impl->bOmitX = bOmitX;
+ impl_->gOmitX_ = bOmitX;
}
void
AbstractPlotModule::setTitle(const char *title)
{
- _impl->title = title;
+ impl_->title_ = title;
}
void
AbstractPlotModule::setSubtitle(const char *subtitle)
{
- _impl->subtitle = subtitle;
+ impl_->subtitle_ = subtitle;
}
void
AbstractPlotModule::setXLabel(const char *label)
{
- _impl->xlabel = label;
+ impl_->xlabel_ = label;
}
void
AbstractPlotModule::setXAxisIsTime()
{
- TimeUnitManager manager(_impl->settings.timeUnit());
- _impl->xlabel = formatString("Time (%s)", manager.timeUnitAsString());
- _impl->xscale = manager.inverseTimeScaleFactor();
+ TimeUnitManager manager(impl_->settings_.timeUnit());
+ impl_->xlabel_ = formatString("Time (%s)", manager.timeUnitAsString());
+ impl_->xscale_ = manager.inverseTimeScaleFactor();
}
void
AbstractPlotModule::setYLabel(const char *label)
{
- _impl->ylabel = label;
+ impl_->ylabel_ = label;
}
void
AbstractPlotModule::setLegend(int nsets, const char * const *setname)
{
- _impl->leg.reserve(_impl->leg.size() + nsets);
+ impl_->legend_.reserve(impl_->legend_.size() + nsets);
for (int i = 0; i < nsets; ++i)
{
appendLegend(setname[i]);
void
AbstractPlotModule::appendLegend(const char *setname)
{
- _impl->leg.push_back(setname);
+ impl_->legend_.push_back(setname);
}
void
-AbstractPlotModule::setXFormat(int width, int prec, char fmt)
+AbstractPlotModule::setXFormat(int width, int precision, char format)
{
- GMX_RELEASE_ASSERT(width >= 0 && prec >= 0 && width <= 99 && prec <= 99,
+ GMX_RELEASE_ASSERT(width >= 0 && precision >= 0
+ && width <= 99 && precision <= 99,
"Invalid width or precision");
- GMX_RELEASE_ASSERT(strchr("eEfFgG", fmt) != NULL,
+ GMX_RELEASE_ASSERT(strchr("eEfFgG", format) != NULL,
"Invalid format specifier");
- sprintf(_impl->xfmt, "%%%d.%d%c", width, prec, fmt);
+ sprintf(impl_->xformat_, "%%%d.%d%c", width, precision, format);
}
void
-AbstractPlotModule::setYFormat(int width, int prec, char fmt)
+AbstractPlotModule::setYFormat(int width, int precision, char format)
{
- GMX_RELEASE_ASSERT(width >= 0 && prec >= 0 && width <= 99 && prec <= 99,
+ GMX_RELEASE_ASSERT(width >= 0 && precision >= 0
+ && width <= 99 && precision <= 99,
"Invalid width or precision");
- GMX_RELEASE_ASSERT(strchr("eEfFgG", fmt) != NULL,
+ GMX_RELEASE_ASSERT(strchr("eEfFgG", format) != NULL,
"Invalid format specifier");
- sprintf(_impl->yfmt, " %%%d.%d%c", width, prec, fmt);
+ sprintf(impl_->yformat_, " %%%d.%d%c", width, precision, format);
}
void
AbstractPlotModule::dataStarted(AbstractAnalysisData *data)
{
- if (!_impl->fnm.empty())
+ if (!impl_->filename_.empty())
{
- if (_impl->bPlain)
+ if (impl_->bPlain_)
{
- _impl->fp = gmx_fio_fopen(_impl->fnm.c_str(), "w");
+ impl_->fp_ = gmx_fio_fopen(impl_->filename_.c_str(), "w");
}
else
{
time_unit_t time_unit
- = static_cast<time_unit_t>(_impl->settings.timeUnit() + 1);
+ = static_cast<time_unit_t>(impl_->settings_.timeUnit() + 1);
xvg_format_t xvg_format
- = (_impl->settings.plotFormat() > 0
- ? static_cast<xvg_format_t>(_impl->settings.plotFormat())
+ = (impl_->settings_.plotFormat() > 0
+ ? static_cast<xvg_format_t>(impl_->settings_.plotFormat())
: exvgNONE);
output_env_t oenv;
output_env_init(&oenv, 0, NULL, time_unit, FALSE, xvg_format, 0, 0);
boost::shared_ptr<output_env> oenvGuard(oenv, &output_env_done);
- _impl->fp = xvgropen(_impl->fnm.c_str(), _impl->title.c_str(),
- _impl->xlabel.c_str(), _impl->ylabel.c_str(),
- oenv);
+ impl_->fp_ = xvgropen(impl_->filename_.c_str(), impl_->title_.c_str(),
+ impl_->xlabel_.c_str(), impl_->ylabel_.c_str(),
+ oenv);
const SelectionCollection *selections
- = _impl->settings.selectionCollection();
+ = impl_->settings_.selectionCollection();
if (selections != NULL)
{
- selections->printXvgrInfo(_impl->fp, oenv);
+ selections->printXvgrInfo(impl_->fp_, oenv);
}
- if (!_impl->subtitle.empty())
+ if (!impl_->subtitle_.empty())
{
- xvgr_subtitle(_impl->fp, _impl->subtitle.c_str(), oenv);
+ xvgr_subtitle(impl_->fp_, impl_->subtitle_.c_str(), oenv);
}
if (output_env_get_print_xvgr_codes(oenv)
- && !_impl->leg.empty())
+ && !impl_->legend_.empty())
{
- std::vector<const char *> leg;
- leg.reserve(_impl->leg.size());
- for (size_t i = 0; i < _impl->leg.size(); ++i)
+ std::vector<const char *> legend;
+ legend.reserve(impl_->legend_.size());
+ for (size_t i = 0; i < impl_->legend_.size(); ++i)
{
- leg.push_back(_impl->leg[i].c_str());
+ legend.push_back(impl_->legend_[i].c_str());
}
- xvgr_legend(_impl->fp, leg.size(), &leg[0], oenv);
+ xvgr_legend(impl_->fp_, legend.size(), &legend[0], oenv);
}
}
}
{
return;
}
- if (!_impl->bOmitX)
+ if (!impl_->gOmitX_)
{
- std::fprintf(_impl->fp, _impl->xfmt, frame.x() * _impl->xscale);
+ std::fprintf(impl_->fp_, impl_->xformat_, frame.x() * impl_->xscale_);
}
}
{
return;
}
- std::fprintf(_impl->fp, "\n");
+ std::fprintf(impl_->fp_, "\n");
}
void
AbstractPlotModule::dataFinished()
{
- _impl->closeFile();
+ impl_->closeFile();
}
/*! \cond libapi */
bool
AbstractPlotModule::isFileOpen() const
{
- return _impl->fp != NULL;
+ return impl_->fp_ != NULL;
}
AbstractPlotModule::writeValue(real value) const
{
GMX_ASSERT(isFileOpen(), "File not opened, but write attempted");
- std::fprintf(_impl->fp, _impl->yfmt, value);
+ std::fprintf(impl_->fp_, impl_->yformat_, value);
}
//! \endcond
{
for (int i = 0; i < DIM; ++i)
{
- _bWrite[i] = true;
+ bWrite_[i] = true;
}
- _bWrite[DIM] = false;
+ bWrite_[DIM] = false;
}
{
for (int i = 0; i < DIM; ++i)
{
- _bWrite[i] = true;
+ bWrite_[i] = true;
}
- _bWrite[DIM] = false;
+ bWrite_[DIM] = false;
}
void
AnalysisDataVectorPlotModule::setWriteX(bool bWrite)
{
- _bWrite[XX] = bWrite;
+ bWrite_[XX] = bWrite;
}
void
AnalysisDataVectorPlotModule::setWriteY(bool bWrite)
{
- _bWrite[YY] = bWrite;
+ bWrite_[YY] = bWrite;
}
void
AnalysisDataVectorPlotModule::setWriteZ(bool bWrite)
{
- _bWrite[ZZ] = bWrite;
+ bWrite_[ZZ] = bWrite;
}
void
AnalysisDataVectorPlotModule::setWriteNorm(bool bWrite)
{
- _bWrite[DIM] = bWrite;
+ bWrite_[DIM] = bWrite;
}
{
for (int i = 0; i < DIM + 1; ++i)
{
- _bWrite[i] = bWrite[i];
+ bWrite_[i] = bWrite[i];
}
}
{
for (int d = 0; d < DIM; ++d)
{
- if (_bWrite[i])
+ if (bWrite_[i])
{
writeValue(points.y(i + d));
}
}
- if (_bWrite[DIM])
+ if (bWrite_[DIM])
{
rvec y = { points.y(i), points.y(i + 1), points.y(i + 2) };
writeValue(norm(y));
/*! \brief
* Set the output file name.
*
- * If no file name is set (or if \p fnm is NULL), no output occurs.
+ * If no file name is set (or if \p filename is empty), no output occurs.
*/
- void setFileName(const std::string &fnm);
+ void setFileName(const std::string &filename);
/*! \brief
* Set plain output.
*
/*! \brief
* Set field width and precision for X value output.
*/
- void setXFormat(int width, int prec, char fmt = 'f');
+ void setXFormat(int width, int precision, char format = 'f');
/*! \brief
* Set field width and precision for Y value output.
*/
- void setYFormat(int width, int prec, char fmt = 'f');
+ void setYFormat(int width, int precision, char format = 'f');
virtual int flags() const;
private:
class Impl;
- PrivateImplPointer<Impl> _impl;
+ PrivateImplPointer<Impl> impl_;
};
virtual void pointsAdded(const AnalysisDataPointSetRef &points);
private:
- bool _bWrite[4];
+ bool bWrite_[4];
// Copy and assign disallowed by base.
};
explicit Impl(Options *options);
//! Helper object for assigning the options.
- OptionsAssigner _assigner;
+ OptionsAssigner assigner_;
};
CommandLineParser::Impl::Impl(Options *options)
- : _assigner(options)
+ : assigner_(options)
{
- _assigner.setAcceptBooleanNoPrefix(true);
- _assigner.setNoStrictSectioning(true);
+ assigner_.setAcceptBooleanNoPrefix(true);
+ assigner_.setNoStrictSectioning(true);
}
/********************************************************************
*/
CommandLineParser::CommandLineParser(Options *options)
- : _impl(new Impl(options))
+ : impl_(new Impl(options))
{
}
// Start in the discard phase to skip options that can't be understood.
bool bDiscard = true;
- _impl->_assigner.start();
+ impl_->assigner_.start();
std::vector<std::string>::const_iterator arg;
for (arg = commandLine->begin() + 1; arg != commandLine->end(); ++arg)
{
{
try
{
- _impl->_assigner.finishOption();
+ impl_->assigner_.finishOption();
}
catch (const UserInputError &ex)
{
try
{
const char *name = arg->c_str() + 1;
- _impl->_assigner.startOption(name);
+ impl_->assigner_.startOption(name);
}
catch (const UserInputError &ex)
{
{
try
{
- _impl->_assigner.appendValue(*arg);
+ impl_->assigner_.appendValue(*arg);
}
catch (const UserInputError &ex)
{
{
try
{
- _impl->_assigner.finishOption();
+ impl_->assigner_.finishOption();
}
catch (const UserInputError &ex)
{
}
errors.finishContext();
}
- _impl->_assigner.finish();
+ impl_->assigner_.finish();
if (!errors.isEmpty())
{
// TODO: This exception type may not always be appropriate.
private:
class Impl;
- PrivateImplPointer<Impl> _impl;
+ PrivateImplPointer<Impl> impl_;
};
} // namespace gmx
public:
CommandLineParserTest();
- gmx::Options _options;
- gmx::CommandLineParser _parser;
- bool _flag;
- std::vector<int> _ivalues;
- std::vector<double> _dvalues;
+ gmx::Options options_;
+ gmx::CommandLineParser parser_;
+ bool flag_;
+ std::vector<int> ivalues_;
+ std::vector<double> dvalues_;
};
CommandLineParserTest::CommandLineParserTest()
- : _options(NULL, NULL), _parser(&_options),
- _flag(false)
+ : options_(NULL, NULL), parser_(&options_),
+ flag_(false)
{
using gmx::BooleanOption;
using gmx::IntegerOption;
using gmx::DoubleOption;
- _options.addOption(BooleanOption("flag").store(&_flag));
- _options.addOption(IntegerOption("mvi").storeVector(&_ivalues).multiValue());
- _options.addOption(DoubleOption("mvd").storeVector(&_dvalues).allowMultiple());
+ options_.addOption(BooleanOption("flag").store(&flag_));
+ options_.addOption(IntegerOption("mvi").storeVector(&ivalues_).multiValue());
+ options_.addOption(DoubleOption("mvd").storeVector(&dvalues_).allowMultiple());
}
TEST_F(CommandLineParserTest, HandlesSingleValues)
"test", "-flag", "yes", "-mvi", "2", "-mvd", "2.7"
};
CommandLine args(CommandLine::create(cmdline));
- ASSERT_NO_THROW(_parser.parse(&args.argc(), args.argv()));
- ASSERT_NO_THROW(_options.finish());
+ ASSERT_NO_THROW(parser_.parse(&args.argc(), args.argv()));
+ ASSERT_NO_THROW(options_.finish());
- EXPECT_TRUE(_flag);
- ASSERT_EQ(1U, _ivalues.size());
- EXPECT_EQ(2, _ivalues[0]);
- ASSERT_EQ(1U, _dvalues.size());
- EXPECT_DOUBLE_EQ(2.7, _dvalues[0]);
+ EXPECT_TRUE(flag_);
+ ASSERT_EQ(1U, ivalues_.size());
+ EXPECT_EQ(2, ivalues_[0]);
+ ASSERT_EQ(1U, dvalues_.size());
+ EXPECT_DOUBLE_EQ(2.7, dvalues_[0]);
}
TEST_F(CommandLineParserTest, HandlesNegativeNumbers)
"test", "-mvi", "1", "-2", "-mvd", "-2.7"
};
CommandLine args(CommandLine::create(cmdline));
- ASSERT_NO_THROW(_parser.parse(&args.argc(), args.argv()));
- ASSERT_NO_THROW(_options.finish());
+ ASSERT_NO_THROW(parser_.parse(&args.argc(), args.argv()));
+ ASSERT_NO_THROW(options_.finish());
- ASSERT_EQ(2U, _ivalues.size());
- EXPECT_EQ(1, _ivalues[0]);
- EXPECT_EQ(-2, _ivalues[1]);
- ASSERT_EQ(1U, _dvalues.size());
- EXPECT_DOUBLE_EQ(-2.7, _dvalues[0]);
+ ASSERT_EQ(2U, ivalues_.size());
+ EXPECT_EQ(1, ivalues_[0]);
+ EXPECT_EQ(-2, ivalues_[1]);
+ ASSERT_EQ(1U, dvalues_.size());
+ EXPECT_DOUBLE_EQ(-2.7, dvalues_[0]);
}
} // namespace
AbstractOptionStorage::AbstractOptionStorage(const AbstractOption &settings,
OptionFlags staticFlags)
- : _flags(settings._flags | staticFlags),
- _minValueCount(settings._minValueCount),
- _maxValueCount(settings._maxValueCount),
- _inSet(false)
+ : flags_(settings.flags_ | staticFlags),
+ minValueCount_(settings.minValueCount_),
+ maxValueCount_(settings.maxValueCount_),
+ inSet_(false)
{
// If the maximum number of values is not known, storage to
// caller-allocated memory is unsafe.
- if ((_maxValueCount < 0 || hasFlag(efMulti)) && hasFlag(efExternalStore))
+ if ((maxValueCount_ < 0 || hasFlag(efMulti)) && hasFlag(efExternalStore))
{
GMX_THROW(APIError("Cannot set user-allocated storage for arbitrary number of values"));
}
// Check that user has not provided incorrect values for vectors.
- if (hasFlag(efVector) && (_minValueCount > 1 || _maxValueCount < 1))
+ if (hasFlag(efVector) && (minValueCount_ > 1 || maxValueCount_ < 1))
{
GMX_THROW(APIError("Inconsistent value counts for vector values"));
}
- if (settings._name != NULL)
+ if (settings.name_ != NULL)
{
- _name = settings._name;
+ name_ = settings.name_;
}
- _descr = settings.createDescription();
+ descr_ = settings.createDescription();
}
AbstractOptionStorage::~AbstractOptionStorage()
void AbstractOptionStorage::startSet()
{
- GMX_RELEASE_ASSERT(!_inSet, "finishSet() not called");
+ GMX_RELEASE_ASSERT(!inSet_, "finishSet() not called");
// The last condition takes care of the situation where multiple
// sources are used, and a later source should be able to reassign
// the value even though the option is already set.
GMX_THROW(InvalidInputError("Option specified multiple times"));
}
clearSet();
- _inSet = true;
+ inSet_ = true;
}
void AbstractOptionStorage::appendValue(const std::string &value)
{
- GMX_RELEASE_ASSERT(_inSet, "startSet() not called");
+ GMX_RELEASE_ASSERT(inSet_, "startSet() not called");
convertValue(value);
}
void AbstractOptionStorage::finishSet()
{
- GMX_RELEASE_ASSERT(_inSet, "startSet() not called");
- _inSet = false;
+ GMX_RELEASE_ASSERT(inSet_, "startSet() not called");
+ inSet_ = false;
// TODO: Should this be done only when processSet() does not throw?
setFlag(efSet);
processSet();
void AbstractOptionStorage::finish()
{
- GMX_RELEASE_ASSERT(!_inSet, "finishSet() not called");
+ GMX_RELEASE_ASSERT(!inSet_, "finishSet() not called");
processAll();
if (hasFlag(efRequired) && !isSet())
{
GMX_RELEASE_ASSERT(!hasFlag(efMulti),
"setMinValueCount() not supported with efMulti");
GMX_RELEASE_ASSERT(count >= 0, "Invalid value count");
- _minValueCount = count;
+ minValueCount_ = count;
if (isSet()
- && !hasFlag(efDontCheckMinimumCount) && valueCount() < _minValueCount)
+ && !hasFlag(efDontCheckMinimumCount) && valueCount() < minValueCount_)
{
GMX_THROW(InvalidInputError("Too few values"));
}
GMX_RELEASE_ASSERT(!hasFlag(efMulti),
"setMaxValueCount() not supported with efMulti");
GMX_RELEASE_ASSERT(count >= -1, "Invalid value count");
- _maxValueCount = count;
- if (isSet() && _maxValueCount >= 0 && valueCount() > _maxValueCount)
+ maxValueCount_ = count;
+ if (isSet() && maxValueCount_ >= 0 && valueCount() > maxValueCount_)
{
GMX_THROW(InvalidInputError("Too many values"));
}
/*! \cond libapi */
//! Initializes the name and default values for an option.
explicit AbstractOption(const char *name)
- : _minValueCount(1), _maxValueCount(1),
- _name(name), _descr(NULL)
+ : minValueCount_(1), maxValueCount_(1),
+ name_(name), descr_(NULL)
{ }
/*! \brief
* description.
*/
virtual std::string createDescription() const
- { return _descr ? _descr : ""; }
+ { return descr_ ? descr_ : ""; }
//! Sets the description for the option.
- void setDescription(const char *descr) { _descr = descr; }
+ void setDescription(const char *descr) { descr_ = descr; }
//! Sets a flag for the option.
- void setFlag(OptionFlag flag) { _flags.set(flag); }
+ void setFlag(OptionFlag flag) { flags_.set(flag); }
//! Clears a flag for the option.
- void clearFlag(OptionFlag flag) { _flags.clear(flag); }
+ void clearFlag(OptionFlag flag) { flags_.clear(flag); }
//! Sets or clears a flag for the option.
- void setFlag(OptionFlag flag, bool bSet) { _flags.set(flag, bSet); }
+ void setFlag(OptionFlag flag, bool bSet) { flags_.set(flag, bSet); }
//! Returns true if the option is vector-valued.
bool isVector() const { return hasFlag(efVector); }
//! Sets the option to be vector-valued.
void setVector()
{
setFlag(efVector);
- _minValueCount = 1;
- if (_maxValueCount == 1)
+ minValueCount_ = 1;
+ if (maxValueCount_ == 1)
{
- _maxValueCount = 3;
+ maxValueCount_ = 3;
}
}
//! Sets the required number of values for the option.
{
if (!hasFlag(efVector))
{
- _minValueCount = count;
+ minValueCount_ = count;
}
- _maxValueCount = count;
+ maxValueCount_ = count;
}
//! Minimum number of values required for the option.
- int _minValueCount;
+ int minValueCount_;
//! Maximum number of values allowed for the option.
- int _maxValueCount;
+ int maxValueCount_;
//! \endcond
private:
//! Returns true if a flag has been set.
- bool hasFlag(OptionFlag flag) const { return _flags.test(flag); }
+ bool hasFlag(OptionFlag flag) const { return flags_.test(flag); }
- const char *_name;
+ const char *name_;
//! Pointer to description of the option.
- const char *_descr;
- OptionFlags _flags;
+ const char *descr_;
+ OptionFlags flags_;
/*! \brief
* Needed to initialize an AbstractOptionStorage object from this class
//! Requires exactly \p count values for the option.
MyClass &valueCount(int count) { setValueCount(count); return me(); }
//! Allows any number of values for the option.
- MyClass &multiValue() { _maxValueCount = -1; return me(); }
+ MyClass &multiValue() { maxValueCount_ = -1; return me(); }
/*! \brief
* Sets a default value for the option.
* \p defaultValue is copied when the option is created.
*/
MyClass &defaultValue(const T &defaultValue)
- { _defaultValue = &defaultValue; return me(); }
+ { defaultValue_ = &defaultValue; return me(); }
/*! \brief
* Sets a default value for the option when it is set.
*
* \p defaultValue is copied when the option is created.
*/
MyClass &defaultValueIfSet(const T &defaultValue)
- { _defaultValueIfSet = &defaultValue; return me(); }
+ { defaultValueIfSet_ = &defaultValue; return me(); }
/*! \brief
* Stores value(s) in memory pointed by \p store.
*
* Options object exists.
*/
MyClass &store(T *store)
- { setFlag(efExternalStore); _store = store; return me(); }
+ { setFlag(efExternalStore); store_ = store; return me(); }
/*! \brief
* Stores number of values in the value pointed by \p countptr.
*
* Options object exists.
*/
MyClass &storeCount(int *countptr)
- { _countptr = countptr; return me(); }
+ { countptr_ = countptr; return me(); }
/*! \brief
* Stores option values in the provided vector.
*
* Options object exists.
*/
MyClass &storeVector(std::vector<T> *store)
- { setFlag(efExternalValueVector); _storeVector = store; return me(); }
+ { setFlag(efExternalValueVector); storeVector_ = store; return me(); }
protected:
/*! \cond libapi */
//! Initializes the name and default values for an option.
explicit OptionTemplate(const char *name)
: AbstractOption(name),
- _defaultValue(NULL), _defaultValueIfSet(NULL), _store(NULL),
- _countptr(NULL), _storeVector(NULL)
+ defaultValue_(NULL), defaultValueIfSet_(NULL), store_(NULL),
+ countptr_(NULL), storeVector_(NULL)
{ }
/*! \brief
* Returns a pointer to user-specified default value, or NULL if there
* is none.
*/
- const T *defaultValue() const { return _defaultValue; }
+ const T *defaultValue() const { return defaultValue_; }
/*! \brief
* Returns a pointer to user-specified default value, or NULL if there
* is none.
*/
- const T *defaultValueIfSet() const { return _defaultValueIfSet; }
+ const T *defaultValueIfSet() const { return defaultValueIfSet_; }
//! Returns \p *this casted into MyClass to reduce typing.
MyClass &me() { return static_cast<MyClass &>(*this); }
//! \endcond
private:
- const T *_defaultValue;
- const T *_defaultValueIfSet;
- T *_store;
- int *_countptr;
- std::vector<T> *_storeVector;
+ const T *defaultValue_;
+ const T *defaultValueIfSet_;
+ T *store_;
+ int *countptr_;
+ std::vector<T> *storeVector_;
/*! \brief
* Needed to initialize storage from this class without otherwise
//! Returns true if the option is required.
bool isRequired() const { return hasFlag(efRequired); }
//! Returns the name of the option.
- const std::string &name() const { return _name; }
+ const std::string &name() const { return name_; }
//! Returns the description of the option.
- const std::string &description() const { return _descr; }
+ const std::string &description() const { return descr_; }
/*! \brief
* Returns an option info object corresponding to this option.
OptionFlags staticFlags);
//! Returns true if the given flag is set.
- bool hasFlag(OptionFlag flag) const { return _flags.test(flag); }
+ bool hasFlag(OptionFlag flag) const { return flags_.test(flag); }
//! Sets the given flag.
- void setFlag(OptionFlag flag) { return _flags.set(flag); }
+ void setFlag(OptionFlag flag) { return flags_.set(flag); }
//! Clears the given flag.
- void clearFlag(OptionFlag flag) { return _flags.clear(flag); }
+ void clearFlag(OptionFlag flag) { return flags_.clear(flag); }
//! Returns the minimum number of values required in one set.
- int minValueCount() const { return _minValueCount; }
+ int minValueCount() const { return minValueCount_; }
//! Returns the maximum allowed number of values in one set (-1 = no limit).
- int maxValueCount() const { return _maxValueCount; }
+ int maxValueCount() const { return maxValueCount_; }
/*! \brief
* Sets a new minimum number of values required in one set.
*
virtual void processAll() = 0;
private:
- std::string _name;
- std::string _descr;
+ std::string name_;
+ std::string descr_;
//! Flags for the option.
- OptionFlags _flags;
+ OptionFlags flags_;
//! Minimum number of values required (in one set).
- int _minValueCount;
+ int minValueCount_;
//! Maximum allowed number of values (in one set), or -1 if no limit.
- int _maxValueCount;
+ int maxValueCount_;
//! Whether we are currently assigning values to a set.
- bool _inSet;
+ bool inSet_;
GMX_DISALLOW_COPY_AND_ASSIGN(AbstractOptionStorage);
};
*/
DoubleOptionStorage::DoubleOptionStorage(const DoubleOption &settings)
- : MyBase(settings), info_(this), bTime_(settings._bTime), factor_(1.0)
+ : MyBase(settings), info_(this), bTime_(settings.bTime_), factor_(1.0)
{
}
*/
StringOptionStorage::StringOptionStorage(const StringOption &settings)
- : MyBase(settings), _info(this), _enumIndexStore(NULL)
+ : MyBase(settings), info_(this), enumIndexStore_(NULL)
{
- if (settings._defaultEnumIndex >= 0 && settings._enumValues == NULL)
+ if (settings.defaultEnumIndex_ >= 0 && settings.enumValues_ == NULL)
{
GMX_THROW(APIError("Cannot set default enum index without enum values"));
}
- if (settings._enumIndexStore != NULL && settings._enumValues == NULL)
+ if (settings.enumIndexStore_ != NULL && settings.enumValues_ == NULL)
{
GMX_THROW(APIError("Cannot set enum index store without enum values"));
}
- if (settings._enumIndexStore != NULL && settings._maxValueCount < 0)
+ if (settings.enumIndexStore_ != NULL && settings.maxValueCount_ < 0)
{
GMX_THROW(APIError("Cannot set enum index store with arbitrary number of values"));
}
- if (settings._enumValues != NULL)
+ if (settings.enumValues_ != NULL)
{
- _enumIndexStore = settings._enumIndexStore;
+ enumIndexStore_ = settings.enumIndexStore_;
const std::string *defaultValue = settings.defaultValue();
int match = -1;
- for (int i = 0; settings._enumValues[i] != NULL; ++i)
+ for (int i = 0; settings.enumValues_[i] != NULL; ++i)
{
- if (defaultValue != NULL && settings._enumValues[i] == *defaultValue)
+ if (defaultValue != NULL && settings.enumValues_[i] == *defaultValue)
{
match = i;
}
- _allowed.push_back(settings._enumValues[i]);
+ allowed_.push_back(settings.enumValues_[i]);
}
if (defaultValue != NULL)
{
GMX_THROW(APIError("Default value is not one of allowed values"));
}
}
- if (settings._defaultEnumIndex >= 0)
+ if (settings.defaultEnumIndex_ >= 0)
{
- if (settings._defaultEnumIndex >= static_cast<int>(_allowed.size()))
+ if (settings.defaultEnumIndex_ >= static_cast<int>(allowed_.size()))
{
GMX_THROW(APIError("Default enumeration index is out of range"));
}
- if (defaultValue != NULL && *defaultValue != _allowed[settings._defaultEnumIndex])
+ if (defaultValue != NULL && *defaultValue != allowed_[settings.defaultEnumIndex_])
{
GMX_THROW(APIError("Conflicting default values"));
}
}
// If there is no default value, match is still -1.
- if (_enumIndexStore != NULL)
+ if (enumIndexStore_ != NULL)
{
- *_enumIndexStore = match;
+ *enumIndexStore_ = match;
}
}
- if (settings._defaultEnumIndex >= 0)
+ if (settings.defaultEnumIndex_ >= 0)
{
clear();
- addValue(_allowed[settings._defaultEnumIndex]);
+ addValue(allowed_[settings.defaultEnumIndex_]);
commitValues();
}
}
void StringOptionStorage::convertValue(const std::string &value)
{
- if (_allowed.size() == 0)
+ if (allowed_.size() == 0)
{
addValue(value);
}
else
{
ValueList::const_iterator i;
- ValueList::const_iterator match = _allowed.end();
- for (i = _allowed.begin(); i != _allowed.end(); ++i)
+ ValueList::const_iterator match = allowed_.end();
+ for (i = allowed_.begin(); i != allowed_.end(); ++i)
{
// TODO: Case independence.
if (i->find(value) == 0)
{
- if (match == _allowed.end() || i->size() < match->size())
+ if (match == allowed_.end() || i->size() < match->size())
{
match = i;
}
}
}
- if (match == _allowed.end())
+ if (match == allowed_.end())
{
GMX_THROW(InvalidInputError("Invalid value: " + value));
}
void StringOptionStorage::refreshValues()
{
MyBase::refreshValues();
- if (_enumIndexStore != NULL)
+ if (enumIndexStore_ != NULL)
{
for (size_t i = 0; i < values().size(); ++i)
{
ValueList::const_iterator match =
- std::find(_allowed.begin(), _allowed.end(), values()[i]);
- GMX_ASSERT(match != _allowed.end(),
+ std::find(allowed_.begin(), allowed_.end(), values()[i]);
+ GMX_ASSERT(match != allowed_.end(),
"Enum value not found (internal error)");
- _enumIndexStore[i] = static_cast<int>(match - _allowed.begin());
+ enumIndexStore_[i] = static_cast<int>(match - allowed_.begin());
}
}
}
{
std::string value(MyBase::createDescription());
- if (_enumValues != NULL)
+ if (enumValues_ != NULL)
{
value.append(": ");
- for (int i = 0; _enumValues[i] != NULL; ++i)
+ for (int i = 0; enumValues_[i] != NULL; ++i)
{
- value.append(_enumValues[i]);
- if (_enumValues[i + 1] != NULL)
+ value.append(enumValues_[i]);
+ if (enumValues_[i + 1] != NULL)
{
- value.append(_enumValues[i + 2] != NULL ? ", " : ", or ");
+ value.append(enumValues_[i + 2] != NULL ? ", " : ", or ");
}
}
}
{
public:
//! Initializes an option with the given name.
- explicit DoubleOption(const char *name) : MyBase(name), _bTime(false)
+ explicit DoubleOption(const char *name) : MyBase(name), bTime_(false)
{
}
* user-provided values are scaled according to the time unit set in
* TimeUnitManager.
*/
- MyClass &timeValue() { _bTime = true; return me(); }
+ MyClass &timeValue() { bTime_ = true; return me(); }
private:
//! Creates a DoubleOptionStorage object.
virtual AbstractOptionStoragePointer createStorage() const;
- bool _bTime;
+ bool bTime_;
/*! \brief
* Needed to initialize DoubleOptionStorage from this class without
public:
//! Initializes an option with the given name.
explicit StringOption(const char *name)
- : MyBase(name), _enumValues(NULL), _defaultEnumIndex(-1),
- _enumIndexStore(NULL)
+ : MyBase(name), enumValues_(NULL), defaultEnumIndex_(-1),
+ enumIndexStore_(NULL)
{
}
* The strings are copied once the option is created.
*/
MyClass &enumValue(const char *const *values)
- { _enumValues = values; return me(); }
+ { enumValues_ = values; return me(); }
/*! \brief
* Sets the default value using an index into the enumeration table.
*
MyClass &defaultEnumIndex(int index)
{
GMX_RELEASE_ASSERT(index >= 0, "Invalid enumeration index");
- _defaultEnumIndex = index;
+ defaultEnumIndex_ = index;
return me();
}
/*! \brief
* Cannot be specified without enumValue().
*/
MyClass &storeEnumIndex(int *store)
- { _enumIndexStore = store; return me(); }
+ { enumIndexStore_ = store; return me(); }
private:
//! Creates a StringOptionStorage object.
virtual AbstractOptionStoragePointer createStorage() const;
virtual std::string createDescription() const;
- const char *const *_enumValues;
- int _defaultEnumIndex;
- int *_enumIndexStore;
+ const char *const *enumValues_;
+ int defaultEnumIndex_;
+ int *enumIndexStore_;
/*! \brief
* Needed to initialize StringOptionStorage from this class without
//! \copydoc DoubleOptionStorage::DoubleOptionStorage()
explicit StringOptionStorage(const StringOption &settings);
- virtual OptionInfo &optionInfo() { return _info; }
- virtual const char *typeString() const { return _allowed.empty() ? "string" : "enum"; }
+ virtual OptionInfo &optionInfo() { return info_; }
+ virtual const char *typeString() const { return allowed_.empty() ? "string" : "enum"; }
virtual std::string formatSingleValue(const std::string &value) const;
private:
virtual void convertValue(const std::string &value);
virtual void refreshValues();
- StringOptionInfo _info;
- ValueList _allowed;
- int *_enumIndexStore;
+ StringOptionInfo info_;
+ ValueList allowed_;
+ int *enumIndexStore_;
};
/*!\}*/
void startSource();
//! Name for the Options object.
- std::string _name;
+ std::string name_;
//! Description title for the Options object.
- std::string _title;
+ std::string title_;
//! Full description for the Options object.
- std::string _description;
+ std::string description_;
/*! \brief
* List of subsections, in insertion order.
*
* This container contains only references to external objects; memory
* management is performed elsewhere.
*/
- SubSectionList _subSections;
+ SubSectionList subSections_;
/*! \brief
* List of options, in insertion order.
*
* All objects in this container are owned by this object, and are
* freed in the destructor.
*/
- OptionList _options;
+ OptionList options_;
//! Options object that contains this object as a subsection, or NULL.
- Options *_parent;
+ Options *parent_;
};
} // namespace gmx
*/
Options::Impl::Impl(const char *name, const char *title)
- : _name(name != NULL ? name : ""), _title(title != NULL ? title : ""),
- _parent(NULL)
+ : name_(name != NULL ? name : ""), title_(title != NULL ? title : ""),
+ parent_(NULL)
{
}
Options *Options::Impl::findSubSection(const char *name) const
{
SubSectionList::const_iterator i;
- for (i = _subSections.begin(); i != _subSections.end(); ++i)
+ for (i = subSections_.begin(); i != subSections_.end(); ++i)
{
if ((*i)->name() == name)
{
AbstractOptionStorage *Options::Impl::findOption(const char *name) const
{
OptionList::const_iterator i;
- for (i = _options.begin(); i != _options.end(); ++i)
+ for (i = options_.begin(); i != options_.end(); ++i)
{
if ((*i)->name() == name)
{
void Options::Impl::startSource()
{
OptionList::const_iterator i;
- for (i = _options.begin(); i != _options.end(); ++i)
+ for (i = options_.begin(); i != options_.end(); ++i)
{
AbstractOptionStorage &option = **i;
option.startSource();
}
SubSectionList::const_iterator j;
- for (j = _subSections.begin(); j != _subSections.end(); ++j)
+ for (j = subSections_.begin(); j != subSections_.end(); ++j)
{
Options §ion = **j;
- section._impl->startSource();
+ section.impl_->startSource();
}
}
*/
Options::Options(const char *name, const char *title)
- : _impl(new Impl(name, title))
+ : impl_(new Impl(name, title))
{
}
const std::string &Options::name() const
{
- return _impl->_name;
+ return impl_->name_;
}
const std::string &Options::title() const
{
- return _impl->_title;
+ return impl_->title_;
}
const std::string &Options::description() const
{
- return _impl->_description;
+ return impl_->description_;
}
void Options::setDescription(const std::string &desc)
{
- _impl->_description = desc;
+ impl_->description_ = desc;
}
void Options::addSubSection(Options *section)
{
// Make sure that section is not already inserted somewhere.
- GMX_RELEASE_ASSERT(section->_impl->_parent == NULL,
+ GMX_RELEASE_ASSERT(section->impl_->parent_ == NULL,
"Cannot add as subsection twice");
// Make sure that there are no duplicate sections.
- GMX_RELEASE_ASSERT(_impl->findSubSection(section->name().c_str()) == NULL,
+ GMX_RELEASE_ASSERT(impl_->findSubSection(section->name().c_str()) == NULL,
"Duplicate subsection name");
- _impl->_subSections.push_back(section);
- section->_impl->_parent = this;
+ impl_->subSections_.push_back(section);
+ section->impl_->parent_ = this;
}
void Options::addOption(const AbstractOption &settings)
{
AbstractOptionStoragePointer option(settings.createStorage());
- if (_impl->findOption(option->name().c_str()) != NULL)
+ if (impl_->findOption(option->name().c_str()) != NULL)
{
GMX_THROW(APIError("Duplicate option: " + option->name()));
}
- _impl->_options.push_back(move(option));
+ impl_->options_.push_back(move(option));
}
bool Options::isSet(const char *name) const
{
- AbstractOptionStorage *option = _impl->findOption(name);
+ AbstractOptionStorage *option = impl_->findOption(name);
return (option != NULL ? option->isSet() : false);
}
{
MessageStringCollector errors;
Impl::OptionList::const_iterator i;
- for (i = _impl->_options.begin(); i != _impl->_options.end(); ++i)
+ for (i = impl_->options_.begin(); i != impl_->options_.end(); ++i)
{
AbstractOptionStorage &option = **i;
try
}
}
Impl::SubSectionList::const_iterator j;
- for (j = _impl->_subSections.begin(); j != _impl->_subSections.end(); ++j)
+ for (j = impl_->subSections_.begin(); j != impl_->subSections_.end(); ++j)
{
Options §ion = **j;
try
private:
class Impl;
- PrivateImplPointer<Impl> _impl;
+ PrivateImplPointer<Impl> impl_;
//! Needed to be able to extend the interface of this object.
friend class OptionsAssigner;
class OptionsAssigner::Impl
{
public:
- //! Possible flags for controlling assignment behavior.
- enum Flag
- {
- //! Recognize boolean option "name" also as "noname".
- efAcceptBooleanNoPrefix = 1<<0,
- //! Look for options in all sections, not just the current one.
- efNoStrictSectioning = 1<<1,
- };
//! Sets the option object to assign to.
- Impl(Options *options);
-
- //! Sets or clears the given flag.
- void setFlag(Flag flag, bool bSet);
+ explicit Impl(Options *options);
- //! Returns true if the given flag is set.
- bool hasFlag(Flag flag) const { return _flags & flag; }
//! Returns true if a subsection has been set.
- bool inSubSection() const { return _sectionStack.size() > 1; }
+ bool inSubSection() const { return sectionStack_.size() > 1; }
//! Returns the Options object for the current section.
- Options ¤tSection() const { return *_sectionStack.back(); }
+ Options ¤tSection() const { return *sectionStack_.back(); }
/*! \brief
* Finds an option by the given name.
*
AbstractOptionStorage *findOption(const char *name);
//! Options object to assign to.
- Options &_options;
- //! Flags that control assignment behavior.
- unsigned long _flags;
+ Options &options_;
+ //! Recognize boolean option "name" also as "noname".
+ bool bAcceptBooleanNoPrefix_;
+ //! Look for options in all sections, not just the current one.
+ bool bNoStrictSectioning_;
/*! \brief
* List of (sub)sections being assigned to.
*
- * The first element always points to \a _options.
+ * The first element always points to \a options_.
*/
- std::vector<Options *> _sectionStack;
+ std::vector<Options *> sectionStack_;
//! Current option being assigned to, or NULL if none.
- AbstractOptionStorage *_currentOption;
- //! Number of values assigned so far to the current option.
- int _currentValueCount;
+ AbstractOptionStorage *currentOption_;
+ /*! \brief
+ * Number of values assigned so far to the current option.
+ *
+ * Counts the number of attempted assignments, whether they have been
+ * successful or not.
+ */
+ int currentValueCount_;
//! If true, a "no" prefix was given for the current boolean option.
- bool _reverseBoolean;
+ bool reverseBoolean_;
};
OptionsAssigner::Impl::Impl(Options *options)
- : _options(*options), _flags(0), _currentOption(NULL),
- _currentValueCount(0), _reverseBoolean(false)
-{
- _sectionStack.push_back(&_options);
-}
-
-void OptionsAssigner::Impl::setFlag(OptionsAssigner::Impl::Flag flag, bool bSet)
+ : options_(*options), bAcceptBooleanNoPrefix_(false),
+ bNoStrictSectioning_(false), currentOption_(NULL),
+ currentValueCount_(0), reverseBoolean_(false)
{
- if (bSet)
- {
- _flags |= flag;
- }
- else
- {
- _flags &= ~flag;
- }
+ sectionStack_.push_back(&options_);
}
AbstractOptionStorage *
OptionsAssigner::Impl::findOption(const char *name)
{
- GMX_RELEASE_ASSERT(_currentOption == NULL,
+ GMX_RELEASE_ASSERT(currentOption_ == NULL,
"Cannot search for another option while processing one");
AbstractOptionStorage *option = NULL;
Options *section = NULL;
while (option == NULL && !searchList.empty())
{
section = searchList.front();
- option = section->_impl->findOption(name);
- if (option == NULL && hasFlag(efAcceptBooleanNoPrefix))
+ option = section->impl_->findOption(name);
+ if (option == NULL && bAcceptBooleanNoPrefix_)
{
if (name[0] == 'n' && name[1] == 'o')
{
- option = section->_impl->findOption(name + 2);
+ option = section->impl_->findOption(name + 2);
if (option != NULL && option->isBoolean())
{
- _reverseBoolean = true;
+ reverseBoolean_ = true;
}
else
{
}
}
searchList.pop_front();
- if (hasFlag(efNoStrictSectioning))
+ if (bNoStrictSectioning_)
{
Options::Impl::SubSectionList::const_iterator i;
- for (i = section->_impl->_subSections.begin();
- i != section->_impl->_subSections.end(); ++i)
+ for (i = section->impl_->subSections_.begin();
+ i != section->impl_->subSections_.end(); ++i)
{
if (*i != oldRoot)
{
searchList.push_back(*i);
}
}
- if (searchList.empty() && root != &_options)
+ if (searchList.empty() && root != &options_)
{
- root = root->_impl->_parent;
+ root = root->impl_->parent_;
++upcount;
searchList.push_back(root);
}
}
}
- if (hasFlag(efNoStrictSectioning) && option != NULL)
+ if (bNoStrictSectioning_ && option != NULL)
{
while (upcount > 0)
{
- _sectionStack.pop_back();
+ sectionStack_.pop_back();
--upcount;
}
std::vector<Options *> sections;
while (section != ¤tSection())
{
sections.push_back(section);
- section = section->_impl->_parent;
+ section = section->impl_->parent_;
}
while (!sections.empty())
{
- _sectionStack.push_back(sections.back());
+ sectionStack_.push_back(sections.back());
sections.pop_back();
}
}
*/
OptionsAssigner::OptionsAssigner(Options *options)
- : _impl(new Impl(options))
+ : impl_(new Impl(options))
{
}
{
}
-void OptionsAssigner::setAcceptBooleanNoPrefix(bool enabled)
+void OptionsAssigner::setAcceptBooleanNoPrefix(bool bEnabled)
{
- _impl->setFlag(Impl::efAcceptBooleanNoPrefix, enabled);
+ impl_->bAcceptBooleanNoPrefix_ = bEnabled;
}
-void OptionsAssigner::setNoStrictSectioning(bool enabled)
+void OptionsAssigner::setNoStrictSectioning(bool bEnabled)
{
- _impl->setFlag(Impl::efNoStrictSectioning, enabled);
+ impl_->bNoStrictSectioning_ = bEnabled;
}
void OptionsAssigner::start()
{
- _impl->_options._impl->startSource();
+ impl_->options_.impl_->startSource();
}
void OptionsAssigner::startSubSection(const char *name)
{
- Options *section = _impl->currentSection()._impl->findSubSection(name);
+ Options *section = impl_->currentSection().impl_->findSubSection(name);
if (section == NULL)
{
GMX_THROW(InvalidInputError("Unknown subsection"));
}
- _impl->_sectionStack.push_back(section);
+ impl_->sectionStack_.push_back(section);
}
void OptionsAssigner::startOption(const char *name)
{
- GMX_RELEASE_ASSERT(_impl->_currentOption == NULL, "finishOption() not called");
- AbstractOptionStorage *option = _impl->findOption(name);
+ GMX_RELEASE_ASSERT(impl_->currentOption_ == NULL, "finishOption() not called");
+ AbstractOptionStorage *option = impl_->findOption(name);
if (option == NULL)
{
GMX_THROW(InvalidInputError("Unknown option"));
}
option->startSet();
- _impl->_currentOption = option;
- _impl->_currentValueCount = 0;
+ impl_->currentOption_ = option;
+ impl_->currentValueCount_ = 0;
}
void OptionsAssigner::appendValue(const std::string &value)
{
- AbstractOptionStorage *option = _impl->_currentOption;
+ AbstractOptionStorage *option = impl_->currentOption_;
GMX_RELEASE_ASSERT(option != NULL, "startOption() not called");
- // Does not count correctly, but the actual count is not really used.
- // TODO: Rename the variable to better reflect the usage.
- ++_impl->_currentValueCount;
+ ++impl_->currentValueCount_;
option->appendValue(value);
}
void OptionsAssigner::finishOption()
{
- AbstractOptionStorage *option = _impl->_currentOption;
+ AbstractOptionStorage *option = impl_->currentOption_;
GMX_RELEASE_ASSERT(option != NULL, "startOption() not called");
bool bBoolReverseValue = false;
if (option->isBoolean())
{
- if (_impl->_currentValueCount == 0)
+ if (impl_->currentValueCount_ == 0)
{
// Should not throw, otherwise something is wrong.
// TODO: Get rid of the hard-coded values.
- option->appendValue(_impl->_reverseBoolean ? "0" : "1");
+ option->appendValue(impl_->reverseBoolean_ ? "0" : "1");
}
- else if (_impl->_reverseBoolean)
+ else if (impl_->reverseBoolean_)
{
bBoolReverseValue = true;
}
}
- _impl->_currentOption = NULL;
- _impl->_reverseBoolean = false;
+ impl_->currentOption_ = NULL;
+ impl_->reverseBoolean_ = false;
option->finishSet();
if (bBoolReverseValue)
{
void OptionsAssigner::finishSubSection()
{
// Should only be called if we are in a subsection.
- GMX_RELEASE_ASSERT(_impl->inSubSection(), "startSubSection() not called");
- _impl->_sectionStack.pop_back();
+ GMX_RELEASE_ASSERT(impl_->inSubSection(), "startSubSection() not called");
+ impl_->sectionStack_.pop_back();
}
void OptionsAssigner::finish()
{
- GMX_RELEASE_ASSERT(_impl->_currentOption == NULL, "finishOption() not called");
- if (_impl->hasFlag(Impl::efNoStrictSectioning))
+ GMX_RELEASE_ASSERT(impl_->currentOption_ == NULL, "finishOption() not called");
+ if (impl_->bNoStrictSectioning_)
{
- while (_impl->inSubSection())
+ while (impl_->inSubSection())
{
finishSubSection();
}
}
- GMX_RELEASE_ASSERT(!_impl->inSubSection(), "finishSubSection() not called");
+ GMX_RELEASE_ASSERT(!impl_->inSubSection(), "finishSubSection() not called");
}
} // namespace gmx
/*! \brief
* Creates an object that assigns to the given object.
*/
- OptionsAssigner(Options *options);
+ explicit OptionsAssigner(Options *options);
~OptionsAssigner();
/*! \brief
*
* Does not throw.
*/
- void setAcceptBooleanNoPrefix(bool enabled);
+ void setAcceptBooleanNoPrefix(bool bEnabled);
/*! \brief
* Sets the assigner to find options in non-active sections.
*
*
* Does not throw.
*/
- void setNoStrictSectioning(bool enabled);
+ void setNoStrictSectioning(bool bEnabled);
/*! \brief
* Start assigning values.
private:
class Impl;
- PrivateImplPointer<Impl> _impl;
+ PrivateImplPointer<Impl> impl_;
};
} // namespace gmx
// No implementation in this class for the pure virtual methods, but
// the declarations are still included for clarity.
virtual const char *typeString() const = 0;
- virtual int valueCount() const { return static_cast<int>(_values->size()); }
+ virtual int valueCount() const { return static_cast<int>(values_->size()); }
/*! \copydoc AbstractOptionStorage::formatValue()
*
* OptionStorageTemplate implements handling of DefaultValueIfSetIndex
*
* Does not throw.
*/
- void clear() { _values->clear(); }
+ void clear() { values_->clear(); }
/*! \brief
* Adds a value to a temporary storage.
*
* derived classes if necessary, and refreshValues() should be called
* if any changes are made.
*/
- ValueList &values() { return *_values; }
+ ValueList &values() { return *values_; }
//! Provides derived classes access to the current list of values.
- const ValueList &values() const { return *_values; }
+ const ValueList &values() const { return *values_; }
private:
/*! \brief
* Vector for temporary storage of values before commitSet() is called.
*/
- ValueList _setValues;
+ ValueList setValues_;
/*! \brief
* Vector for primary storage of option values.
*
* and other storage locations are updated only when refreshValues() is
* called.
*/
- ValueList *_values;
- T *_store;
- int *_countptr;
- boost::scoped_ptr<ValueList> _ownedValues;
- boost::scoped_ptr<T> _defaultValueIfSet;
+ ValueList *values_;
+ T *store_;
+ int *countptr_;
+ boost::scoped_ptr<ValueList> ownedValues_;
+ boost::scoped_ptr<T> defaultValueIfSet_;
// Copy and assign disallowed by base.
};
OptionStorageTemplate<T>::OptionStorageTemplate(const OptionTemplate<T, U> &settings,
OptionFlags staticFlags)
: AbstractOptionStorage(settings, staticFlags),
- _values(settings._storeVector),
- _store(settings._store),
- _countptr(settings._countptr)
+ values_(settings.storeVector_),
+ store_(settings.store_),
+ countptr_(settings.countptr_)
{
- if (_values == NULL)
+ if (values_ == NULL)
{
// The flag should be set for proper error checking.
GMX_RELEASE_ASSERT(!hasFlag(efExternalValueVector),
"Internal inconsistency");
- _ownedValues.reset(new std::vector<T>);
- _values = _ownedValues.get();
+ ownedValues_.reset(new std::vector<T>);
+ values_ = ownedValues_.get();
}
if (hasFlag(efNoDefaultValue)
- && (settings._defaultValue != NULL
- || settings._defaultValueIfSet != NULL))
+ && (settings.defaultValue_ != NULL
+ || settings.defaultValueIfSet_ != NULL))
{
GMX_THROW(APIError("Option does not support default value, but one is set"));
}
- if (_store != NULL && _countptr == NULL && !hasFlag(efVector)
+ if (store_ != NULL && countptr_ == NULL && !hasFlag(efVector)
&& minValueCount() != maxValueCount())
{
GMX_THROW(APIError("Count storage is not set, although the number of produced values is not known"));
if (!hasFlag(efNoDefaultValue))
{
setFlag(efHasDefaultValue);
- if (settings._defaultValue != NULL)
+ if (settings.defaultValue_ != NULL)
{
- _values->clear();
- addValue(*settings._defaultValue);
+ values_->clear();
+ addValue(*settings.defaultValue_);
// TODO: This is a bit hairy, as it indirectly calls a virtual function.
commitValues();
}
- else if (_ownedValues.get() != NULL && _store != NULL)
+ else if (ownedValues_.get() != NULL && store_ != NULL)
{
- _values->clear();
+ values_->clear();
int count = (settings.isVector() ?
- settings._maxValueCount : settings._minValueCount);
+ settings.maxValueCount_ : settings.minValueCount_);
for (int i = 0; i < count; ++i)
{
- _values->push_back(_store[i]);
+ values_->push_back(store_[i]);
}
}
- if (settings._defaultValueIfSet != NULL)
+ if (settings.defaultValueIfSet_ != NULL)
{
if (hasFlag(efMulti))
{
GMX_THROW(APIError("defaultValueIfSet() is not supported with allowMultiple()"));
}
- _defaultValueIfSet.reset(new T(*settings._defaultValueIfSet));
+ defaultValueIfSet_.reset(new T(*settings.defaultValueIfSet_));
}
}
setFlag(efClearOnNextSet);
"Invalid value index");
if (i == DefaultValueIfSetIndex)
{
- if (_defaultValueIfSet.get() != NULL)
+ if (defaultValueIfSet_.get() != NULL)
{
- return formatSingleValue(*_defaultValueIfSet);
+ return formatSingleValue(*defaultValueIfSet_);
}
return std::string();
}
template <typename T>
void OptionStorageTemplate<T>::clearSet()
{
- _setValues.clear();
+ setValues_.clear();
}
template <typename T>
void OptionStorageTemplate<T>::processSet()
{
- processSetValues(&_setValues);
- if (_setValues.empty() && _defaultValueIfSet.get() != NULL)
+ processSetValues(&setValues_);
+ if (setValues_.empty() && defaultValueIfSet_.get() != NULL)
{
- addValue(*_defaultValueIfSet);
+ addValue(*defaultValueIfSet_);
setFlag(efHasDefaultValue);
}
else
clearFlag(efHasDefaultValue);
}
if (!hasFlag(efDontCheckMinimumCount)
- && _setValues.size() < static_cast<size_t>(minValueCount()))
+ && setValues_.size() < static_cast<size_t>(minValueCount()))
{
clearSet();
GMX_THROW(InvalidInputError("Too few (valid) values"));
void OptionStorageTemplate<T>::addValue(const T &value)
{
if (maxValueCount() >= 0
- && _setValues.size() >= static_cast<size_t>(maxValueCount()))
+ && setValues_.size() >= static_cast<size_t>(maxValueCount()))
{
GMX_THROW(InvalidInputError("Too many values"));
}
- _setValues.push_back(value);
+ setValues_.push_back(value);
}
{
if (hasFlag(efClearOnNextSet))
{
- _values->swap(_setValues);
+ values_->swap(setValues_);
clearFlag(efClearOnNextSet);
}
else
{
- _values->insert(_values->end(), _setValues.begin(), _setValues.end());
+ values_->insert(values_->end(), setValues_.begin(), setValues_.end());
}
clearSet();
refreshValues();
template <typename T>
void OptionStorageTemplate<T>::refreshValues()
{
- if (_countptr != NULL)
+ if (countptr_ != NULL)
{
- *_countptr = static_cast<int>(_values->size());
+ *countptr_ = static_cast<int>(values_->size());
}
- if (_store != NULL)
+ if (store_ != NULL)
{
- for (size_t i = 0; i < _values->size(); ++i)
+ for (size_t i = 0; i < values_->size(); ++i)
{
- _store[i] = (*_values)[i];
+ store_[i] = (*values_)[i];
}
}
}
*/
OptionsIterator::OptionsIterator(const Options &options)
- : _options(options)
+ : options_(options)
{
}
void OptionsIterator::acceptSubSections(OptionsVisitor *visitor) const
{
const Options::Impl::SubSectionList &subSectionList =
- _options._impl->_subSections;
+ options_.impl_->subSections_;
Options::Impl::SubSectionList::const_iterator i;
for (i = subSectionList.begin(); i != subSectionList.end(); ++i)
{
void OptionsIterator::acceptOptions(OptionsVisitor *visitor) const
{
const Options::Impl::OptionList &optionList =
- _options._impl->_options;
+ options_.impl_->options_;
Options::Impl::OptionList::const_iterator i;
for (i = optionList.begin(); i != optionList.end(); ++i)
{
*/
OptionsModifyingIterator::OptionsModifyingIterator(Options *options)
- : _options(*options)
+ : options_(*options)
{
}
void OptionsModifyingIterator::acceptSubSections(OptionsModifyingVisitor *visitor) const
{
const Options::Impl::SubSectionList &subSectionList =
- _options._impl->_subSections;
+ options_.impl_->subSections_;
Options::Impl::SubSectionList::const_iterator i;
for (i = subSectionList.begin(); i != subSectionList.end(); ++i)
{
void OptionsModifyingIterator::acceptOptions(OptionsModifyingVisitor *visitor) const
{
const Options::Impl::OptionList &optionList =
- _options._impl->_options;
+ options_.impl_->options_;
Options::Impl::OptionList::const_iterator i;
for (i = optionList.begin(); i != optionList.end(); ++i)
{
/*! \brief
* Creates an object for visiting options in a Options object.
*/
- OptionsIterator(const Options &options);
+ explicit OptionsIterator(const Options &options);
/*! \brief
* Visits each subsection in the wrapped Options object.
private:
//! The wrapped Options object.
- const Options &_options;
+ const Options &options_;
GMX_DISALLOW_COPY_AND_ASSIGN(OptionsIterator);
};
/*! \brief
* Creates an object for visiting options in a Options object.
*/
- OptionsModifyingIterator(Options *options);
+ explicit OptionsModifyingIterator(Options *options);
/*! \brief
* Visits each subsection in the wrapped Options object.
private:
//! The wrapped Options object.
- Options &_options;
+ Options &options_;
GMX_DISALLOW_COPY_AND_ASSIGN(OptionsModifyingIterator);
};
public:
//! Initializes an option with the given name.
explicit MockOption(const char *name)
- : MyBase(name), _storagePtr(NULL)
+ : MyBase(name), storagePtr_(NULL)
{
}
//! Sets an output pointer to give access to the created storage object.
MyClass &storageObject(MockOptionStorage **storagePtr)
- { _storagePtr = storagePtr; return me(); }
+ { storagePtr_ = storagePtr; return me(); }
private:
virtual gmx::AbstractOptionStoragePointer createStorage() const
{
MockOptionStorage *storage = new MockOptionStorage(*this);
- if (_storagePtr != NULL)
+ if (storagePtr_ != NULL)
{
- *_storagePtr = storage;
+ *storagePtr_ = storage;
}
return gmx::AbstractOptionStoragePointer(storage);
}
- MockOptionStorage **_storagePtr;
+ MockOptionStorage **storagePtr_;
};
MockOptionStorage::MockOptionStorage(const MockOption &settings)
SelectionOptionStorage::SelectionOptionStorage(const SelectionOption &settings)
: MyBase(settings, OptionFlags() | efNoDefaultValue | efDontCheckMinimumCount),
- info_(this), manager_(NULL), selectionFlags_(settings._selectionFlags)
+ info_(this), manager_(NULL), selectionFlags_(settings.selectionFlags_)
{
GMX_RELEASE_ASSERT(!hasFlag(efMulti),
"allowMultiple() is not supported for selection options");
- if (settings._infoPtr != NULL)
+ if (settings.infoPtr_ != NULL)
{
- *settings._infoPtr = &info_;
+ *settings.infoPtr_ = &info_;
}
}
public:
//! Initializes an option with the given name.
explicit SelectionOption(const char *name)
- : MyBase(name), _infoPtr(NULL)
+ : MyBase(name), infoPtr_(NULL)
{ }
/*! \brief
* in which case SelectionPosition::hasVelocity() returns false.
*/
MyClass &evaluateVelocities()
- { _selectionFlags.set(efEvaluateVelocities); return me(); }
+ { selectionFlags_.set(efEvaluateVelocities); return me(); }
/*! \brief
* Request force evaluation for output positions.
*
* in which case SelectionPosition::hasForce() returns false.
*/
MyClass &evaluateForces()
- { _selectionFlags.set(efEvaluateForces); return me(); }
+ { selectionFlags_.set(efEvaluateForces); return me(); }
/*! \brief
* Only accept selections that evaluate to atom positions.
*
* TODO: This option is not yet implemented.
*/
MyClass &onlyAtoms()
- { _selectionFlags.set(efOnlyAtoms); return me(); }
+ { selectionFlags_.set(efOnlyAtoms); return me(); }
/*! \brief
* Only accept static selections for this option.
*/
MyClass &onlyStatic()
- { _selectionFlags.set(efOnlyStatic); return me(); }
+ { selectionFlags_.set(efOnlyStatic); return me(); }
/*! \brief
* Handle dynamic selections for this option with position masks.
*
* \see SelectionPosition::selected()
*/
MyClass &dynamicMask()
- { _selectionFlags.set(efDynamicMask); return me(); }
+ { selectionFlags_.set(efDynamicMask); return me(); }
/*! \brief
* Disallow using atom coordinates as the reference positions.
*
* TODO: This option is not yet implemented.
*/
MyClass &dynamicOnlyWhole()
- { _selectionFlags.set(efDynamicOnlyWhole); return me(); }
+ { selectionFlags_.set(efDynamicOnlyWhole); return me(); }
/*! \brief
* Get an info object that can be used to alter the option after
* \see SelectionOptionInfo
*/
MyClass &getAdjuster(SelectionOptionInfo **infoPtr)
- { _infoPtr = infoPtr; return me(); }
+ { infoPtr_ = infoPtr; return me(); }
private:
// Disable possibility to allow multiple occurrences, since it isn't
virtual AbstractOptionStoragePointer createStorage() const;
- SelectionFlags _selectionFlags;
- SelectionOptionInfo **_infoPtr;
+ SelectionFlags selectionFlags_;
+ SelectionOptionInfo **infoPtr_;
/*! \brief
* Needed to initialize SelectionOptionStorage from this class without
{
public:
//! Creates a flags object with no flags set.
- FlagsTemplate() : _flags(0) {}
+ FlagsTemplate() : flags_(0) {}
//! Creates a flags object from a single flag.
- FlagsTemplate(T flag) : _flags(flag) {}
+ FlagsTemplate(T flag) : flags_(flag) {}
//! Returns true if the given flag is set.
- bool test(T flag) const { return _flags & flag; }
+ bool test(T flag) const { return flags_ & flag; }
//! Clears all flags.
- void clearAll() { _flags = 0; }
+ void clearAll() { flags_ = 0; }
//! Sets the given flag.
- void set(T flag) { _flags |= flag; }
+ void set(T flag) { flags_ |= flag; }
//! Clears the given flag.
- void clear(T flag) { _flags &= ~flag; }
+ void clear(T flag) { flags_ &= ~flag; }
//! Sets or clears the given flag.
void set(T flag, bool bSet)
{
//! Combines flags from two flags objects.
FlagsTemplate<T> operator |(const FlagsTemplate<T> &other) const
{
- return FlagsTemplate<T>(_flags | other._flags);
+ return FlagsTemplate<T>(flags_ | other.flags_);
}
//! Combines flags from another flag object.
FlagsTemplate<T> &operator |=(const FlagsTemplate<T> &other)
{
- _flags |= other._flags;
+ flags_ |= other.flags_;
return *this;
}
//! Combined flags from two flags objects.
FlagsTemplate<T> operator &(const FlagsTemplate<T> &other) const
{
- return FlagsTemplate<T>(_flags & other._flags);
+ return FlagsTemplate<T>(flags_ & other.flags_);
}
//! Returns an object with all flags flipped.
FlagsTemplate<T> operator ~() const
{
- return FlagsTemplate<T>(~_flags);
+ return FlagsTemplate<T>(~flags_);
}
private:
//! Creates a flags object with the given flags.
- explicit FlagsTemplate(unsigned long flags) : _flags(flags) {}
+ explicit FlagsTemplate(unsigned long flags) : flags_(flags) {}
- unsigned long _flags;
+ unsigned long flags_;
};
} // namespace gmx
~Impl();
//! Full path of the reference data file.
- std::string _fullFilename;
+ std::string fullFilename_;
/*! \brief
* XML document for the reference data.
*
* May be NULL if there was an I/O error in initialization.
*/
- xmlDocPtr _refDoc;
+ xmlDocPtr refDoc_;
/*! \brief
* Whether the reference data is being written (true) or compared
* (false).
*/
- bool _bWrite;
+ bool bWrite_;
/*! \brief
* Whether any reference checkers have been created for this data.
*/
- bool _bInUse;
+ bool bInUse_;
};
const xmlChar * const TestReferenceData::Impl::cXmlVersion =
TestReferenceData::Impl::Impl(ReferenceDataMode mode)
- : _refDoc(NULL), _bWrite(false), _bInUse(false)
+ : refDoc_(NULL), bWrite_(false), bInUse_(false)
{
std::string dirname = getReferenceDataPath();
std::string filename = TestFileManager::getTestSpecificFileName(".xml");
- _fullFilename = Path::join(dirname, filename);
+ fullFilename_ = Path::join(dirname, filename);
- _bWrite = true;
+ bWrite_ = true;
if (mode != erefdataUpdateAll)
{
- FILE *fp = std::fopen(_fullFilename.c_str(), "r");
+ FILE *fp = std::fopen(fullFilename_.c_str(), "r");
if (fp != NULL)
{
- _bWrite = false;
+ bWrite_ = false;
fclose(fp);
}
else if (mode == erefdataCompare)
{
- _bWrite = false;
+ bWrite_ = false;
return;
}
}
- if (_bWrite)
+ if (bWrite_)
{
// TODO: Error checking
- _refDoc = xmlNewDoc(cXmlVersion);
- xmlNodePtr rootNode = xmlNewDocNode(_refDoc, NULL, cRootNodeName, NULL);
- xmlDocSetRootElement(_refDoc, rootNode);
- xmlNodePtr xslNode = xmlNewDocPI(_refDoc, cXmlStyleSheetNodeName,
+ refDoc_ = xmlNewDoc(cXmlVersion);
+ xmlNodePtr rootNode = xmlNewDocNode(refDoc_, NULL, cRootNodeName, NULL);
+ xmlDocSetRootElement(refDoc_, rootNode);
+ xmlNodePtr xslNode = xmlNewDocPI(refDoc_, cXmlStyleSheetNodeName,
cXmlStyleSheetContent);
xmlAddPrevSibling(rootNode, xslNode);
}
else
{
- _refDoc = xmlParseFile(_fullFilename.c_str());
- if (_refDoc == NULL)
+ refDoc_ = xmlParseFile(fullFilename_.c_str());
+ if (refDoc_ == NULL)
{
- GMX_THROW(TestException("Reference data not parsed successfully: " + _fullFilename));
+ GMX_THROW(TestException("Reference data not parsed successfully: " + fullFilename_));
}
- xmlNodePtr rootNode = xmlDocGetRootElement(_refDoc);
+ xmlNodePtr rootNode = xmlDocGetRootElement(refDoc_);
if (rootNode == NULL)
{
- xmlFreeDoc(_refDoc);
- GMX_THROW(TestException("Reference data is empty: " + _fullFilename));
+ xmlFreeDoc(refDoc_);
+ GMX_THROW(TestException("Reference data is empty: " + fullFilename_));
}
if (xmlStrcmp(rootNode->name, cRootNodeName) != 0)
{
- xmlFreeDoc(_refDoc);
- GMX_THROW(TestException("Invalid root node type in " + _fullFilename));
+ xmlFreeDoc(refDoc_);
+ GMX_THROW(TestException("Invalid root node type in " + fullFilename_));
}
}
}
TestReferenceData::Impl::~Impl()
{
- if (_bWrite && _bInUse && _refDoc != NULL)
+ if (bWrite_ && bInUse_ && refDoc_ != NULL)
{
std::string dirname = getReferenceDataPath();
if (!Directory::exists(dirname))
ADD_FAILURE() << "Creation of reference data directory failed for " << dirname;
}
}
- if (xmlSaveFormatFile(_fullFilename.c_str(), _refDoc, 1) == -1)
+ if (xmlSaveFormatFile(fullFilename_.c_str(), refDoc_, 1) == -1)
{
- ADD_FAILURE() << "Saving reference data failed for " + _fullFilename;
+ ADD_FAILURE() << "Saving reference data failed for " + fullFilename_;
}
}
- if (_refDoc != NULL)
+ if (refDoc_ != NULL)
{
- xmlFreeDoc(_refDoc);
+ xmlFreeDoc(refDoc_);
}
}
* id of the compound is added. Used for reporting comparison
* mismatches.
*/
- std::string _path;
+ std::string path_;
/*! \brief
* Current node under which reference data is searched.
*
- * Points to either the root of TestReferenceData::Impl::_refDoc, or to
+ * Points to either the root of TestReferenceData::Impl::refDoc_, or to
* a compound node.
*
* Can be NULL, in which case this checker does nothing (doesn't even
* report errors, see shouldIgnore()).
*/
- xmlNodePtr _currNode;
+ xmlNodePtr currNode_;
/*! \brief
- * Points to a child of \a _currNode where the next search should start.
+ * Points to a child of \a currNode_ where the next search should start.
*
- * On initialization, points to the first child of \a _currNode. After
+ * On initialization, points to the first child of \a currNode_. After
* every check, is updated to point to the node following the one
* found, with possible wrapping.
*
- * Is NULL if and only if \a _currNode contains no children.
- * Otherwise, always points to a direct child of \a _currNode.
+ * Is NULL if and only if \a currNode_ contains no children.
+ * Otherwise, always points to a direct child of \a currNode_.
*/
- xmlNodePtr _nextSearchNode;
+ xmlNodePtr nextSearchNode_;
/*! \brief
* Whether the reference data is being written (true) or compared
* (false).
*/
- bool _bWrite;
+ bool bWrite_;
/*! \brief
* Current number of unnamed elements in a sequence.
*
* It is the index of the next added unnamed element.
*/
- int _seqIndex;
+ int seqIndex_;
};
const xmlChar * const TestReferenceChecker::Impl::cBooleanNodeName =
TestReferenceChecker::Impl::Impl(bool bWrite)
- : _currNode(NULL), _nextSearchNode(NULL), _bWrite(bWrite), _seqIndex(0)
+ : currNode_(NULL), nextSearchNode_(NULL), bWrite_(bWrite), seqIndex_(0)
{
}
TestReferenceChecker::Impl::Impl(const std::string &path, xmlNodePtr rootNode,
bool bWrite)
- : _path(path + "/"), _currNode(rootNode),
- _nextSearchNode(rootNode->xmlChildrenNode),
- _bWrite(bWrite), _seqIndex(0)
+ : path_(path + "/"), currNode_(rootNode),
+ nextSearchNode_(rootNode->xmlChildrenNode),
+ bWrite_(bWrite), seqIndex_(0)
{
}
std::string
TestReferenceChecker::Impl::appendPath(const char *id) const
{
- std::string printId = (id != NULL) ? id : formatString("[%d]", _seqIndex);
- return _path + printId;
+ std::string printId = (id != NULL) ? id : formatString("[%d]", seqIndex_);
+ return path_ + printId;
}
TestReferenceChecker::Impl::findNode(const xmlChar *name, const char *id) const
{
const xmlChar *xmlId = reinterpret_cast<const xmlChar *>(id);
- xmlNodePtr node = _nextSearchNode;
+ xmlNodePtr node = nextSearchNode_;
if (node == NULL)
{
return NULL;
}
}
node = node->next;
- if (node == NULL && _nextSearchNode != _currNode->xmlChildrenNode)
+ if (node == NULL && nextSearchNode_ != currNode_->xmlChildrenNode)
{
- node = _currNode->xmlChildrenNode;
+ node = currNode_->xmlChildrenNode;
}
}
- while (node != NULL && node != _nextSearchNode);
+ while (node != NULL && node != nextSearchNode_);
return NULL;
}
xmlNodePtr node = findNode(name, id);
if (node == NULL)
{
- if (_bWrite)
+ if (bWrite_)
{
- node = xmlNewTextChild(_currNode, NULL, name, NULL);
+ node = xmlNewTextChild(currNode_, NULL, name, NULL);
if (node != NULL && id != NULL)
{
const xmlChar *xmlId = reinterpret_cast<const xmlChar *>(id);
}
else
{
- _nextSearchNode = node->next;
- if (_nextSearchNode == NULL)
+ nextSearchNode_ = node->next;
+ if (nextSearchNode_ == NULL)
{
- _nextSearchNode = _currNode->xmlChildrenNode;
+ nextSearchNode_ = currNode_->xmlChildrenNode;
}
}
if (node == NULL)
{
- GMX_RELEASE_ASSERT(!_bWrite, "Node creation failed without exception");
+ GMX_RELEASE_ASSERT(!bWrite_, "Node creation failed without exception");
ADD_FAILURE() << "Reference data item not found";
}
- _seqIndex = (id == NULL) ? _seqIndex+1 : 0;
+ seqIndex_ = (id == NULL) ? seqIndex_+1 : 0;
return node;
}
return std::string();
}
*bFound = true;
- if (_bWrite)
+ if (bWrite_)
{
xmlNodeAddContent(node, reinterpret_cast<const xmlChar *>(value));
return std::string(value);
bool
TestReferenceChecker::Impl::shouldIgnore() const
{
- return _currNode == NULL;
+ return currNode_ == NULL;
}
*/
TestReferenceData::TestReferenceData()
- : _impl(new Impl(getReferenceDataMode()))
+ : impl_(new Impl(getReferenceDataMode()))
{
}
TestReferenceData::TestReferenceData(ReferenceDataMode mode)
- : _impl(new Impl(mode))
+ : impl_(new Impl(mode))
{
}
bool TestReferenceData::isWriteMode() const
{
- return _impl->_bWrite;
+ return impl_->bWrite_;
}
TestReferenceChecker TestReferenceData::rootChecker()
{
- if (!isWriteMode() && !_impl->_bInUse && _impl->_refDoc == NULL)
+ if (!isWriteMode() && !impl_->bInUse_ && impl_->refDoc_ == NULL)
{
ADD_FAILURE() << "Reference data file not found: "
- << _impl->_fullFilename;
+ << impl_->fullFilename_;
}
- _impl->_bInUse = true;
- if (_impl->_refDoc == NULL)
+ impl_->bInUse_ = true;
+ if (impl_->refDoc_ == NULL)
{
return TestReferenceChecker(new TestReferenceChecker::Impl(isWriteMode()));
}
- xmlNodePtr rootNode = xmlDocGetRootElement(_impl->_refDoc);
+ xmlNodePtr rootNode = xmlDocGetRootElement(impl_->refDoc_);
return TestReferenceChecker(
new TestReferenceChecker::Impl("", rootNode, isWriteMode()));
}
*/
TestReferenceChecker::TestReferenceChecker(Impl *impl)
- : _impl(impl)
+ : impl_(impl)
{
}
TestReferenceChecker::TestReferenceChecker(const TestReferenceChecker &other)
- : _impl(new Impl(*other._impl))
+ : impl_(new Impl(*other.impl_))
{
}
TestReferenceChecker &
TestReferenceChecker::operator =(const TestReferenceChecker &other)
{
- _impl.reset(new Impl(*other._impl));
+ impl_.reset(new Impl(*other.impl_));
return *this;
}
bool TestReferenceChecker::isWriteMode() const
{
- return _impl->_bWrite;
+ return impl_->bWrite_;
}
{
return bPresent;
}
- xmlNodePtr node = _impl->findNode(NULL, id);
+ xmlNodePtr node = impl_->findNode(NULL, id);
bool bFound = (node != NULL);
if (bFound != bPresent)
{
ADD_FAILURE() << "Mismatch while checking reference data item'"
- << _impl->appendPath(id) << "'\n"
+ << impl_->appendPath(id) << "'\n"
<< "Expected: " << (bPresent ? "it is present.\n" : "it is absent.\n")
<< " Actual: " << (bFound ? "it is present." : "it is absent.");
}
if (bFound && bPresent)
{
- _impl->_nextSearchNode = node;
+ impl_->nextSearchNode_ = node;
return true;
}
return false;
TestReferenceChecker TestReferenceChecker::checkCompound(const char *type, const char *id)
{
- SCOPED_TRACE(_impl->traceString(id));
- if (_impl->shouldIgnore())
+ SCOPED_TRACE(impl_->traceString(id));
+ if (impl_->shouldIgnore())
{
return TestReferenceChecker(new Impl(isWriteMode()));
}
const xmlChar *xmlNodeName = reinterpret_cast<const xmlChar *>(type);
- xmlNodePtr newNode = _impl->findOrCreateNode(xmlNodeName, id);
+ xmlNodePtr newNode = impl_->findOrCreateNode(xmlNodeName, id);
if (newNode == NULL)
{
return TestReferenceChecker(new Impl(isWriteMode()));
}
return TestReferenceChecker(
- new Impl(_impl->appendPath(id), newNode, isWriteMode()));
+ new Impl(impl_->appendPath(id), newNode, isWriteMode()));
}
void TestReferenceChecker::checkBoolean(bool value, const char *id)
{
- if (_impl->shouldIgnore())
+ if (impl_->shouldIgnore())
{
return;
}
- SCOPED_TRACE(_impl->traceString(id));
+ SCOPED_TRACE(impl_->traceString(id));
bool bFound = false;
const char *strValue = value ? "true" : "false";
std::string refStrValue =
- _impl->processItem(Impl::cBooleanNodeName, id, strValue, &bFound);
+ impl_->processItem(Impl::cBooleanNodeName, id, strValue, &bFound);
if (bFound)
{
EXPECT_EQ(refStrValue, strValue);
void TestReferenceChecker::checkString(const char *value, const char *id)
{
- if (_impl->shouldIgnore())
+ if (impl_->shouldIgnore())
{
return;
}
- SCOPED_TRACE(_impl->traceString(id));
+ SCOPED_TRACE(impl_->traceString(id));
bool bFound = false;
std::string refStrValue =
- _impl->processItem(Impl::cStringNodeName, id, value, &bFound);
+ impl_->processItem(Impl::cStringNodeName, id, value, &bFound);
if (bFound)
{
EXPECT_EQ(refStrValue, value);
void TestReferenceChecker::checkStringBlock(const std::string &value,
const char *id)
{
- if (_impl->shouldIgnore())
+ if (impl_->shouldIgnore())
{
return;
}
- SCOPED_TRACE(_impl->traceString(id));
- xmlNodePtr node = _impl->findOrCreateNode(Impl::cStringNodeName, id);
+ SCOPED_TRACE(impl_->traceString(id));
+ xmlNodePtr node = impl_->findOrCreateNode(Impl::cStringNodeName, id);
if (node == NULL)
{
return;
void TestReferenceChecker::checkInteger(int value, const char *id)
{
- if (_impl->shouldIgnore())
+ if (impl_->shouldIgnore())
{
return;
}
- SCOPED_TRACE(_impl->traceString(id));
+ SCOPED_TRACE(impl_->traceString(id));
bool bFound = false;
std::string strValue = formatString("%d", value);
std::string refStrValue =
- _impl->processItem(Impl::cIntegerNodeName, id, strValue, &bFound);
+ impl_->processItem(Impl::cIntegerNodeName, id, strValue, &bFound);
if (bFound)
{
EXPECT_EQ(refStrValue, strValue);
void TestReferenceChecker::checkDouble(double value, const char *id)
{
- if (_impl->shouldIgnore())
+ if (impl_->shouldIgnore())
{
return;
}
- SCOPED_TRACE(_impl->traceString(id));
+ SCOPED_TRACE(impl_->traceString(id));
bool bFound = false;
std::string strValue = formatString("%f", value);
std::string refStrValue =
- _impl->processItem(Impl::cRealNodeName, id, strValue, &bFound);
+ impl_->processItem(Impl::cRealNodeName, id, strValue, &bFound);
if (bFound)
{
char *endptr;
private:
class Impl;
- PrivateImplPointer<Impl> _impl;
+ PrivateImplPointer<Impl> impl_;
};
/*! \libinternal \brief
*/
explicit TestReferenceChecker(Impl *impl);
- PrivateImplPointer<Impl> _impl;
+ PrivateImplPointer<Impl> impl_;
/*! \brief
* Needed to expose the constructor only to TestReferenceData.