static char *
copy_string (const char * s)
{
- unsigned long int slen = strlen(s);
+ size_t slen = strlen(s);
char * copy = new char[slen + 1];
// the source string length is known so no need to check for '\0'
static int
find_child (Itr begin, Itr end, int index, const PropertyList& nodes)
{
- int nNodes = nodes.size();
+ size_t nNodes = nodes.size();
boost::iterator_range<Itr> name(begin, end);
- for (int i = 0; i < nNodes; i++) {
+ for (size_t i = 0; i < nNodes; i++) {
SGPropertyNode * node = nodes[i];
// searching for a matching index is a lot less time consuming than
// comparing two strings so do that first.
if (node->getIndex() == index && boost::equals(node->getName(), name))
- return i;
+ return static_cast<int>(i);
}
return -1;
}
static int
find_last_child (const char * name, const PropertyList& nodes)
{
- int nNodes = nodes.size();
+ size_t nNodes = nodes.size();
int index = -1;
- for (int i = 0; i < nNodes; i++) {
+ for (size_t i = 0; i < nNodes; i++) {
SGPropertyNode * node = nodes[i];
if (compare_strings(node->getName(), name))
{
SGPropertyNode::getChildren (const char * name) const
{
PropertyList children;
- int max = _children.size();
+ size_t max = _children.size();
- for (int i = 0; i < max; i++)
+ for (size_t i = 0; i < max; i++)
if (compare_strings(_children[i]->getName(), name))
children.push_back(_children[i]);
{
PropertyList children;
- for (int pos = _children.size() - 1; pos >= 0; pos--)
+ for (int pos = static_cast<int>(_children.size() - 1); pos >= 0; pos--)
if (compare_strings(_children[pos]->getName(), name))
children.push_back(removeChild(pos, keep));
SGPropertyChangeListener::~SGPropertyChangeListener ()
{
- for (int i = _properties.size() - 1; i >= 0; i--)
+ for (int i = static_cast<int>(_properties.size() - 1); i >= 0; i--)
_properties[i]->removeChangeListener(this);
}
template<typename T>
class SGBinaryExpression : public SGExpression<T> {
public:
- const SGExpression<T>* getOperand(unsigned i) const
+ const SGExpression<T>* getOperand(size_t i) const
{ return _expressions[i]; }
- SGExpression<T>* getOperand(unsigned i)
+ SGExpression<T>* getOperand(size_t i)
{ return _expressions[i]; }
- void setOperand(unsigned i, SGExpression<T>* expression)
+ void setOperand(size_t i, SGExpression<T>* expression)
{
if (!expression)
expression = new SGConstExpression<T>(T());
template<typename T>
class SGNaryExpression : public SGExpression<T> {
public:
- unsigned getNumOperands() const
+ size_t getNumOperands() const
{ return _expressions.size(); }
- const SGExpression<T>* getOperand(unsigned i) const
+ const SGExpression<T>* getOperand(size_t i) const
{ return _expressions[i]; }
- SGExpression<T>* getOperand(unsigned i)
+ SGExpression<T>* getOperand(size_t i)
{ return _expressions[i]; }
- unsigned addOperand(SGExpression<T>* expression)
+ size_t addOperand(SGExpression<T>* expression)
{
if (!expression)
- return ~unsigned(0);
+ return ~size_t(0);
_expressions.push_back(expression);
return _expressions.size() - 1;
}
virtual bool isConst() const
{
- for (unsigned i = 0; i < _expressions.size(); ++i)
+ for (size_t i = 0; i < _expressions.size(); ++i)
if (!_expressions[i]->isConst())
return false;
return true;
}
virtual SGExpression<T>* simplify()
{
- for (unsigned i = 0; i < _expressions.size(); ++i)
+ for (size_t i = 0; i < _expressions.size(); ++i)
_expressions[i] = _expressions[i]->simplify();
return SGExpression<T>::simplify();
}
virtual void eval(T& value, const simgear::expression::Binding* b) const
{
value = T(0);
- unsigned sz = SGNaryExpression<T>::getNumOperands();
- for (unsigned i = 0; i < sz; ++i)
+ size_t sz = SGNaryExpression<T>::getNumOperands();
+ for (size_t i = 0; i < sz; ++i)
value += getOperand(i)->getValue(b);
}
using SGNaryExpression<T>::getValue;
virtual void eval(T& value, const simgear::expression::Binding* b) const
{
value = getOperand(0)->getValue(b);
- unsigned sz = SGNaryExpression<T>::getNumOperands();
- for (unsigned i = 1; i < sz; ++i)
+ size_t sz = SGNaryExpression<T>::getNumOperands();
+ for (size_t i = 1; i < sz; ++i)
value -= getOperand(i)->getValue(b);
}
using SGNaryExpression<T>::getValue;
virtual void eval(T& value, const simgear::expression::Binding* b) const
{
value = T(1);
- unsigned sz = SGNaryExpression<T>::getNumOperands();
- for (unsigned i = 0; i < sz; ++i)
+ size_t sz = SGNaryExpression<T>::getNumOperands();
+ for (size_t i = 0; i < sz; ++i)
value *= getOperand(i)->getValue(b);
}
using SGNaryExpression<T>::getValue;
{ }
virtual void eval(T& value, const simgear::expression::Binding* b) const
{
- unsigned sz = SGNaryExpression<T>::getNumOperands();
+ size_t sz = SGNaryExpression<T>::getNumOperands();
if (sz < 1)
return;
value = getOperand(0)->getValue(b);
- for (unsigned i = 1; i < sz; ++i)
+ for (size_t i = 1; i < sz; ++i)
value = SGMisc<T>::min(value, getOperand(i)->getValue(b));
}
using SGNaryExpression<T>::getOperand;
{ }
virtual void eval(T& value, const simgear::expression::Binding* b) const
{
- unsigned sz = SGNaryExpression<T>::getNumOperands();
+ size_t sz = SGNaryExpression<T>::getNumOperands();
if (sz < 1)
return;
value = getOperand(0)->getValue(b);
- for (unsigned i = 1; i < sz; ++i)
+ for (size_t i = 1; i < sz; ++i)
value = SGMisc<T>::max(value, getOperand(i)->getValue(b));
}
using SGNaryExpression<T>::getOperand;
class GeneralNaryExpression : public ::SGExpression<T> {
public:
typedef OpType operand_type;
- unsigned getNumOperands() const
+ size_t getNumOperands() const
{ return _expressions.size(); }
- const ::SGExpression<OpType>* getOperand(unsigned i) const
+ const ::SGExpression<OpType>* getOperand(size_t i) const
{ return _expressions[i]; }
- ::SGExpression<OpType>* getOperand(unsigned i)
+ ::SGExpression<OpType>* getOperand(size_t i)
{ return _expressions[i]; }
- unsigned addOperand(::SGExpression<OpType>* expression)
+ size_t addOperand(::SGExpression<OpType>* expression)
{
if (!expression)
- return ~unsigned(0);
+ return ~size_t(0);
_expressions.push_back(expression);
return _expressions.size() - 1;
}
virtual bool isConst() const
{
- for (unsigned i = 0; i < _expressions.size(); ++i)
+ for (size_t i = 0; i < _expressions.size(); ++i)
if (!_expressions[i]->isConst())
return false;
return true;
}
virtual ::SGExpression<T>* simplify()
{
- for (unsigned i = 0; i < _expressions.size(); ++i)
+ for (size_t i = 0; i < _expressions.size(); ++i)
_expressions[i] = _expressions[i]->simplify();
return SGExpression<T>::simplify();
}
}
virtual void eval(bool& value, const simgear::expression::Binding* b) const
{
- unsigned sz = this->getNumOperands();
+ size_t sz = this->getNumOperands();
if (sz != 2)
return;
value = _pred(this->getOperand(0)->getValue(b),