Skip to content

Commit

Permalink
libdeng2: Cleanup
Browse files Browse the repository at this point in the history
Indentation in the Value class headers.
  • Loading branch information
skyjake committed Dec 2, 2012
1 parent 2d79da9 commit 3739b59
Show file tree
Hide file tree
Showing 10 changed files with 763 additions and 753 deletions.
69 changes: 35 additions & 34 deletions doomsday/libdeng2/include/de/data/accessorvalue.h
Expand Up @@ -23,43 +23,44 @@
#include "../TextValue"
#include "../Variable"

namespace de
namespace de {

/**
* Special text value that provides access to properties of another object.
*
* @ingroup data
*/
class AccessorValue : public TextValue
{
/**
* Special text value that provides access to properties of another object.
*
* @ingroup data
*/
class AccessorValue : public TextValue
{
public:
/// Mode to use for variables that have an accessor value.
static Variable::Flags const VARIABLE_MODE;

public:
AccessorValue();

/// Update the text content of the accessor.
virtual void update() const = 0;
public:
/// Mode to use for variables that have an accessor value.
static Variable::Flags const VARIABLE_MODE;

public:
AccessorValue();

/// Update the text content of the accessor.
virtual void update() const = 0;

/// Creates a new value with the content of the accessor. The returned
/// value should not be an AccessorValue.
virtual Value *duplicateContent() const = 0;

/// Creates a new value with the content of the accessor. The returned
/// value should not be an AccessorValue.
virtual Value *duplicateContent() const = 0;
Value *duplicate() const;
Number asNumber() const;
Text asText() const;
dsize size() const;
bool isTrue() const;
dint compare(Value const &value) const;
void sum(Value const &value);
void multiply(Value const &value);
void divide(Value const &value);
void modulo(Value const &divisor);
void operator >> (Writer &to) const;
void operator << (Reader &from);
};

Value *duplicate() const;
Number asNumber() const;
Text asText() const;
dsize size() const;
bool isTrue() const;
dint compare(Value const &value) const;
void sum(Value const &value);
void multiply(Value const &value);
void divide(Value const &value);
void modulo(Value const &divisor);
void operator >> (Writer &to) const;
void operator << (Reader &from);
};
}
} // namespace de

#endif /* LIBDENG2_ACCESSORVALUE_H */

239 changes: 120 additions & 119 deletions doomsday/libdeng2/include/de/data/arrayvalue.h
Expand Up @@ -24,128 +24,129 @@

#include <vector>

