Newer
Older
Import / projects / Gameloft / bne_lib / code / Utils / Cast.h
@John John on 29 Dec 2020 490 bytes bulk import from macbookpro checkouts
#ifndef __CC_CAST__
#define __CC_CAST__

#include <RKObject.h>

template <class T>
T* ccptr_cast(RKObject* obj) {
  if (obj &&
      obj->IsClass<T>())
  {
    return static_cast<T*>(obj);
  }
  return static_cast<T*>(nullptr);
}

template <class T>
const T* ccptr_cast(const RKObject* obj) {
  if (obj &&
      obj->IsClass<T>())
  {
    return static_cast<const T*>(obj);
  }
  return static_cast<const T*>(nullptr);
}

#define CCPTR_CAST(ClassDef, obj) ccptr_cast<ClassDef>(obj)

#endif