Skip to content

Commit

Permalink
NULL to nullptr
Browse files Browse the repository at this point in the history
Use nullptr instead of the NULL macro. Adds some level of type safety
and doesn't require a header to be included.

Also change documentation to use the term null-terminated instead of
NULL-terminated.

Signed-off-by: Ralph Sennhauser <[email protected]>
  • Loading branch information
seragh committed Aug 24, 2024
1 parent 669c614 commit c1fcb80
Show file tree
Hide file tree
Showing 225 changed files with 2,210 additions and 2,210 deletions.
2 changes: 1 addition & 1 deletion FCollada/DLLEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#ifdef FCOLLADA_DLL
#ifdef WIN32
HINSTANCE hInstance = NULL;
HINSTANCE hInstance = nullptr;

BOOL WINAPI DllMain(HINSTANCE _hInstance, ULONG fdwReason, LPVOID UNUSED(lpvReserved))
{
Expand Down
28 changes: 14 additions & 14 deletions FCollada/FCDocument/FCDAnimated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ImplementObjectType(FCDAnimated)

FCDAnimated::FCDAnimated(FCDocument* document, size_t valueCount, const char** _qualifiers, float** _values)
: FCDObject(document)
, target(NULL)
, target(nullptr)
{
arrayElement = -1;

Expand Down Expand Up @@ -120,15 +120,15 @@ float* FCDAnimated::FindValue(const fm::string& qualifier)
{
if (qualifiers[i] == qualifier) return values[i];
}
return NULL;
return nullptr;
}
const float* FCDAnimated::FindValue(const fm::string& qualifier) const
{
for (size_t i = 0; i < qualifiers.size(); ++i)
{
if (qualifiers[i] == qualifier) return values[i];
}
return NULL;
return nullptr;
}

// Retrieve the index of a given qualifier
Expand Down Expand Up @@ -163,7 +163,7 @@ void FCDAnimated::SetTargetObject(FCDObject* _target)
TrackObject(target);
}

// Returns whether any of the contained curves are non-NULL
// Returns whether any of the contained curves are non-nullptr
bool FCDAnimated::HasCurve() const
{
FCDAnimationCurveListList::const_iterator cit;
Expand All @@ -181,7 +181,7 @@ FCDAnimationMultiCurve* FCDAnimated::CreateMultiCurve() const

fm::pvector<const FCDAnimationCurve> toMerge;
toMerge.resize(count);
for (size_t i = 0; i < count; ++i) toMerge[i] = (!curves[i].empty()) ? curves[i][0] : NULL;
for (size_t i = 0; i < count; ++i) toMerge[i] = (!curves[i].empty()) ? curves[i][0] : nullptr;
return FCDAnimationCurveTools::MergeCurves(toMerge, defaultValues);
}

Expand Down Expand Up @@ -225,13 +225,13 @@ void FCDAnimated::Evaluate(float time)
{
// Retrieve the curve and the corresponding value
FCDAnimationCurve* curve = curves[i][0];
if (curve == NULL) continue;
if (curve == nullptr) continue;
float* value = values[i];
if (value == NULL) continue;
if (value == nullptr) continue;

// Evaluate the curve at this time
(*value) = curve->Evaluate(time);
if (target != NULL) target->SetValueChange();
if (target != nullptr) target->SetValueChange();
}
}
}
Expand Down Expand Up @@ -270,7 +270,7 @@ FCDAnimated* FCDAnimated::Clone(FCDocument* document) const