namespace de
namespace de {

/**
* The ArrayValue class is a subclass of Value that holds a dynamic
* array of other values. The array is indexed using (integer) numbers.
*
* @ingroup data
*/
class DENG2_PUBLIC ArrayValue : public Value
{
public:
/// Attempt to index the array with indices that are not defined for the array. @ingroup errors
DENG2_ERROR(OutOfBoundsError);

/// The index used for accessing the array is of the wrong type. @ingroup errors
DENG2_ERROR(IllegalIndexError);

/// Type for the elements. Public because const access to the elements is public.
typedef std::vector<Value *> Elements;

public:
ArrayValue();
ArrayValue(ArrayValue const &other);
~ArrayValue();

/// Const accessor to the array elements.
Elements const &elements() const { return _elements; }

/**
* Adds a new Value to the elements of the array. The value is
* added to the end of the list of elements.
* @param value Value to add to the array. The array takes
* ownership of the object.
*/
void add(Value *value);

/**
* Adds a new TextValue to the elements of the array. The value is
* added to the end of the list of elements.
* param text Text to add to the array.
*/
void add(String const &text);

/**
* Pops the last element and gives its ownership to the caller.
*
* @return Last element of the array. Ownership transferred.
*/
Value *pop();

/**
* Inserts a new Value into the elements of the array at an
* arbitrary location. The new Value's index will be @a index.
* @param index Index for the new Value.
* @param value Value to add. The array takes ownership of the object.
*/
void insert(dint index, Value *value);

/**
* The ArrayValue class is a subclass of Value that holds a dynamic
* array of other values. The array is indexed using (integer) numbers.
* Replaces an existing Value in the array. The previous value
* at the index will be destroyed.
*
* @ingroup data
* @param index Index of the Value.
* @param value New value. The array takes ownership of the object.
*/
class DENG2_PUBLIC ArrayValue : public Value
{
public:
/// Attempt to index the array with indices that are not defined for the array. @ingroup errors
DENG2_ERROR(OutOfBoundsError);

/// The index used for accessing the array is of the wrong type. @ingroup errors
DENG2_ERROR(IllegalIndexError);

/// Type for the elements. Public because const access to the elements is public.
typedef std::vector<Value *> Elements;

public:
ArrayValue();
ArrayValue(ArrayValue const &other);
~ArrayValue();

/// Const accessor to the array elements.
Elements const &elements() const { return _elements; }

/**
* Adds a new Value to the elements of the array. The value is
* added to the end of the list of elements.
* @param value Value to add to the array. The array takes
* ownership of the object.
*/
void add(Value *value);

/**
* Adds a new TextValue to the elements of the array. The value is
* added to the end of the list of elements.
* param text Text to add to the array.
*/
void add(String const &text);

/**
* Pops the last element and gives its ownership to the caller.
*
* @return Last element of the array. Ownership transferred.
*/
Value *pop();

/**
* Inserts a new Value into the elements of the array at an
* arbitrary location. The new Value's index will be @a index.
* @param index Index for the new Value.
* @param value Value to add. The array takes ownership of the object.
*/
void insert(dint index, Value *value);

/**
* Replaces an existing Value in the array. The previous value
* at the index will be destroyed.
*
* @param index Index of the Value.
* @param value New value. The array takes ownership of the object.
*/
void replace(dint index, Value *value);

/**
* Removes a Value from the array. The Value will be destroyed.
* @param index Index of the Value to remove.
*/
void remove(dint index);

/**
* Returns a reference to a value in the array.
*
* @param index Index of the element.
*
* @return Element at the index.
*/
Value const &at(dint index) const;

Value const &front() const { return at(0); }

Value const &back() const { return at(size() - 1); }

/**
* Empties the array of all values.
*/
void clear();

/// Reverse the order of the elements.
void reverse();

// Implementations of pure virtual methods.
Value *duplicate() const;
Text asText() const;
dsize size() const;
Value const &element(Value const &index) const;
Value &element(Value const &index);
void setElement(Value const &index, Value *value);
bool contains(Value const &value) const;
Value *begin();
Value *next();
bool isTrue() const;
dint compare(Value const &value) const;
void sum(Value const &value);

// Implements ISerializable.
void operator >> (Writer &to) const;
void operator << (Reader &from);

private:
Elements::iterator indexToIterator(dint index);
Elements::const_iterator indexToIterator(dint index) const;

private:
Elements _elements;

/// Current position of the iterator.
dint _iteration;
};
}
void replace(dint index, Value *value);

/**
* Removes a Value from the array. The Value will be destroyed.
* @param index Index of the Value to remove.
*/
void remove(dint index);

/**
* Returns a reference to a value in the array.
*
* @param index Index of the element.
*
* @return Element at the index.
*/
Value const &at(dint index) const;

Value const &front() const { return at(0); }

Value const &back() const { return at(size() - 1); }

/**
* Empties the array of all values.
*/
void clear();

/// Reverse the order of the elements.
void reverse();

// Implementations of pure virtual methods.
Value *duplicate() const;
Text asText() const;
dsize size() const;
Value const &element(Value const &index) const;
Value &element(Value const &index);
void setElement(Value const &index, Value *value);
bool contains(Value const &value) const;
Value *begin();
Value *next();
bool isTrue() const;
dint compare(Value const &value) const;
void sum(Value const &value);

// Implements ISerializable.
void operator >> (Writer &to) const;
void operator << (Reader &from);

private:
Elements::iterator indexToIterator(dint index);
Elements::const_iterator indexToIterator(dint index) const;

private:
Elements _elements;

/// Current position of the iterator.
dint _iteration;
};

} // namespace de

#endif /* LIBDENG2_ARRAYVALUE_H */

0 comments on commit 3739b59

Please sign in to comment.