Small code cleaning. Additional check for proper values in substring method.
git-svn-id: http://svn.code.sf.net/p/irrlicht/code/trunk@1415 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
3ecc64ead9
commit
ef06f6ef9b
@ -16,10 +16,6 @@ namespace io
|
|||||||
class IFileList : public virtual IReferenceCounted
|
class IFileList : public virtual IReferenceCounted
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Destructor
|
|
||||||
virtual ~IFileList() {}
|
|
||||||
|
|
||||||
//! Get the number of files in the filelist.
|
//! Get the number of files in the filelist.
|
||||||
/** \return Amount of files and directories in the file list. */
|
/** \return Amount of files and directories in the file list. */
|
||||||
virtual u32 getFileCount() const = 0;
|
virtual u32 getFileCount() const = 0;
|
||||||
@ -37,11 +33,10 @@ public:
|
|||||||
\return File name of the file. Returns 0, if an error occured. */
|
\return File name of the file. Returns 0, if an error occured. */
|
||||||
virtual const c8* getFullFileName(u32 index) = 0;
|
virtual const c8* getFullFileName(u32 index) = 0;
|
||||||
|
|
||||||
//! Returns of the file is a directory
|
//! Check if the file is a directory
|
||||||
/** \param index is the zero based index of the file which name should
|
/** \param index The zero based index of the file whose name shall
|
||||||
be returned. The index has to be smaller than the amount getFileCount() returns.
|
be returned. The index has to be smaller than the amount getFileCount() returns.
|
||||||
\return True, if the file is a directory, and false, if it is not.
|
\return True if the file is a directory, else false. */
|
||||||
If an error occurs, the result is undefined. */
|
|
||||||
virtual bool isDirectory(u32 index) const = 0;
|
virtual bool isDirectory(u32 index) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,9 +32,6 @@ class IFileSystem : public virtual IReferenceCounted
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Destructor
|
|
||||||
virtual ~IFileSystem() {}
|
|
||||||
|
|
||||||
//! Opens a file for read access.
|
//! Opens a file for read access.
|
||||||
/** \param filename: Name of file to open.
|
/** \param filename: Name of file to open.
|
||||||
\return Returns a pointer to the created file interface.
|
\return Returns a pointer to the created file interface.
|
||||||
@ -189,7 +186,7 @@ public:
|
|||||||
//! Creates a new empty collection of attributes, usable for serialization and more.
|
//! Creates a new empty collection of attributes, usable for serialization and more.
|
||||||
/** \param driver: Video driver to be used to load textures when specified as attribute values.
|
/** \param driver: Video driver to be used to load textures when specified as attribute values.
|
||||||
Can be null to prevent automatic texture loading by attributes.
|
Can be null to prevent automatic texture loading by attributes.
|
||||||
\return Returns a pointer to the created object.
|
\return Pointer to the created object.
|
||||||
If you no longer need the object, you should call IAttributes::drop().
|
If you no longer need the object, you should call IAttributes::drop().
|
||||||
See IReferenceCounted::drop() for more information. */
|
See IReferenceCounted::drop() for more information. */
|
||||||
virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver=0) = 0;
|
virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver=0) = 0;
|
||||||
|
@ -223,7 +223,6 @@ public:
|
|||||||
parentAbsoluteClip = Parent->AbsoluteClippingRect;
|
parentAbsoluteClip = Parent->AbsoluteClippingRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
diffx = parentAbsolute.getWidth() - LastParentRect.getWidth();
|
diffx = parentAbsolute.getWidth() - LastParentRect.getWidth();
|
||||||
diffy = parentAbsolute.getHeight() - LastParentRect.getHeight();
|
diffy = parentAbsolute.getHeight() - LastParentRect.getHeight();
|
||||||
|
|
||||||
@ -233,7 +232,6 @@ public:
|
|||||||
if (AlignTop == EGUIA_SCALE || AlignBottom == EGUIA_SCALE)
|
if (AlignTop == EGUIA_SCALE || AlignBottom == EGUIA_SCALE)
|
||||||
fh = (f32)parentAbsolute.getHeight();
|
fh = (f32)parentAbsolute.getHeight();
|
||||||
|
|
||||||
|
|
||||||
switch (AlignLeft)
|
switch (AlignLeft)
|
||||||
{
|
{
|
||||||
case EGUIA_UPPERLEFT:
|
case EGUIA_UPPERLEFT:
|
||||||
@ -296,8 +294,8 @@ public:
|
|||||||
|
|
||||||
RelativeRect = DesiredRect;
|
RelativeRect = DesiredRect;
|
||||||
|
|
||||||
s32 w = RelativeRect.getWidth();
|
const s32 w = RelativeRect.getWidth();
|
||||||
s32 h = RelativeRect.getHeight();
|
const s32 h = RelativeRect.getHeight();
|
||||||
|
|
||||||
// make sure the desired rectangle is allowed
|
// make sure the desired rectangle is allowed
|
||||||
if (w < MinSize.Width)
|
if (w < MinSize.Width)
|
||||||
|
@ -16,18 +16,15 @@ namespace io
|
|||||||
class IReadFile : public virtual IReferenceCounted
|
class IReadFile : public virtual IReferenceCounted
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Destructor
|
|
||||||
virtual ~IReadFile() {}
|
|
||||||
|
|
||||||
//! Reads an amount of bytes from the file.
|
//! Reads an amount of bytes from the file.
|
||||||
/** \param buffer Pointer to buffer where to read bytes will be written to.
|
/** \param buffer Pointer to buffer where read bytes are written to.
|
||||||
\param sizeToRead Amount of bytes to read from the file.
|
\param sizeToRead Amount of bytes to read from the file.
|
||||||
\return How much bytes were read. */
|
\return How much bytes were read. */
|
||||||
virtual s32 read(void* buffer, u32 sizeToRead) = 0;
|
virtual s32 read(void* buffer, u32 sizeToRead) = 0;
|
||||||
|
|
||||||
//! Changes position in file
|
//! Changes position in file
|
||||||
/** \param finalPos: Destination position in the file.
|
/** \param finalPos Destination position in the file.
|
||||||
\param relativeMovement: If set to true, the position in the file is
|
\param relativeMovement If set to true, the position in the file is
|
||||||
changed relative to current position. Otherwise the position is changed
|
changed relative to current position. Otherwise the position is changed
|
||||||
from beginning of file.
|
from beginning of file.
|
||||||
\return True if successful, otherwise false. */
|
\return True if successful, otherwise false. */
|
||||||
|
@ -16,9 +16,6 @@ namespace io
|
|||||||
class IWriteFile : public virtual IReferenceCounted
|
class IWriteFile : public virtual IReferenceCounted
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Destructor
|
|
||||||
virtual ~IWriteFile() {}
|
|
||||||
|
|
||||||
//! Writes an amount of bytes to the file.
|
//! Writes an amount of bytes to the file.
|
||||||
/** \param buffer Pointer to buffer of bytes to write.
|
/** \param buffer Pointer to buffer of bytes to write.
|
||||||
\param sizeToWrite Amount of bytes to write to the file.
|
\param sizeToWrite Amount of bytes to write to the file.
|
||||||
|
@ -26,8 +26,6 @@ class map
|
|||||||
: LeftChild(0), RightChild(0), Parent(0), Key(k),
|
: LeftChild(0), RightChild(0), Parent(0), Key(k),
|
||||||
Value(v), IsRed(true) {}
|
Value(v), IsRed(true) {}
|
||||||
|
|
||||||
~RBTree() {}
|
|
||||||
|
|
||||||
void setLeftChild(RBTree* p)
|
void setLeftChild(RBTree* p)
|
||||||
{
|
{
|
||||||
LeftChild=p;
|
LeftChild=p;
|
||||||
@ -280,10 +278,10 @@ class map
|
|||||||
|
|
||||||
|
|
||||||
//! Parent First Iterator.
|
//! Parent First Iterator.
|
||||||
//! Traverses the tree from top to bottom. Typical usage is
|
/** Traverses the tree from top to bottom. Typical usage is
|
||||||
//! when storing the tree structure, because when reading it
|
when storing the tree structure, because when reading it
|
||||||
//! later (and inserting elements) the tree structure will
|
later (and inserting elements) the tree structure will
|
||||||
//! be the same.
|
be the same. */
|
||||||
class ParentFirstIterator
|
class ParentFirstIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -388,10 +386,10 @@ class map
|
|||||||
|
|
||||||
|
|
||||||
//! Parent Last Iterator
|
//! Parent Last Iterator
|
||||||
//! Traverse the tree from bottom to top.
|
/** Traverse the tree from bottom to top.
|
||||||
//! Typical usage is when deleting all elements in the tree
|
Typical usage is when deleting all elements in the tree
|
||||||
//! because you must delete the children before you delete
|
because you must delete the children before you delete
|
||||||
//! their parent.
|
their parent. */
|
||||||
class ParentLastIterator
|
class ParentLastIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -475,7 +473,6 @@ class map
|
|||||||
Cur = Cur->getParent();
|
Cur = Cur->getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Node* Root;
|
Node* Root;
|
||||||
Node* Cur;
|
Node* Cur;
|
||||||
}; // ParentLastIterator
|
}; // ParentLastIterator
|
||||||
@ -539,10 +536,9 @@ class map
|
|||||||
//------------------------------
|
//------------------------------
|
||||||
|
|
||||||
//! Inserts a new node into the tree
|
//! Inserts a new node into the tree
|
||||||
//! \param keyNew: the index for this value
|
/** \param keyNew: the index for this value
|
||||||
//! \param v: the value to insert
|
\param v: the value to insert
|
||||||
//! \return Returns true if successful,
|
\return True if successful, false if it fails (already exists) */
|
||||||
//! false if it fails (already exists)
|
|
||||||
bool insert(const KeyType& keyNew, const ValueType& v)
|
bool insert(const KeyType& keyNew, const ValueType& v)
|
||||||
{
|
{
|
||||||
// First insert node the "usual" way (no fancy balance logic yet)
|
// First insert node the "usual" way (no fancy balance logic yet)
|
||||||
@ -622,10 +618,9 @@ class map
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Replaces the value if the key already exists,
|
//! Replaces the value if the key already exists, otherwise inserts a new element.
|
||||||
//! otherwise inserts a new element.
|
/** \param k The index for this value
|
||||||
//! \param k: the index for this value
|
\param v The new value of */
|
||||||
//! \param v: the new value of
|
|
||||||
void set(const KeyType& k, const ValueType& v)
|
void set(const KeyType& k, const ValueType& v)
|
||||||
{
|
{
|
||||||
Node* p = find(k);
|
Node* p = find(k);
|
||||||
@ -636,9 +631,9 @@ class map
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Removes a node from the tree and returns it.
|
//! Removes a node from the tree and returns it.
|
||||||
//! The returned node must be deleted by the user
|
/** The returned node must be deleted by the user
|
||||||
//! \param k: the key to remove
|
\param k the key to remove
|
||||||
//! \return: A pointer to the node, or 0 if not found
|
\return A pointer to the node, or 0 if not found */
|
||||||
Node* delink(const KeyType& k)
|
Node* delink(const KeyType& k)
|
||||||
{
|
{
|
||||||
Node* p = find(k);
|
Node* p = find(k);
|
||||||
@ -677,7 +672,7 @@ class map
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Removes a node from the tree and deletes it.
|
//! Removes a node from the tree and deletes it.
|
||||||
//! \return True if the node was found and deleted
|
/** \return True if the node was found and deleted */
|
||||||
bool remove(const KeyType& k)
|
bool remove(const KeyType& k)
|
||||||
{
|
{
|
||||||
Node* p = find(k);
|
Node* p = find(k);
|
||||||
@ -916,7 +911,6 @@ class map
|
|||||||
//! Pull up node's left child and let it knock node down to the right
|
//! Pull up node's left child and let it knock node down to the right
|
||||||
void rotateRight(Node* p)
|
void rotateRight(Node* p)
|
||||||
{
|
{
|
||||||
|
|
||||||
Node* left = p->getLeftChild();
|
Node* left = p->getLeftChild();
|
||||||
|
|
||||||
p->setLeftChild(left->getRightChild());
|
p->setLeftChild(left->getRightChild());
|
||||||
|
@ -713,10 +713,13 @@ public:
|
|||||||
//! \param length: Length of substring.
|
//! \param length: Length of substring.
|
||||||
string<T> subString(u32 begin, s32 length) const
|
string<T> subString(u32 begin, s32 length) const
|
||||||
{
|
{
|
||||||
|
// if start after string
|
||||||
|
// or no proper substring length
|
||||||
|
if ((length <= 0) || (begin>=size()))
|
||||||
|
return string<T>("");
|
||||||
|
// clamp length to maximal value
|
||||||
if ((length+begin) > size())
|
if ((length+begin) > size())
|
||||||
length = size()-begin;
|
length = size()-begin;
|
||||||
if (length <= 0)
|
|
||||||
return string<T>("");
|
|
||||||
|
|
||||||
string<T> o;
|
string<T> o;
|
||||||
o.reserve(length+1);
|
o.reserve(length+1);
|
||||||
|
@ -217,7 +217,7 @@ public:
|
|||||||
\return True if this vector is between begin and end, false if not. */
|
\return True if this vector is between begin and end, false if not. */
|
||||||
bool isBetweenPoints(const vector2d<T>& begin, const vector2d<T>& end) const
|
bool isBetweenPoints(const vector2d<T>& begin, const vector2d<T>& end) const
|
||||||
{
|
{
|
||||||
T f = (end - begin).getLengthSQ();
|
const T f = (end - begin).getLengthSQ();
|
||||||
return getDistanceFromSQ(begin) < f &&
|
return getDistanceFromSQ(begin) < f &&
|
||||||
getDistanceFromSQ(end) < f;
|
getDistanceFromSQ(end) < f;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user