FCDAnimated* FCDAnimated::Clone(FCDAnimated* clone) const
{
if (clone != NULL)
if (clone != nullptr)
{
// Clone the miscellaneous parameters.
clone->arrayElement = arrayElement;
Expand All @@ -289,7 +289,7 @@ FCDAnimated* FCDAnimated::Clone(FCDAnimated* clone) const
void FCDAnimated::OnObjectReleased(FUTrackable* object)
{
FUAssert(object == target, return);
target = NULL;
target = nullptr;

// Delete ourselves. We have no job left, if something
// wants us they can reconstruct from FCDAnimationChannel
Expand All @@ -303,7 +303,7 @@ void FCDAnimated::OnObjectReleased(FUTrackable* object)
ImplementObjectType(FCDAnimatedCustom)

static const char* customAnimatedTemporaryQualifier = "";
static float* customAnimatedTemporaryValue = NULL;
static float* customAnimatedTemporaryValue = nullptr;

FCDAnimatedCustom::FCDAnimatedCustom(FCDObject* object)
: FCDAnimated(object, 1, &customAnimatedTemporaryQualifier, &customAnimatedTemporaryValue)
Expand All @@ -317,9 +317,9 @@ FCDAnimatedCustom::FCDAnimatedCustom(FCDObject* object)

void FCDAnimatedCustom::Copy(const FCDAnimated* copy)
{
if (copy != NULL)
if (copy != nullptr)
{
Resize(copy->GetValueCount(), NULL, false);
Resize(copy->GetValueCount(), nullptr, false);
copy->Clone(this);
}
}
Expand All @@ -331,7 +331,7 @@ void FCDAnimatedCustom::Resize(size_t count, const char** _qualifiers, bool prep
qualifiers.resize(count);
curves.resize(count);

for (size_t i = 0; i < count && _qualifiers != NULL && *_qualifiers != 0; ++i)
for (size_t i = 0; i < count && _qualifiers != nullptr && *_qualifiers != 0; ++i)
{
qualifiers[i] = (prependDot ? fm::string(".") : fm::string("")) + *(_qualifiers++);
}
Expand Down
34 changes: 17 additions & 17 deletions FCollada/FCDocument/FCDAnimated.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class FCOLLADA_EXPORT FCDAnimated : public FCDObject, FUTracker

/** The list of animation curves.
There is always one curve for one value pointer, although
that curve may be the NULL pointer to indicate a non-animated value. */
that curve may be the nullptr to indicate a non-animated value. */
FCDAnimationCurveListList curves;

/** The target object who contain the float values.*/
Expand Down Expand Up @@ -119,12 +119,12 @@ class FCOLLADA_EXPORT FCDAnimated : public FCDObject, FUTracker
@param curveIndex The index of the curve within the list of curves affecting the
value at the given index.
@return The curve affecting the value at the given index. This pointer will
be NULL if one of the index is out-of-bounds or if the value is not animated. */
inline FCDAnimationCurve* GetCurve(size_t index, size_t curveIndex = 0) { FUAssert(index < GetValueCount(), return NULL); return curveIndex < curves.at(index).size() ? curves.at(index).at(curveIndex) : NULL; }
inline const FCDAnimationCurve* GetCurve(size_t index, size_t curveIndex = 0) const { FUAssert(index < GetValueCount(), return NULL); return curveIndex < curves.at(index).size() ? curves.at(index).at(curveIndex) : NULL; } /**< See above. */
be nullptr if one of the index is out-of-bounds or if the value is not animated. */
inline FCDAnimationCurve* GetCurve(size_t index, size_t curveIndex = 0) { FUAssert(index < GetValueCount(), return nullptr); return curveIndex < curves.at(index).size() ? curves.at(index).at(curveIndex) : nullptr; }
inline const FCDAnimationCurve* GetCurve(size_t index, size_t curveIndex = 0) const { FUAssert(index < GetValueCount(), return nullptr); return curveIndex < curves.at(index).size() ? curves.at(index).at(curveIndex) : nullptr; } /**< See above. */

/** Retrieves the list of the curves affecting the values of an animated element.
This list may contain the NULL pointer, where a value is not animated.
This list may contain the nullptr, where a value is not animated.
@return The list of animation curves. */
inline FCDAnimationCurveListList& GetCurves() { return curves; }
inline const FCDAnimationCurveListList& GetCurves() const { return curves; } /**< See above. */
Expand All @@ -147,9 +147,9 @@ class FCOLLADA_EXPORT FCDAnimated : public FCDObject, FUTracker
/** Retrieves the value of an animated element.
@param index The value index.
@return The value at the given index. This pointer will
be NULL if the index is out-of-boudns. */
inline float* GetValue(size_t index) { FUAssert(index < GetValueCount(), return NULL); return values.at(index); }
inline const float* GetValue(size_t index) const { FUAssert(index < GetValueCount(), return NULL); return values.at(index); } /**< See above. */
be nullptr if the index is out-of-boudns. */
inline float* GetValue(size_t index) { FUAssert(index < GetValueCount(), return nullptr); return values.at(index); }
inline const float* GetValue(size_t index) const { FUAssert(index < GetValueCount(), return nullptr); return values.at(index); } /**< See above. */

/** [INTERNAL] Overwrites the value pointer of an animated element.
Used when changing the list size within FCDParameterAnimatableList.
Expand All @@ -171,27 +171,27 @@ class FCOLLADA_EXPORT FCDAnimated : public FCDObject, FUTracker
/** Retrieves an animated value given a valid qualifier.
@param qualifier A valid qualifier.
@return The animated value for this qualifier. This pointer will be
NULL if the given qualifier is not used within this animated element. */
nullptr if the given qualifier is not used within this animated element. */
float* FindValue(const fm::string& qualifier);
const float* FindValue(const fm::string& qualifier) const; /**< See above. */

/** Retrieves an animation curve given a valid qualifier.
@param qualifier A valid qualifier.
@return The animation curve for this qualifier. This pointer will be
NULL if the given qualifier is not used within this animated element
nullptr if the given qualifier is not used within this animated element
or if the value for the given qualifier is not animated. */
inline FCDAnimationCurve* FindCurve(const char* qualifier) { size_t index = FindQualifier(qualifier); return index < GetValueCount() ? GetCurve(index) : NULL; }
inline FCDAnimationCurve* FindCurve(const char* qualifier) { size_t index = FindQualifier(qualifier); return index < GetValueCount() ? GetCurve(index) : nullptr; }
inline FCDAnimationCurve* FindCurve(const fm::string& qualifier) { return FindCurve(qualifier.c_str()); } /**< See above. */
inline const FCDAnimationCurve* FindCurve(const char* qualifier) const { size_t index = FindQualifier(qualifier); return index < GetValueCount() ? GetCurve(index) : NULL; } /**< See above. */
inline const FCDAnimationCurve* FindCurve(const char* qualifier) const { size_t index = FindQualifier(qualifier); return index < GetValueCount() ? GetCurve(index) : nullptr; } /**< See above. */
inline const FCDAnimationCurve* FindCurve(const fm::string& qualifier) const { return FindCurve(qualifier.c_str()); } /**< See above. */

/** Retrieves an animation curve given a value pointer.
@param value A value pointer contained within the animated element.
@return The animation curve for this qualifier. This pointer will be
NULL if the value pointer is not contained by this animated element
nullptr if the value pointer is not contained by this animated element
or if the value is not animated. */
inline FCDAnimationCurve* FindCurve(const float* value) { size_t index = FindValue(value); return index < GetValueCount() ? GetCurve(index) : NULL; }
inline const FCDAnimationCurve* FindCurve(const float* value) const { size_t index = FindValue(value); return index < GetValueCount() ? GetCurve(index) : NULL; } /**< See above. */
inline FCDAnimationCurve* FindCurve(const float* value) { size_t index = FindValue(value); return index < GetValueCount() ? GetCurve(index) : nullptr; }
inline const FCDAnimationCurve* FindCurve(const float* value) const { size_t index = FindValue(value); return index < GetValueCount() ? GetCurve(index) : nullptr; } /**< See above. */

/** Retrieves the value index for a given qualifier.
@param qualifier A valid qualifier.
Expand Down Expand Up @@ -303,7 +303,7 @@ class FCOLLADA_EXPORT FCDAnimatedCustom : public FCDAnimated
@param count The new size of the animated element.
@param qualifiers The new qualifiers for the animated element.
@param prependDot Whether to prepend the '.' character for all the qualifiers of the animated element. */
void Resize(size_t count, const char** qualifiers = NULL, bool prependDot = true);
void Resize(size_t count, const char** qualifiers = nullptr, bool prependDot = true);

/** Resizes the wanted qualifiers.
@param qualifiers The new qualifiers for the animated element.
Expand All @@ -315,7 +315,7 @@ class FCOLLADA_EXPORT FCDAnimatedCustom : public FCDAnimated
namespace FCDAnimatedStandardQualifiers
{
/** Common accessor type string arrays.
These are NULL-terminated and can be used with the AddAccessor function. */
These are null-terminated and can be used with the AddAccessor function. */
FCOLLADA_EXPORT extern const char* EMPTY[1]; /**< Used for qualifying single values. */
FCOLLADA_EXPORT extern const char* XYZW[4]; /**< Used for position and vector values. */
FCOLLADA_EXPORT extern const char* RGBA[4]; /**< Used for color value. */
Expand Down
16 changes: 8 additions & 8 deletions FCollada/FCDocument/FCDAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ FCDAnimation::FCDAnimation(FCDocument* document, FCDAnimation* _parent)
FCDAnimation::~FCDAnimation()
{
// childNodes.clear();
parent = NULL;
parent = nullptr;
}

FCDEntity* FCDAnimation::Clone(FCDEntity* _clone, bool cloneChildren) const
{
FCDAnimation* clone = NULL;
if (_clone == NULL) _clone = clone = new FCDAnimation(const_cast<FCDocument*>(GetDocument()), NULL);
FCDAnimation* clone = nullptr;
if (_clone == nullptr) _clone = clone = new FCDAnimation(const_cast<FCDocument*>(GetDocument()), nullptr);
else if (_clone->HasType(FCDAnimation::GetClassType())) clone = (FCDAnimation*) _clone;

Parent::Clone(_clone, cloneChildren);

if (clone != NULL)
if (clone != nullptr)
{
// Clone the channels
for (const FCDAnimationChannel** it = channels.begin(); it != channels.end(); ++it)
Expand Down Expand Up @@ -97,18 +97,18 @@ const FCDEntity* FCDAnimation::FindDaeId(const fm::string& daeId) const
for (const FCDAnimation** it = children.begin(); it != children.end(); ++it)
{
const FCDEntity* found = (*it)->FindDaeId(daeId);
if (found != NULL) return found;
if (found != nullptr) return found;
}
return NULL;
return nullptr;
}

void FCDAnimation::GetHierarchicalAssets(FCDAssetConstList& assets) const
{
for (const FCDAnimation* animation = this; animation != NULL; animation = animation->GetParent())
for (const FCDAnimation* animation = this; animation != nullptr; animation = animation->GetParent())
{
// Retrieve the asset information structure for this node.
const FCDAsset* asset = animation->GetAsset();
if (asset != NULL) assets.push_back(asset);
if (asset != nullptr) assets.push_back(asset);
}
assets.push_back(GetDocument()->GetAsset());
}
Expand Down
24 changes: 12 additions & 12 deletions FCollada/FCDocument/FCDAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class FCOLLADA_EXPORT FCDAnimation : public FCDEntity
or the AddChild function, depending on the
hierarchical level of the animation entity.
@param document The FCollada document that owns the animation entity.
@param parent The parent animation entity. This pointer will be NULL for root animation entities. */
FCDAnimation(FCDocument* document, FCDAnimation* parent = NULL);
@param parent The parent animation entity. This pointer will be nullptr for root animation entities. */
FCDAnimation(FCDocument* document, FCDAnimation* parent = nullptr);

/** Destructor .*/
virtual ~FCDAnimation();
Expand All @@ -75,26 +75,26 @@ class FCOLLADA_EXPORT FCDAnimation : public FCDEntity
virtual Type GetType() const { return ANIMATION; }

/** Retrieves the parent of the animation structure.
@return The animation parent. This pointer will be NULL
@return The animation parent. This pointer will be nullptr
to indicate a root-level animation structure that is
contained within the animation library. */
inline FCDAnimation* GetParent() { return parent; }
inline const FCDAnimation* GetParent() const { return parent; } /**< See above. */

/** Copies the animation tree into a clone.
The clone may reside in another document.
@param clone The empty clone. If this pointer is NULL, a new animation tree
@param clone The empty clone. If this pointer is nullptr, a new animation tree
will be created and you will need to release the returned pointer manually.
@param cloneChildren Whether to recursively clone this entity's children.
@return The clone. */
virtual FCDEntity* Clone(FCDEntity* clone = NULL, bool cloneChildren = false) const;
virtual FCDEntity* Clone(FCDEntity* clone = nullptr, bool cloneChildren = false) const;

/** Retrieves the entity with the given COLLADA id.
This function will look through the local sub-tree of animations
for the given COLLADA id.
@param daeId A COLLADA id.
@return The animation entity that matches the COLLADA id. This pointer
will be NULL if there are no animation entities that matches the COLLADA id. */
will be nullptr if there are no animation entities that matches the COLLADA id. */
virtual FCDEntity* FindDaeId(const fm::string& daeId) { return const_cast<FCDEntity*>(const_cast<const FCDAnimation*>(this)->FindDaeId(daeId)); }
virtual const FCDEntity* FindDaeId(const fm::string& daeId) const; /**< See above. */

Expand All @@ -107,9 +107,9 @@ class FCOLLADA_EXPORT FCDAnimation : public FCDEntity
animation entity tree.
@param index The index of the sub-tree.
@return The animation entity sub-tree at the given index. This pointer will
be NULL if the index is out-of-bounds. */
inline FCDAnimation* GetChild(size_t index) { FUAssert(index < children.size(), return NULL); return children.at(index); }
inline const FCDAnimation* GetChild(size_t index) const { FUAssert(index < children.size(), return NULL); return children.at(index); } /**< See above. */
be nullptr if the index is out-of-bounds. */
inline FCDAnimation* GetChild(size_t index) { FUAssert(index < children.size(), return nullptr); return children.at(index); }
inline const FCDAnimation* GetChild(size_t index) const { FUAssert(index < children.size(), return nullptr); return children.at(index); } /**< See above. */

/** Creates a new animation entity sub-tree contained within this animation entity tree.
@return The new animation sub-tree. */
Expand All @@ -133,10 +133,10 @@ class FCOLLADA_EXPORT FCDAnimation : public FCDEntity

/** Retrieves an animation channel contained by this animation entity.
@param index The index of the channel.
@return The channel at the given index. This pointer will be NULL
@return The channel at the given index. This pointer will be nullptr
if the index is out-of-bounds. */
FCDAnimationChannel* GetChannel(size_t index) { FUAssert(index < GetChannelCount(), return NULL); return channels.at(index); }
const FCDAnimationChannel* GetChannel(size_t index) const { FUAssert(index < GetChannelCount(), return NULL); return channels.at(index); } /**< See above. */
FCDAnimationChannel* GetChannel(size_t index) { FUAssert(index < GetChannelCount(), return nullptr); return channels.at(index); }
const FCDAnimationChannel* GetChannel(size_t index) const { FUAssert(index < GetChannelCount(), return nullptr); return channels.at(index); } /**< See above. */

/** [INTERNAL] Retrieves the channels' list
@deprecated
Expand Down
4 changes: 2 additions & 2 deletions FCollada/FCDocument/FCDAnimationChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ FCDAnimationChannel::FCDAnimationChannel(FCDocument* document, FCDAnimation* _pa

FCDAnimationChannel::~FCDAnimationChannel()
{
parent = NULL;
parent = nullptr;
}

FCDAnimationChannel* FCDAnimationChannel::Clone(FCDAnimationChannel* clone) const
{
if (clone == NULL) clone = new FCDAnimationChannel(const_cast<FCDocument*>(GetDocument()), NULL);
if (clone == nullptr) clone = new FCDAnimationChannel(const_cast<FCDocument*>(GetDocument()), nullptr);

// Clone the curves
for (const FCDAnimationCurve** it = curves.begin(); it != curves.end(); ++it)
Expand Down
10 changes: 5 additions & 5 deletions FCollada/FCDocument/FCDAnimationChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class FCOLLADA_EXPORT FCDAnimationChannel : public FCDObject

/** Copies the animation channel into a clone.
The clone may reside in another document.
@param clone The empty clone. If this pointer is NULL, a new animation channel
@param clone The empty clone. If this pointer is nullptr, a new animation channel
will be created and you will need to release the returned pointer manually.
@return The clone. */
FCDAnimationChannel* Clone(FCDAnimationChannel* clone = NULL) const;
FCDAnimationChannel* Clone(FCDAnimationChannel* clone = nullptr) const;

/** Retrieves the animation sub-tree that contains the animation channel.
@return The parent animation sub-tree. */
Expand All @@ -83,10 +83,10 @@ class FCOLLADA_EXPORT FCDAnimationChannel : public FCDObject

/** Retrieves an animation curve contained within the channel.
@param index The index of the animation curve.
@return The animation curve at the given index. This pointer will be NULL
@return The animation curve at the given index. This pointer will be nullptr
if the index is out-of-bounds. */
FCDAnimationCurve* GetCurve(size_t index) { FUAssert(index < GetCurveCount(), return NULL); return curves.at(index); }
const FCDAnimationCurve* GetCurve(size_t index) const { FUAssert(index < GetCurveCount(), return NULL); return curves.at(index); } /**< See above. */
FCDAnimationCurve* GetCurve(size_t index) { FUAssert(index < GetCurveCount(), return nullptr); return curves.at(index); }
const FCDAnimationCurve* GetCurve(size_t index) const { FUAssert(index < GetCurveCount(), return nullptr); return curves.at(index); } /**< See above. */

/** Adds a new animation curve to this animation channel.
@return The new animation curve. */
Expand Down
Loading

0 comments on commit c1fcb80

Please sign in to comment.