libc++: adapt to core libc
This commit is contained in:
parent
867cdc0098
commit
ff8a6fe6e5
@ -9,7 +9,8 @@ message($$PREFIX_DIR)
|
||||
TEMPLATE = lib
|
||||
TARGET = fougstl-c++$$TARGET_SUFFIX
|
||||
DESTDIR = $$PREFIX_DIR/lib
|
||||
CONFIG *= dll
|
||||
|
||||
DEFINES *= FOUG_USE_STDINT_H
|
||||
|
||||
dll {
|
||||
DEFINES *= FOUG_STL_DLL FOUG_STL_MAKE_DLL
|
||||
@ -40,13 +41,13 @@ SOURCES += \
|
||||
../../../src/c++/libstl/stlb.cpp \
|
||||
../../../src/c++/libstl/stla.cpp
|
||||
|
||||
global_inc.path = $$PREFIX_DIR/include
|
||||
global_inc.path = $$PREFIX_DIR/include/dataex
|
||||
global_inc.files = ../../../src/*.h
|
||||
cpp_global_inc.path = $$PREFIX_DIR/include/c++
|
||||
cpp_global_inc.path = $$PREFIX_DIR/include/dataex/c++
|
||||
cpp_global_inc.files = ../../../src/c++/*.h
|
||||
cpp_streams_inc.path = $$PREFIX_DIR/include/c++/streams
|
||||
cpp_streams_inc.path = $$PREFIX_DIR/include/dataex/c++/streams
|
||||
cpp_streams_inc.files = ../../../src/c++/streams/*.h
|
||||
cpp_libstl_inc.path = $$PREFIX_DIR/include/c++/libstl
|
||||
cpp_libstl_inc.path = $$PREFIX_DIR/include/dataex/c++/libstl
|
||||
cpp_libstl_inc.files = ../../../src/c++/libstl/*.h
|
||||
INSTALLS += global_inc cpp_global_inc cpp_streams_inc cpp_libstl_inc
|
||||
|
||||
|
@ -14,9 +14,9 @@ public:
|
||||
virtual bool isReadable() const = 0;
|
||||
virtual bool isSequential() const = 0;
|
||||
|
||||
virtual bool seek(foug::Int64 pos) = 0;
|
||||
virtual Int64 read(char* data, Int64 maxSize) = 0;
|
||||
virtual Int64 write(const char* data, Int64 maxSize) = 0;
|
||||
virtual bool seek(int64_t pos) = 0;
|
||||
virtual int64_t read(char* data, int64_t maxSize) = 0;
|
||||
virtual int64_t write(const char* data, int64_t maxSize) = 0;
|
||||
};
|
||||
|
||||
} // namespace foug
|
||||
|
@ -1,24 +1,12 @@
|
||||
#ifndef FOUG_CPP_GLOBAL_H
|
||||
#define FOUG_CPP_GLOBAL_H
|
||||
|
||||
#include "../c/foug_global.h"
|
||||
#include "../c/global.h"
|
||||
|
||||
namespace foug {
|
||||
|
||||
typedef foug_int8 Int8;
|
||||
typedef foug_uint8 UInt8;
|
||||
|
||||
typedef foug_int16 Int16;
|
||||
typedef foug_uint16 UInt16;
|
||||
|
||||
typedef foug_int32 Int32;
|
||||
typedef foug_uint32 UInt32;
|
||||
|
||||
typedef foug_int64 Int64;
|
||||
typedef foug_uint64 UInt64;
|
||||
|
||||
typedef foug_real32 Real32;
|
||||
typedef foug_real64 Real64;
|
||||
typedef foug_real32_t Real32;
|
||||
typedef foug_real64_t Real64;
|
||||
|
||||
} // namespace foug
|
||||
|
||||
|
@ -30,8 +30,8 @@ typedef Triangle<Coords> Triangle;
|
||||
class FOUG_STL_EXPORT AbstractGeometry
|
||||
{
|
||||
public:
|
||||
virtual UInt32 triangleCount() const = 0;
|
||||
virtual void getTriangle(UInt32 index, Triangle* triangle) const = 0;
|
||||
virtual uint32_t triangleCount() const = 0;
|
||||
virtual void getTriangle(uint32_t index, Triangle* triangle) const = 0;
|
||||
};
|
||||
|
||||
} // namespace stl
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace foug {
|
||||
namespace stla {
|
||||
|
||||
bool Io::read(AbstractGeometryBuilder* builder, Int64 streamSize)
|
||||
bool Io::read(AbstractGeometryBuilder* builder, int64_t streamSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class FOUG_STL_EXPORT Io : public IoBase
|
||||
public:
|
||||
Io(AbstractStream* stream = 0);
|
||||
|
||||
bool read(AbstractGeometryBuilder* builder, Int64 streamSize = -1);
|
||||
bool read(AbstractGeometryBuilder* builder, int64_t streamSize = -1);
|
||||
bool write(const stl::AbstractGeometry& geom, const std::string& solidName);
|
||||
};
|
||||
|
||||
|
@ -7,46 +7,46 @@
|
||||
// Read tools
|
||||
|
||||
template<typename NUMERIC>
|
||||
NUMERIC fromLittleEndian(const foug::UInt8* bytes)
|
||||
NUMERIC fromLittleEndian(const uint8_t* bytes)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
foug::UInt16 fromLittleEndian<foug::UInt16>(const foug::UInt8* bytes)
|
||||
uint16_t fromLittleEndian<uint16_t>(const uint8_t* bytes)
|
||||
{
|
||||
// |BB|AA| -> 0xAABB
|
||||
return (bytes[1] << 8) | bytes[0];
|
||||
}
|
||||
|
||||
template<>
|
||||
foug::UInt32 fromLittleEndian<foug::UInt32>(const foug::UInt8* bytes)
|
||||
uint32_t fromLittleEndian<uint32_t>(const uint8_t* bytes)
|
||||
{
|
||||
// |DD|CC|BB|AA| -> 0xAABBCCDD
|
||||
return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
|
||||
}
|
||||
|
||||
template<>
|
||||
foug::Real32 fromLittleEndian<foug::Real32>(const foug::UInt8* bytes)
|
||||
foug::Real32 fromLittleEndian<foug::Real32>(const uint8_t* bytes)
|
||||
{
|
||||
union
|
||||
{
|
||||
foug::UInt32 asInteger;
|
||||
uint32_t asInteger;
|
||||
foug::Real32 asFloat;
|
||||
} helper;
|
||||
|
||||
helper.asInteger = fromLittleEndian<foug::UInt32>(bytes);
|
||||
helper.asInteger = fromLittleEndian<uint32_t>(bytes);
|
||||
return helper.asFloat;
|
||||
}
|
||||
|
||||
// Write tools
|
||||
|
||||
template<typename NUMERIC>
|
||||
void toLittleEndian(NUMERIC n, foug::UInt8* bytes)
|
||||
void toLittleEndian(NUMERIC n, uint8_t* bytes)
|
||||
{
|
||||
union {
|
||||
NUMERIC asNumeric;
|
||||
foug::UInt8 asBytes[sizeof(NUMERIC)];
|
||||
uint8_t asBytes[sizeof(NUMERIC)];
|
||||
} helper;
|
||||
helper.asNumeric = n;
|
||||
// std::copy(helper.asBytes, helper.asBytes + sizeof(NUMERIC), bytes);
|
||||
@ -59,13 +59,13 @@ namespace stlb {
|
||||
|
||||
static const int stlFacetSize = 50;
|
||||
static const int stlMinFileSize = 284;
|
||||
static const int stlTriangleDataSize = (4 * 3) * sizeof(foug::Real32) + sizeof(foug::UInt16);
|
||||
static const int stlTriangleDataSize = (4 * 3) * sizeof(foug::Real32) + sizeof(uint16_t);
|
||||
|
||||
void AbstractGeometryBuilder::processHeader(const Header& /*data*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AbstractGeometryBuilder::beginTriangles(UInt32 /*count*/)
|
||||
void AbstractGeometryBuilder::beginTriangles(uint32_t /*count*/)
|
||||
{
|
||||
}
|
||||
|
||||
@ -95,9 +95,9 @@ bool Io::read(AbstractGeometryBuilder* builder)
|
||||
|
||||
AbstractStream* istream = this->stream();
|
||||
AbstractTaskProgress* progress = this->taskProgress();
|
||||
const UInt32 chunkSize = stlTriangleDataSize * 163;
|
||||
const uint32_t chunkSize = stlTriangleDataSize * 163;
|
||||
|
||||
UInt8 buffer[8192];
|
||||
uint8_t buffer[8192];
|
||||
char* charBuffer = reinterpret_cast<char*>(buffer);
|
||||
|
||||
// Read header
|
||||
@ -107,9 +107,9 @@ bool Io::read(AbstractGeometryBuilder* builder)
|
||||
builder->processHeader(headerData);
|
||||
|
||||
// Read facet count
|
||||
if (istream->read(charBuffer, sizeof(UInt32)) != sizeof(UInt32))
|
||||
if (istream->read(charBuffer, sizeof(uint32_t)) != sizeof(uint32_t))
|
||||
return false;
|
||||
const UInt32 facetCount = ::fromLittleEndian<UInt32>(buffer);
|
||||
const uint32_t facetCount = ::fromLittleEndian<uint32_t>(buffer);
|
||||
builder->beginTriangles(facetCount);
|
||||
|
||||
if (progress != 0) {
|
||||
@ -118,16 +118,16 @@ bool Io::read(AbstractGeometryBuilder* builder)
|
||||
}
|
||||
|
||||
// Read triangles
|
||||
const UInt64 totalFacetSize = stlTriangleDataSize * facetCount;
|
||||
UInt64 amountReadSize = 0;
|
||||
const uint64_t totalFacetSize = stlTriangleDataSize * facetCount;
|
||||
uint64_t amountReadSize = 0;
|
||||
stl::Triangle triangle;
|
||||
bool streamError = false;
|
||||
while (amountReadSize < totalFacetSize && !streamError) {
|
||||
const Int64 iReadSize = istream->read(charBuffer, chunkSize);
|
||||
const int64_t iReadSize = istream->read(charBuffer, chunkSize);
|
||||
if (iReadSize > 0 && (iReadSize % stlTriangleDataSize == 0)) {
|
||||
const UInt32 iFacetCount = iReadSize / stlTriangleDataSize;
|
||||
UInt32 bufferOffset = 0;
|
||||
for (UInt32 i = 0; i < iFacetCount; ++i) {
|
||||
const uint32_t iFacetCount = iReadSize / stlTriangleDataSize;
|
||||
uint32_t bufferOffset = 0;
|
||||
for (uint32_t i = 0; i < iFacetCount; ++i) {
|
||||
// Read normal
|
||||
triangle.normal.x = ::fromLittleEndian<Real32>(buffer + bufferOffset);
|
||||
triangle.normal.y = ::fromLittleEndian<Real32>(buffer + 1*sizeof(Real32) + bufferOffset);
|
||||
@ -149,8 +149,8 @@ bool Io::read(AbstractGeometryBuilder* builder)
|
||||
triangle.v3.z = ::fromLittleEndian<Real32>(buffer + 11*sizeof(Real32) + bufferOffset);
|
||||
|
||||
// Attribute byte count
|
||||
const UInt16 attributeByteCount =
|
||||
::fromLittleEndian<UInt16>(buffer + 12*sizeof(Real32) + bufferOffset);
|
||||
const uint16_t attributeByteCount =
|
||||
::fromLittleEndian<uint16_t>(buffer + 12*sizeof(Real32) + bufferOffset);
|
||||
|
||||
// Add triangle
|
||||
builder->processNextTriangle(triangle, attributeByteCount);
|
||||
@ -189,7 +189,7 @@ bool Io::write(const stl::AbstractGeometry& geom, const AbstractGeometryExtraDat
|
||||
AbstractStream* ostream = this->stream();
|
||||
AbstractTaskProgress* progress = this->taskProgress();
|
||||
|
||||
UInt8 buffer[128];
|
||||
uint8_t buffer[128];
|
||||
|
||||
// Write header
|
||||
Header headerData;
|
||||
@ -202,9 +202,9 @@ bool Io::write(const stl::AbstractGeometry& geom, const AbstractGeometryExtraDat
|
||||
return false;
|
||||
|
||||
// Write facet count
|
||||
const UInt32 facetCount = geom.triangleCount();
|
||||
::toLittleEndian<UInt32>(facetCount, buffer);
|
||||
if (ostream->write(reinterpret_cast<char*>(&buffer), sizeof(UInt32)) != sizeof(UInt32))
|
||||
const uint32_t facetCount = geom.triangleCount();
|
||||
::toLittleEndian<uint32_t>(facetCount, buffer);
|
||||
if (ostream->write(reinterpret_cast<char*>(&buffer), sizeof(uint32_t)) != sizeof(uint32_t))
|
||||
return false;
|
||||
|
||||
if (progress != 0) {
|
||||
@ -214,7 +214,7 @@ bool Io::write(const stl::AbstractGeometry& geom, const AbstractGeometryExtraDat
|
||||
|
||||
// Write triangles
|
||||
stl::Triangle triangle;
|
||||
for (UInt32 facet = 0; facet < facetCount; ++facet) {
|
||||
for (uint32_t facet = 0; facet < facetCount; ++facet) {
|
||||
geom.getTriangle(facet, &triangle);
|
||||
|
||||
// Write normal
|
||||
@ -238,8 +238,8 @@ bool Io::write(const stl::AbstractGeometry& geom, const AbstractGeometryExtraDat
|
||||
::toLittleEndian<Real32>(triangle.v3.z, buffer + 11*sizeof(Real32));
|
||||
|
||||
// Attribute byte count
|
||||
const UInt16 attrByteCount = extraData != 0 ? extraData->attributeByteCount(facet) : 0;
|
||||
::toLittleEndian<UInt16>(attrByteCount, buffer + 12*sizeof(Real32));
|
||||
const uint16_t attrByteCount = extraData != 0 ? extraData->attributeByteCount(facet) : 0;
|
||||
::toLittleEndian<uint16_t>(attrByteCount, buffer + 12*sizeof(Real32));
|
||||
|
||||
// Write to stream
|
||||
if (ostream->write(reinterpret_cast<const char*>(buffer), stlTriangleDataSize)
|
||||
|
@ -10,14 +10,14 @@ namespace foug {
|
||||
namespace stlb {
|
||||
|
||||
enum { HeaderSize = 80 };
|
||||
typedef UInt8 Header[HeaderSize];
|
||||
typedef uint8_t Header[HeaderSize];
|
||||
|
||||
class FOUG_STL_EXPORT AbstractGeometryBuilder
|
||||
{
|
||||
public:
|
||||
virtual void processHeader(const Header& data);
|
||||
virtual void beginTriangles(UInt32 count);
|
||||
virtual void processNextTriangle(const stl::Triangle& triangle, UInt16 attributeByteCount) = 0;
|
||||
virtual void beginTriangles(uint32_t count);
|
||||
virtual void processNextTriangle(const stl::Triangle& triangle, uint16_t attributeByteCount) = 0;
|
||||
virtual void endTriangles();
|
||||
};
|
||||
|
||||
@ -25,7 +25,7 @@ class FOUG_STL_EXPORT AbstractGeometryExtraData
|
||||
{
|
||||
public:
|
||||
virtual void getHeader(Header& data) const = 0;
|
||||
virtual UInt16 attributeByteCount(UInt32 triangleIndex) const = 0;
|
||||
virtual uint16_t attributeByteCount(uint32_t triangleIndex) const = 0;
|
||||
};
|
||||
|
||||
class FOUG_STL_EXPORT Io : public IoBase
|
||||
|
@ -30,17 +30,17 @@ bool Qt4Stream::isSequential() const
|
||||
return m_device != 0 ? m_device->isSequential() : false;
|
||||
}
|
||||
|
||||
bool Qt4Stream::seek(Int64 pos)
|
||||
bool Qt4Stream::seek(int64_t pos)
|
||||
{
|
||||
return m_device->seek(pos);
|
||||
}
|
||||
|
||||
Int64 Qt4Stream::read(char *data, Int64 maxSize)
|
||||
int64_t Qt4Stream::read(char *data, int64_t maxSize)
|
||||
{
|
||||
return m_device->read(data, maxSize);
|
||||
}
|
||||
|
||||
Int64 Qt4Stream::write(const char *data, Int64 maxSize)
|
||||
int64_t Qt4Stream::write(const char *data, int64_t maxSize)
|
||||
{
|
||||
return m_device->write(data, maxSize);
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ public:
|
||||
bool isReadable() const;
|
||||
bool isSequential() const;
|
||||
|
||||
bool seek(foug::Int64 pos);
|
||||
Int64 read(char* data, Int64 maxSize);
|
||||
Int64 write(const char* data, Int64 maxSize);
|
||||
bool seek(int64_t pos);
|
||||
int64_t read(char* data, int64_t maxSize);
|
||||
int64_t write(const char* data, int64_t maxSize);
|
||||
|
||||
private:
|
||||
QIODevice* m_device;
|
||||
|
Loading…
Reference in New Issue
Block a user