replace 'unsigned long' with uint64_t

This commit is contained in:
Andrew Meadows 2017-08-18 14:35:48 -07:00
parent 8ad41227ce
commit aee35b751e
2 changed files with 21 additions and 20 deletions

View file

@ -1636,7 +1636,7 @@ bool Octree::readFromFile(const char* fileName) {
QDataStream fileInputStream(&file); QDataStream fileInputStream(&file);
QFileInfo fileInfo(qFileName); QFileInfo fileInfo(qFileName);
unsigned long fileLength = fileInfo.size(); uint64_t fileLength = fileInfo.size();
emit importSize(1.0f, 1.0f, 1.0f); emit importSize(1.0f, 1.0f, 1.0f);
emit importProgress(0); emit importProgress(0);
@ -1713,7 +1713,7 @@ bool Octree::readFromURL(const QString& urlString) {
} }
bool Octree::readFromStream(unsigned long streamLength, QDataStream& inputStream, const QString& marketplaceID) { bool Octree::readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID) {
// decide if this is binary SVO or JSON-formatted SVO // decide if this is binary SVO or JSON-formatted SVO
QIODevice *device = inputStream.device(); QIODevice *device = inputStream.device();
char firstChar; char firstChar;
@ -1730,14 +1730,14 @@ bool Octree::readFromStream(unsigned long streamLength, QDataStream& inputStream
} }
bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStream) { bool Octree::readSVOFromStream(uint64_t streamLength, QDataStream& inputStream) {
qWarning() << "SVO file format depricated. Support for reading SVO files is no longer support and will be removed soon."; qWarning() << "SVO file format depricated. Support for reading SVO files is no longer support and will be removed soon.";
bool fileOk = false; bool fileOk = false;
PacketVersion gotVersion = 0; PacketVersion gotVersion = 0;
unsigned long headerLength = 0; // bytes in the header uint64_t headerLength = 0; // bytes in the header
bool wantImportProgress = true; bool wantImportProgress = true;
@ -1749,14 +1749,14 @@ bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStr
if (getWantSVOfileVersions()) { if (getWantSVOfileVersions()) {
// read just enough of the file to parse the header... // read just enough of the file to parse the header...
const unsigned long HEADER_LENGTH = sizeof(int) + sizeof(PacketVersion); const uint64_t HEADER_LENGTH = sizeof(int) + sizeof(PacketVersion);
unsigned char fileHeader[HEADER_LENGTH]; unsigned char fileHeader[HEADER_LENGTH];
inputStream.readRawData((char*)&fileHeader, HEADER_LENGTH); inputStream.readRawData((char*)&fileHeader, HEADER_LENGTH);
headerLength = HEADER_LENGTH; // we need this later to skip to the data headerLength = HEADER_LENGTH; // we need this later to skip to the data
unsigned char* dataAt = (unsigned char*)&fileHeader; unsigned char* dataAt = (unsigned char*)&fileHeader;
unsigned long dataLength = HEADER_LENGTH; uint64_t dataLength = HEADER_LENGTH;
// if so, read the first byte of the file and see if it matches the expected version code // if so, read the first byte of the file and see if it matches the expected version code
int intPacketType; int intPacketType;
@ -1802,7 +1802,7 @@ bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStr
if (!hasBufferBreaks) { if (!hasBufferBreaks) {
// read the entire file into a buffer, WHAT!? Why not. // read the entire file into a buffer, WHAT!? Why not.
unsigned long dataLength = streamLength - headerLength; uint64_t dataLength = streamLength - headerLength;
unsigned char* entireFileDataSection = new unsigned char[dataLength]; unsigned char* entireFileDataSection = new unsigned char[dataLength];
inputStream.readRawData((char*)entireFileDataSection, dataLength); inputStream.readRawData((char*)entireFileDataSection, dataLength);
@ -1817,9 +1817,9 @@ bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStr
} else { } else {
unsigned long dataLength = streamLength - headerLength; uint64_t dataLength = streamLength - headerLength;
unsigned long remainingLength = dataLength; uint64_t remainingLength = dataLength;
const unsigned long MAX_CHUNK_LENGTH = MAX_OCTREE_PACKET_SIZE * 2; const uint64_t MAX_CHUNK_LENGTH = MAX_OCTREE_PACKET_SIZE * 2;
unsigned char* fileChunk = new unsigned char[MAX_CHUNK_LENGTH]; unsigned char* fileChunk = new unsigned char[MAX_CHUNK_LENGTH];
while (remainingLength > 0) { while (remainingLength > 0) {
@ -1845,7 +1845,7 @@ bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStr
remainingLength -= chunkLength; remainingLength -= chunkLength;
unsigned char* dataAt = fileChunk; unsigned char* dataAt = fileChunk;
unsigned long dataLength = chunkLength; uint64_t dataLength = chunkLength;
ReadBitstreamToTreeParams args(NO_EXISTS_BITS, NULL, 0, ReadBitstreamToTreeParams args(NO_EXISTS_BITS, NULL, 0,
SharedNodePointer(), wantImportProgress, gotVersion); SharedNodePointer(), wantImportProgress, gotVersion);
@ -1885,7 +1885,7 @@ QJsonDocument addMarketplaceIDToDocumentEntities(QJsonDocument& doc, const QStri
const int READ_JSON_BUFFER_SIZE = 2048; const int READ_JSON_BUFFER_SIZE = 2048;
bool Octree::readJSONFromStream(unsigned long streamLength, QDataStream& inputStream, const QString& marketplaceID /*=""*/) { bool Octree::readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID /*=""*/) {
// if the data is gzipped we may not have a useful bytesAvailable() result, so just keep reading until // if the data is gzipped we may not have a useful bytesAvailable() result, so just keep reading until
// we get an eof. Leave streamLength parameter for consistency. // we get an eof. Leave streamLength parameter for consistency.
@ -1980,14 +1980,14 @@ bool Octree::writeToJSONFile(const char* fileName, const OctreeElementPointer& e
return success; return success;
} }
unsigned long Octree::getOctreeElementsCount() { uint64_t Octree::getOctreeElementsCount() {
unsigned long nodeCount = 0; uint64_t nodeCount = 0;
recurseTreeWithOperation(countOctreeElementsOperation, &nodeCount); recurseTreeWithOperation(countOctreeElementsOperation, &nodeCount);
return nodeCount; return nodeCount;
} }
bool Octree::countOctreeElementsOperation(const OctreeElementPointer& element, void* extraData) { bool Octree::countOctreeElementsOperation(const OctreeElementPointer& element, void* extraData) {
(*(unsigned long*)extraData)++; (*(uint64_t*)extraData)++;
return true; // keep going return true; // keep going
} }

View file

@ -14,6 +14,7 @@
#include <memory> #include <memory>
#include <set> #include <set>
#include <stdint.h>
#include <QHash> #include <QHash>
#include <QObject> #include <QObject>
@ -231,7 +232,7 @@ public:
virtual void eraseAllOctreeElements(bool createNewRoot = true); virtual void eraseAllOctreeElements(bool createNewRoot = true);
void readBitstreamToTree(const unsigned char* bitstream, unsigned long int bufferSizeBytes, ReadBitstreamToTreeParams& args); void readBitstreamToTree(const unsigned char* bitstream, uint64_t bufferSizeBytes, ReadBitstreamToTreeParams& args);
void deleteOctalCodeFromTree(const unsigned char* codeBuffer, bool collapseEmptyTrees = DONT_COLLAPSE); void deleteOctalCodeFromTree(const unsigned char* codeBuffer, bool collapseEmptyTrees = DONT_COLLAPSE);
void reaverageOctreeElements(OctreeElementPointer startElement = OctreeElementPointer()); void reaverageOctreeElements(OctreeElementPointer startElement = OctreeElementPointer());
@ -301,13 +302,13 @@ public:
// Octree importers // Octree importers
bool readFromFile(const char* filename); bool readFromFile(const char* filename);
bool readFromURL(const QString& url); // will support file urls as well... bool readFromURL(const QString& url); // will support file urls as well...
bool readFromStream(unsigned long streamLength, QDataStream& inputStream, const QString& marketplaceID=""); bool readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="");
bool readSVOFromStream(unsigned long streamLength, QDataStream& inputStream); bool readSVOFromStream(uint64_t streamLength, QDataStream& inputStream);
bool readJSONFromStream(unsigned long streamLength, QDataStream& inputStream, const QString& marketplaceID=""); bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="");
bool readJSONFromGzippedFile(QString qFileName); bool readJSONFromGzippedFile(QString qFileName);
virtual bool readFromMap(QVariantMap& entityDescription) = 0; virtual bool readFromMap(QVariantMap& entityDescription) = 0;
unsigned long getOctreeElementsCount(); uint64_t getOctreeElementsCount();
bool getShouldReaverage() const { return _shouldReaverage; } bool getShouldReaverage() const { return _shouldReaverage; }