1. Jens Alfke
  2. fudge-cpp

Source

fudge-cpp / src / internal.h

/*
 *  fudge/internal.h
 *  Fudge
 *
 *  Created by Jens Alfke on 4/25/11.
 *  Copyright 2011 Jens Alfke. All rights reserved.
 *
 */

#include <CoreFoundation/CFByteOrder.h>

namespace fudge {

const uint32_t kNoFixedSize = 0xFFFFFFFF;

extern uint32_t kFixedSizesByType[];
   

//////// OS-specific utilities for handling big-endian numeric formats:
    

inline int16_t getShort(const void* ptr) {
    return (int16_t)CFSwapInt16BigToHost(*(const uint16_t*)ptr);
}

inline int32_t getInt(const void* ptr) {
    return (int32_t)CFSwapInt32BigToHost(*(const uint32_t*)ptr);
}

inline int64_t getLong(const void* ptr) {
    return (int64_t)CFSwapInt64BigToHost(*(const uint64_t*)ptr);
}

inline float getFloat(const void* ptr) {
    return CFConvertFloat32SwappedToHost(*(const CFSwappedFloat32*)ptr);
}

inline double getDouble(const void* ptr) {
    return CFConvertFloat64SwappedToHost(*(const CFSwappedFloat64*)ptr);
}
    
}