diff --git a/Cesium3DTiles/include/Cesium3DTiles/ExternalTilesetContent.h b/Cesium3DTiles/include/Cesium3DTiles/ExternalTilesetContent.h index 42279292a..e60f2f7b4 100644 --- a/Cesium3DTiles/include/Cesium3DTiles/ExternalTilesetContent.h +++ b/Cesium3DTiles/include/Cesium3DTiles/ExternalTilesetContent.h @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace Cesium3DTiles { @@ -47,7 +48,7 @@ namespace Cesium3DTiles { const glm::dmat4& tileTransform, TileRefine tileRefine, const std::string& url, - const gsl::span& data + const gsl::span& data ); }; diff --git a/Cesium3DTiles/include/Cesium3DTiles/GltfContent.h b/Cesium3DTiles/include/Cesium3DTiles/GltfContent.h index f67cf77f2..95840c668 100644 --- a/Cesium3DTiles/include/Cesium3DTiles/GltfContent.h +++ b/Cesium3DTiles/include/Cesium3DTiles/GltfContent.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace Cesium3DTiles { @@ -42,7 +43,7 @@ namespace Cesium3DTiles { static std::unique_ptr load( std::shared_ptr pLogger, const std::string& url, - const gsl::span& data + const gsl::span& data ); public: diff --git a/Cesium3DTiles/include/Cesium3DTiles/TileContentFactory.h b/Cesium3DTiles/include/Cesium3DTiles/TileContentFactory.h index 6b4012580..f55f59e1a 100644 --- a/Cesium3DTiles/include/Cesium3DTiles/TileContentFactory.h +++ b/Cesium3DTiles/include/Cesium3DTiles/TileContentFactory.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace Cesium3DTiles { class TileContent; @@ -91,7 +92,7 @@ namespace Cesium3DTiles { const TileContentLoadInput& input); private: - static std::optional getMagic(const gsl::span& data); + static std::optional getMagic(const gsl::span& data); static std::unordered_map> _loadersByMagic; static std::unordered_map> _loadersByContentType; diff --git a/Cesium3DTiles/include/Cesium3DTiles/TileContentLoadInput.h b/Cesium3DTiles/include/Cesium3DTiles/TileContentLoadInput.h index 63672fe84..220572c2a 100644 --- a/Cesium3DTiles/include/Cesium3DTiles/TileContentLoadInput.h +++ b/Cesium3DTiles/include/Cesium3DTiles/TileContentLoadInput.h @@ -11,6 +11,7 @@ #include #include +#include namespace Cesium3DTiles { @@ -63,7 +64,7 @@ namespace Cesium3DTiles */ TileContentLoadInput( const std::shared_ptr pLogger_, - const gsl::span& data_, + const gsl::span& data_, const std::string& contentType_, const std::string& url_, const Tile& tile_ @@ -103,7 +104,7 @@ namespace Cesium3DTiles */ TileContentLoadInput( const std::shared_ptr pLogger_, - const gsl::span& data_, + const gsl::span& data_, const std::string& contentType_, const std::string& url_, const TileContext& context_, @@ -141,7 +142,7 @@ namespace Cesium3DTiles * does not succeed, it will try to determine the type based on the * `contentType` field. */ - gsl::span data; + gsl::span data; /** * @brief The content type. diff --git a/Cesium3DTiles/src/Batched3DModelContent.cpp b/Cesium3DTiles/src/Batched3DModelContent.cpp index eba0acd9d..b2eb71081 100644 --- a/Cesium3DTiles/src/Batched3DModelContent.cpp +++ b/Cesium3DTiles/src/Batched3DModelContent.cpp @@ -3,6 +3,7 @@ #include "Cesium3DTiles/spdlog-cesium.h" #include #include +#include namespace Cesium3DTiles { @@ -41,7 +42,7 @@ namespace Cesium3DTiles { void parseFeatureTableJsonData( const std::shared_ptr& pLogger, CesiumGltf::Model& gltf, - const gsl::span& featureTableJsonData) + const gsl::span& featureTableJsonData) { rapidjson::Document document; document.Parse(reinterpret_cast(featureTableJsonData.data()), featureTableJsonData.size()); @@ -80,7 +81,7 @@ namespace Cesium3DTiles { std::unique_ptr Batched3DModelContent::load( std::shared_ptr pLogger, const std::string& url, - const gsl::span& data + const gsl::span& data ) { // TODO: actually use the b3dm payload if (data.size() < sizeof(B3dmHeader)) { @@ -147,7 +148,7 @@ namespace Cesium3DTiles { throw std::runtime_error("The B3DM is invalid because the start of the glTF model is after the end of the entire B3DM."); } - gsl::span glbData = data.subspan(glbStart, glbEnd - glbStart); + gsl::span glbData = data.subspan(glbStart, glbEnd - glbStart); std::unique_ptr pResult = GltfContent::load( pLogger, url, @@ -156,7 +157,7 @@ namespace Cesium3DTiles { if (pResult->model && header.featureTableJsonByteLength > 0) { CesiumGltf::Model& gltf = pResult->model.value(); - gsl::span featureTableJsonData = data.subspan(headerLength, header.featureTableJsonByteLength); + gsl::span featureTableJsonData = data.subspan(headerLength, header.featureTableJsonByteLength); parseFeatureTableJsonData(pLogger, gltf, featureTableJsonData); } diff --git a/Cesium3DTiles/src/Batched3DModelContent.h b/Cesium3DTiles/src/Batched3DModelContent.h index b269dce40..0e3fb59b0 100644 --- a/Cesium3DTiles/src/Batched3DModelContent.h +++ b/Cesium3DTiles/src/Batched3DModelContent.h @@ -8,6 +8,7 @@ #include "Cesium3DTiles/TileContentLoader.h" #include #include +#include #include namespace Cesium3DTiles { @@ -42,7 +43,7 @@ namespace Cesium3DTiles { static std::unique_ptr load( std::shared_ptr pLogger, const std::string& url, - const gsl::span& data + const gsl::span& data ); }; diff --git a/Cesium3DTiles/src/CompositeContent.cpp b/Cesium3DTiles/src/CompositeContent.cpp index 7d6ae8842..12c5b8c5b 100644 --- a/Cesium3DTiles/src/CompositeContent.cpp +++ b/Cesium3DTiles/src/CompositeContent.cpp @@ -4,6 +4,7 @@ #include "Cesium3DTiles/TileContentFactory.h" #include #include +#include namespace { #pragma pack(push, 1) @@ -41,7 +42,7 @@ namespace Cesium3DTiles { * @param derivedData The data for the result. * @return The result. */ - TileContentLoadInput derive(const TileContentLoadInput& input, const gsl::span& derivedData) { + TileContentLoadInput derive(const TileContentLoadInput& input, const gsl::span& derivedData) { return TileContentLoadInput( input.pLogger, derivedData, @@ -62,7 +63,7 @@ namespace Cesium3DTiles { std::unique_ptr CompositeContent::load( const TileContentLoadInput& input) { const std::shared_ptr& pLogger = input.pLogger; - const gsl::span& data = input.data; + const gsl::span& data = input.data; const std::string& url = input.url; if (data.size() < sizeof(CmptHeader)) { @@ -102,7 +103,7 @@ namespace Cesium3DTiles { break; } - gsl::span innerData(data.data() + pos, pInner->byteLength); + gsl::span innerData(data.data() + pos, pInner->byteLength); std::unique_ptr pInnerLoadResult = TileContentFactory::createContent( derive(input, innerData) diff --git a/Cesium3DTiles/src/ExternalTilesetContent.cpp b/Cesium3DTiles/src/ExternalTilesetContent.cpp index 24b9098eb..457a0dba2 100644 --- a/Cesium3DTiles/src/ExternalTilesetContent.cpp +++ b/Cesium3DTiles/src/ExternalTilesetContent.cpp @@ -4,6 +4,7 @@ #include "Cesium3DTiles/Tileset.h" #include "CesiumUtility/Uri.h" #include +#include namespace Cesium3DTiles { @@ -18,7 +19,7 @@ namespace Cesium3DTiles { const glm::dmat4& tileTransform, TileRefine tileRefine, const std::string& url, - const gsl::span& data + const gsl::span& data ) { std::unique_ptr pResult = std::make_unique(); diff --git a/Cesium3DTiles/src/GltfContent.cpp b/Cesium3DTiles/src/GltfContent.cpp index 4eca4c103..fc8dd640d 100644 --- a/Cesium3DTiles/src/GltfContent.cpp +++ b/Cesium3DTiles/src/GltfContent.cpp @@ -17,7 +17,7 @@ namespace Cesium3DTiles { /*static*/ std::unique_ptr GltfContent::load( std::shared_ptr pLogger, const std::string& url, - const gsl::span& data + const gsl::span& data ) { std::unique_ptr pResult = std::make_unique(); diff --git a/Cesium3DTiles/src/QuantizedMeshContent.cpp b/Cesium3DTiles/src/QuantizedMeshContent.cpp index 057859d7a..47028aa27 100644 --- a/Cesium3DTiles/src/QuantizedMeshContent.cpp +++ b/Cesium3DTiles/src/QuantizedMeshContent.cpp @@ -12,6 +12,7 @@ #include #include #include +#include using namespace CesiumUtility; using namespace CesiumGeospatial; @@ -84,21 +85,21 @@ namespace Cesium3DTiles { QuantizedMeshIndexType indexType; uint32_t triangleCount; - gsl::span indicesBuffer; + gsl::span indicesBuffer; uint32_t westEdgeIndicesCount; - gsl::span westEdgeIndicesBuffer; + gsl::span westEdgeIndicesBuffer; uint32_t southEdgeIndicesCount; - gsl::span southEdgeIndicesBuffer; + gsl::span southEdgeIndicesBuffer; uint32_t eastEdgeIndicesCount; - gsl::span eastEdgeIndicesBuffer; + gsl::span eastEdgeIndicesBuffer; uint32_t northEdgeIndicesCount; - gsl::span northEdgeIndicesBuffer; + gsl::span northEdgeIndicesBuffer; - gsl::span octEncodedNormalBuffer; + gsl::span octEncodedNormalBuffer; uint32_t metadataJsonLength; gsl::span metadataJsonBuffer; @@ -130,7 +131,7 @@ namespace Cesium3DTiles { } template - static T readValue(const gsl::span& data, size_t offset, T defaultValue) { + static T readValue(const gsl::span& data, size_t offset, T defaultValue) { if (offset + sizeof(T) <= data.size()) { return *reinterpret_cast(data.data() + offset); } @@ -162,7 +163,7 @@ namespace Cesium3DTiles { TileContentLoadResult& result ); - static std::optional parseQuantizedMesh(const gsl::span& data) { + static std::optional parseQuantizedMesh(const gsl::span& data) { if (data.size() < headerLength) { return std::nullopt; } @@ -213,7 +214,7 @@ namespace Cesium3DTiles { } uint32_t indicesCount = meshView.triangleCount * 3; - meshView.indicesBuffer = gsl::span(data.data() + readIndex, indicesCount * sizeof(uint32_t)); + meshView.indicesBuffer = gsl::span(data.data() + readIndex, indicesCount * sizeof(uint32_t)); readIndex += meshView.indicesBuffer.size_bytes(); if (readIndex > data.size()) { return std::nullopt; @@ -231,7 +232,7 @@ namespace Cesium3DTiles { } uint32_t indicesCount = meshView.triangleCount * 3; - meshView.indicesBuffer = gsl::span(data.data() + readIndex, indicesCount * sizeof(uint16_t)); + meshView.indicesBuffer = gsl::span(data.data() + readIndex, indicesCount * sizeof(uint16_t)); readIndex += meshView.indicesBuffer.size_bytes(); if (readIndex > data.size()) { return std::nullopt; @@ -252,7 +253,7 @@ namespace Cesium3DTiles { return std::nullopt; } - meshView.westEdgeIndicesBuffer = gsl::span(data.data() + readIndex, edgeByteSizes); + meshView.westEdgeIndicesBuffer = gsl::span(data.data() + readIndex, edgeByteSizes); readIndex += edgeByteSizes; // read the south edge @@ -263,7 +264,7 @@ namespace Cesium3DTiles { return std::nullopt; } - meshView.southEdgeIndicesBuffer = gsl::span(data.data() + readIndex, edgeByteSizes); + meshView.southEdgeIndicesBuffer = gsl::span(data.data() + readIndex, edgeByteSizes); readIndex += edgeByteSizes; // read the east edge @@ -274,7 +275,7 @@ namespace Cesium3DTiles { return std::nullopt; } - meshView.eastEdgeIndicesBuffer = gsl::span(data.data() + readIndex, edgeByteSizes); + meshView.eastEdgeIndicesBuffer = gsl::span(data.data() + readIndex, edgeByteSizes); readIndex += edgeByteSizes; // read the north edge @@ -285,7 +286,7 @@ namespace Cesium3DTiles { return std::nullopt; } - meshView.northEdgeIndicesBuffer = gsl::span(data.data() + readIndex, edgeByteSizes); + meshView.northEdgeIndicesBuffer = gsl::span(data.data() + readIndex, edgeByteSizes); readIndex += edgeByteSizes; // parse oct-encoded normal buffer and metadata @@ -305,7 +306,7 @@ namespace Cesium3DTiles { break; } - meshView.octEncodedNormalBuffer = gsl::span(data.data() + readIndex, vertexCount * 2); + meshView.octEncodedNormalBuffer = gsl::span(data.data() + readIndex, vertexCount * 2); } else if (extensionID == 4) { // Metadata if (readIndex + sizeof(uint32_t) > data.size()) { @@ -411,10 +412,10 @@ namespace Cesium3DTiles { double longitudeOffset, double latitudeOffset, const std::vector &uvsAndHeights, - const gsl::span &westEdgeIndicesBuffer, - const gsl::span &southEdgeIndicesBuffer, - const gsl::span &eastEdgeIndicesBuffer, - const gsl::span &northEdgeIndicesBuffer, + const gsl::span &westEdgeIndicesBuffer, + const gsl::span &southEdgeIndicesBuffer, + const gsl::span &eastEdgeIndicesBuffer, + const gsl::span &northEdgeIndicesBuffer, gsl::span& outputPositions, gsl::span& outputNormals, gsl::span& outputIndices) @@ -531,14 +532,14 @@ namespace Cesium3DTiles { outputIndices); } - static void decodeNormals(const gsl::span& encoded, gsl::span& decoded) { + static void decodeNormals(const gsl::span& encoded, gsl::span& decoded) { if (decoded.size() < encoded.size()) { throw std::runtime_error("decoded buffer is too small."); } size_t normalOutputIndex = 0; for (size_t i = 0; i < encoded.size(); i += 2) { - glm::dvec3 normal = octDecode(encoded[i], encoded[i + 1]); + glm::dvec3 normal = octDecode(static_cast(encoded[i]), static_cast(encoded[i + 1])); decoded[normalOutputIndex++] = static_cast(normal.x); decoded[normalOutputIndex++] = static_cast(normal.y); decoded[normalOutputIndex++] = static_cast(normal.z); @@ -546,8 +547,8 @@ namespace Cesium3DTiles { } template - static std::vector generateNormals(const gsl::span &positions, const gsl::span &indices, size_t currentNumOfIndex) { - std::vector normalsBuffer(positions.size() * sizeof(float)); + static std::vector generateNormals(const gsl::span &positions, const gsl::span &indices, size_t currentNumOfIndex) { + std::vector normalsBuffer(positions.size() * sizeof(float)); gsl::span normals(reinterpret_cast(normalsBuffer.data()), positions.size()); for (size_t i = 0; i < currentNumOfIndex; i += 3) { T id0 = indices[i]; @@ -599,7 +600,7 @@ namespace Cesium3DTiles { const TileID& tileID, const BoundingVolume& tileBoundingVolume, const std::string& url, - const gsl::span& data + const gsl::span& data ) { // TODO: use context plus tileID to compute the tile's rectangle, rather than inferring it from the parent tile. const QuadtreeTileID& id = std::get(tileID); @@ -635,7 +636,7 @@ namespace Cesium3DTiles { uint32_t skirtIndicesCount = (skirtVertexCount - 4) * 6; // decode position without skirt, but preallocate position buffer to include skirt as well - std::vector outputPositionsBuffer((vertexCount + skirtVertexCount) * 3 * sizeof(float)); + std::vector outputPositionsBuffer((vertexCount + skirtVertexCount) * 3 * sizeof(float)); gsl::span outputPositions(reinterpret_cast(outputPositionsBuffer.data()), (vertexCount + skirtVertexCount) * 3); size_t positionOutputIndex = 0; @@ -694,7 +695,7 @@ namespace Cesium3DTiles { } // decode normal vertices of the tile as well as its metadata without skirt - std::vector outputNormalsBuffer; + std::vector outputNormalsBuffer; gsl::span outputNormals; if (!meshView->octEncodedNormalBuffer.empty()) { uint32_t totalNormalFloats = (vertexCount + skirtVertexCount) * 3; @@ -713,7 +714,7 @@ namespace Cesium3DTiles { // indices buffer for gltf to include tile and skirt indices. Caution of indices type // since adding skirt means the number of vertices is potentially over maximum of uint16_t - std::vector outputIndicesBuffer; + std::vector outputIndicesBuffer; uint32_t indexSizeBytes = meshView->indexType == QuantizedMeshIndexType::UnsignedInt ? sizeof(uint32_t) : sizeof(uint16_t); const std::optional& implicitContext = context.implicitContext; const QuadtreeTilingScheme& tilingScheme = implicitContext->tilingScheme; diff --git a/Cesium3DTiles/src/QuantizedMeshContent.h b/Cesium3DTiles/src/QuantizedMeshContent.h index 3193f97ee..4d83c537d 100644 --- a/Cesium3DTiles/src/QuantizedMeshContent.h +++ b/Cesium3DTiles/src/QuantizedMeshContent.h @@ -4,6 +4,7 @@ #include "Cesium3DTiles/Library.h" #include "Cesium3DTiles/TileContentLoader.h" #include "Cesium3DTiles/TileContentLoadResult.h" +#include namespace Cesium3DTiles { @@ -43,7 +44,7 @@ namespace Cesium3DTiles { const TileID& tileID, const BoundingVolume& tileBoundingVolume, const std::string& url, - const gsl::span& data + const gsl::span& data ); }; diff --git a/Cesium3DTiles/src/RasterOverlayTileProvider.cpp b/Cesium3DTiles/src/RasterOverlayTileProvider.cpp index ec395fdaf..e731f356a 100644 --- a/Cesium3DTiles/src/RasterOverlayTileProvider.cpp +++ b/Cesium3DTiles/src/RasterOverlayTileProvider.cpp @@ -434,7 +434,7 @@ namespace Cesium3DTiles { }; } - gsl::span data = pResponse->data(); + gsl::span data = pResponse->data(); CesiumGltf::ImageReaderResult loadedImage = CesiumGltf::readImage(data); return LoadedRasterOverlayImage { diff --git a/Cesium3DTiles/src/TileContentFactory.cpp b/Cesium3DTiles/src/TileContentFactory.cpp index c5e9ddaed..8ae92e3a1 100644 --- a/Cesium3DTiles/src/TileContentFactory.cpp +++ b/Cesium3DTiles/src/TileContentFactory.cpp @@ -24,7 +24,7 @@ namespace Cesium3DTiles { std::unique_ptr TileContentFactory::createContent( const TileContentLoadInput& input) { - const gsl::span& data = input.data; + const gsl::span& data = input.data; std::string magic = TileContentFactory::getMagic(data).value_or("json"); auto itMagic = TileContentFactory::_loadersByMagic.find(magic); @@ -43,12 +43,12 @@ namespace Cesium3DTiles { // Determine if this is plausibly a JSON external tileset. size_t i; for (i = 0; i < data.size(); ++i) { - if (!std::isspace(data[i])) { + if (!std::isspace(static_cast(data[i]))) { break; } } - if (i < data.size() && data[i] == '{') { + if (i < data.size() && static_cast(data[i]) == '{') { // Might be an external tileset, try loading it that way. itMagic = TileContentFactory::_loadersByMagic.find("json"); if (itMagic != TileContentFactory::_loadersByMagic.end()) { @@ -67,10 +67,10 @@ namespace Cesium3DTiles { * @param data The raw data. * @return The string, or an empty optional if the given data contains less than 4 bytes */ - std::optional TileContentFactory::getMagic(const gsl::span& data) { + std::optional TileContentFactory::getMagic(const gsl::span& data) { if (data.size() >= 4) { - gsl::span magicData = data.subspan(0, 4); - return std::string(magicData.begin(), magicData.end()); + gsl::span magicData = data.subspan(0, 4); + return std::string(reinterpret_cast(magicData.data()), 4); } return std::nullopt; diff --git a/Cesium3DTiles/src/TileMapServiceRasterOverlay.cpp b/Cesium3DTiles/src/TileMapServiceRasterOverlay.cpp index 5a699252a..e1e6d143f 100644 --- a/Cesium3DTiles/src/TileMapServiceRasterOverlay.cpp +++ b/Cesium3DTiles/src/TileMapServiceRasterOverlay.cpp @@ -10,6 +10,7 @@ #include "CesiumGeospatial/WebMercatorProjection.h" #include "tinyxml2.h" #include "CesiumUtility/Uri.h" +#include using namespace CesiumAsync; @@ -154,7 +155,7 @@ namespace Cesium3DTiles { return nullptr; } - gsl::span data = pResponse->data(); + gsl::span data = pResponse->data(); tinyxml2::XMLDocument doc; tinyxml2::XMLError error = doc.Parse(reinterpret_cast(data.data()), data.size_bytes()); diff --git a/Cesium3DTiles/src/Tileset.cpp b/Cesium3DTiles/src/Tileset.cpp index d6df9e3a2..2b4330aab 100644 --- a/Cesium3DTiles/src/Tileset.cpp +++ b/Cesium3DTiles/src/Tileset.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace CesiumAsync; using namespace CesiumGeometry; @@ -147,7 +148,7 @@ namespace Cesium3DTiles { return; } - gsl::span data = pResponse->data(); + gsl::span data = pResponse->data(); rapidjson::Document ionResponse; ionResponse.Parse(reinterpret_cast(data.data()), data.size()); @@ -455,7 +456,7 @@ namespace Cesium3DTiles { pContext->baseUrl = pRequest->url(); - gsl::span data = pResponse->data(); + gsl::span data = pResponse->data(); rapidjson::Document tileset; tileset.Parse(reinterpret_cast(data.data()), data.size()); @@ -755,7 +756,7 @@ namespace Cesium3DTiles { * @return Whether the update succeeded */ static bool updateContextWithNewToken(TileContext* pContext, const IAssetResponse* pIonResponse, const std::shared_ptr& pLogger) { - gsl::span data = pIonResponse->data(); + gsl::span data = pIonResponse->data(); rapidjson::Document ionResponse; ionResponse.Parse(reinterpret_cast(data.data()), data.size()); diff --git a/Cesium3DTiles/src/upsampleGltfForRasterOverlays.cpp b/Cesium3DTiles/src/upsampleGltfForRasterOverlays.cpp index d77e8c5b2..6dc2d1ab1 100644 --- a/Cesium3DTiles/src/upsampleGltfForRasterOverlays.cpp +++ b/Cesium3DTiles/src/upsampleGltfForRasterOverlays.cpp @@ -6,6 +6,7 @@ #include "SkirtMeshMetadata.h" #include "upsampleGltfForRasterOverlays.h" #include +#include using namespace CesiumGltf; @@ -31,7 +32,7 @@ namespace Cesium3DTiles { ); struct FloatVertexAttribute { - const std::vector& buffer; + const std::vector& buffer; int64_t offset; int64_t stride; int64_t numberOfFloatsPerVertex; diff --git a/Cesium3DTiles/test/SimpleAssetAccessor.h b/Cesium3DTiles/test/SimpleAssetAccessor.h index bb7126267..3b81ce4bf 100644 --- a/Cesium3DTiles/test/SimpleAssetAccessor.h +++ b/Cesium3DTiles/test/SimpleAssetAccessor.h @@ -6,6 +6,7 @@ #include "SimpleAssetResponse.h" #include #include +#include class SimpleAssetAccessor : public CesiumAsync::IAssetAccessor { public: @@ -30,7 +31,7 @@ class SimpleAssetAccessor : public CesiumAsync::IAssetAccessor { const CesiumAsync::AsyncSystem& asyncSystem, const std::string& url, const std::vector& headers, - const gsl::span&) override + const gsl::span&) override { return this->requestAsset(asyncSystem, url, headers); } diff --git a/Cesium3DTiles/test/SimpleAssetResponse.h b/Cesium3DTiles/test/SimpleAssetResponse.h index 9952d51d0..b1fc47a71 100644 --- a/Cesium3DTiles/test/SimpleAssetResponse.h +++ b/Cesium3DTiles/test/SimpleAssetResponse.h @@ -2,13 +2,14 @@ #include "CesiumAsync/IAssetResponse.h" #include +#include class SimpleAssetResponse : public CesiumAsync::IAssetResponse { public: SimpleAssetResponse(uint16_t statusCode, const std::string& contentType, const CesiumAsync::HttpHeaders& headers, - const std::vector& data) + const std::vector& data) : mockStatusCode{ statusCode } , mockContentType{ contentType } , mockHeaders{ headers } @@ -21,13 +22,13 @@ class SimpleAssetResponse : public CesiumAsync::IAssetResponse { virtual const CesiumAsync::HttpHeaders& headers() const override { return this->mockHeaders; } - virtual gsl::span data() const override { - return gsl::span(mockData.data(), mockData.size()); + virtual gsl::span data() const override { + return gsl::span(mockData.data(), mockData.size()); } uint16_t mockStatusCode; std::string mockContentType; CesiumAsync::HttpHeaders mockHeaders; - std::vector mockData; + std::vector mockData; }; diff --git a/Cesium3DTiles/test/TestQuantizedMeshContent.cpp b/Cesium3DTiles/test/TestQuantizedMeshContent.cpp index 9d0040135..c707bf436 100644 --- a/Cesium3DTiles/test/TestQuantizedMeshContent.cpp +++ b/Cesium3DTiles/test/TestQuantizedMeshContent.cpp @@ -46,7 +46,7 @@ struct MeshData { struct Extension { uint8_t extensionID; - std::vector extensionData; + std::vector extensionData; }; template @@ -97,7 +97,7 @@ static double calculateSkirtHeight(int tileLevel, const CesiumGeospatial::Ellips } template -static std::vector convertQuantizedMeshToBinary(const QuantizedMesh &quantizedMesh) { +static std::vector convertQuantizedMeshToBinary(const QuantizedMesh &quantizedMesh) { // compute the total size of mesh to preallocate size_t totalSize = sizeof(quantizedMesh.header) + sizeof(uint32_t) + // vertex data @@ -121,7 +121,7 @@ static std::vector convertQuantizedMeshToBinary(const QuantizedMesh size_t offset = 0; size_t length = 0; - std::vector buffer(totalSize); + std::vector buffer(totalSize); // serialize header length = sizeof(quantizedMesh.header); @@ -589,8 +589,8 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") { QuantizedMesh quantizedMesh = createGridQuantizedMesh(boundingVolume, verticesWidth, verticesHeight); // convert to gltf - std::vector quantizedMeshBin = convertQuantizedMeshToBinary(quantizedMesh); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + std::vector quantizedMeshBin = convertQuantizedMeshToBinary(quantizedMesh); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -636,8 +636,8 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") { QuantizedMesh quantizedMesh = createGridQuantizedMesh(boundingVolume, verticesWidth, verticesHeight); // convert to gltf - std::vector quantizedMeshBin = convertQuantizedMeshToBinary(quantizedMesh); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + std::vector quantizedMeshBin = convertQuantizedMeshToBinary(quantizedMesh); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -683,8 +683,8 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") { QuantizedMesh quantizedMesh = createGridQuantizedMesh(boundingVolume, verticesWidth, verticesHeight); // convert to gltf - std::vector quantizedMeshBin = convertQuantizedMeshToBinary(quantizedMesh); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + std::vector quantizedMeshBin = convertQuantizedMeshToBinary(quantizedMesh); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -734,10 +734,10 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") { glm::vec3 normal = glm::normalize(glm::vec3(0.2, 1.4, 0.3)); uint8_t x = 0, y = 0; octEncode(normal, x, y); - std::vector octNormals(verticesWidth * verticesHeight * 2); + std::vector octNormals(verticesWidth * verticesHeight * 2); for (size_t i = 0; i < octNormals.size(); i += 2) { - octNormals[i] = x; - octNormals[i+1] = y; + octNormals[i] = std::byte(x); + octNormals[i+1] = std::byte(y); } Extension octNormalExtension; @@ -747,8 +747,8 @@ TEST_CASE("Test converting quantized mesh to gltf with skirt") { quantizedMesh.extensions.emplace_back(std::move(octNormalExtension)); // convert to gltf - std::vector quantizedMeshBin = convertQuantizedMeshToBinary(quantizedMesh); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + std::vector quantizedMeshBin = convertQuantizedMeshToBinary(quantizedMesh); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -813,10 +813,10 @@ TEST_CASE("Test converting ill-formed quantized mesh") { glm::vec3 normal = glm::normalize(glm::vec3(0.2, 1.4, 0.3)); uint8_t x = 0, y = 0; octEncode(normal, x, y); - std::vector octNormals(verticesWidth * verticesHeight * 2); + std::vector octNormals(verticesWidth * verticesHeight * 2); for (size_t i = 0; i < octNormals.size(); i += 2) { - octNormals[i] = x; - octNormals[i+1] = y; + octNormals[i] = std::byte(x); + octNormals[i+1] = std::byte(y); } Extension octNormalExtension; @@ -826,8 +826,8 @@ TEST_CASE("Test converting ill-formed quantized mesh") { quantizedMesh.extensions.emplace_back(std::move(octNormalExtension)); SECTION("Quantized mesh with ill-formed header") { - std::vector quantizedMeshBin(32); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + std::vector quantizedMeshBin(32); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -840,7 +840,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { } SECTION("Quantized mesh with ill-formed vertex data") { - std::vector quantizedMeshBin( + std::vector quantizedMeshBin( sizeof(quantizedMesh.header) + // header sizeof(uint32_t) + // vertex count quantizedMesh.vertexData.u.size() * sizeof(uint16_t) // u buffer @@ -862,7 +862,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { length = quantizedMesh.vertexData.u.size() * sizeof(uint16_t); std::memcpy(quantizedMeshBin.data() + offset, quantizedMesh.vertexData.u.data(), length); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -875,7 +875,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { } SECTION("Quantized mesh with ill-formed indices") { - std::vector quantizedMeshBin( + std::vector quantizedMeshBin( sizeof(quantizedMesh.header) + // header sizeof(uint32_t) + // vertex count quantizedMesh.vertexData.u.size() * sizeof(uint16_t) + // u buffer @@ -916,7 +916,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { length = sizeof(triangleCount); std::memcpy(quantizedMeshBin.data() + offset, &triangleCount, length); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -929,7 +929,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { } SECTION("Quantized mesh with ill-formed west edge indices") { - std::vector quantizedMeshBin( + std::vector quantizedMeshBin( sizeof(quantizedMesh.header) + // header sizeof(uint32_t) + // vertex count quantizedMesh.vertexData.u.size() * sizeof(uint16_t) + // u buffer @@ -983,7 +983,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { length = sizeof(westCount); std::memcpy(quantizedMeshBin.data() + offset, &westCount, length); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -996,7 +996,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { } SECTION("Quantized mesh with ill-formed south edge indices") { - std::vector quantizedMeshBin( + std::vector quantizedMeshBin( sizeof(quantizedMesh.header) + // header sizeof(uint32_t) + // vertex count quantizedMesh.vertexData.u.size() * sizeof(uint16_t) + // u buffer @@ -1062,7 +1062,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { length = sizeof(westCount); std::memcpy(quantizedMeshBin.data() + offset, &southCount, length); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -1075,7 +1075,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { } SECTION("Quantized mesh with ill-formed east edge indices") { - std::vector quantizedMeshBin( + std::vector quantizedMeshBin( sizeof(quantizedMesh.header) + // header sizeof(uint32_t) + // vertex count quantizedMesh.vertexData.u.size() * sizeof(uint16_t) + // u buffer @@ -1153,7 +1153,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { length = sizeof(eastCount); std::memcpy(quantizedMeshBin.data() + offset, &eastCount, length); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, @@ -1166,7 +1166,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { } SECTION("Quantized mesh with ill-formed north edge indices") { - std::vector quantizedMeshBin( + std::vector quantizedMeshBin( sizeof(quantizedMesh.header) + // header sizeof(uint32_t) + // vertex count quantizedMesh.vertexData.u.size() * sizeof(uint16_t) + // u buffer @@ -1256,7 +1256,7 @@ TEST_CASE("Test converting ill-formed quantized mesh") { length = sizeof(northCount); std::memcpy(quantizedMeshBin.data() + offset, &northCount, length); - gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); + gsl::span data(quantizedMeshBin.data(), quantizedMeshBin.size()); std::unique_ptr loadResult = QuantizedMeshContent::load( spdlog::default_logger(), context, diff --git a/Cesium3DTiles/test/TestTilesetSelectionAlgorithm.cpp b/Cesium3DTiles/test/TestTilesetSelectionAlgorithm.cpp index 0d2a744f1..5964934f1 100644 --- a/Cesium3DTiles/test/TestTilesetSelectionAlgorithm.cpp +++ b/Cesium3DTiles/test/TestTilesetSelectionAlgorithm.cpp @@ -12,20 +12,21 @@ #include "glm/mat4x4.hpp" #include #include +#include using namespace CesiumAsync; using namespace Cesium3DTiles; using namespace CesiumGeospatial; using namespace CesiumUtility; -static std::vector readFile(const std::filesystem::path& fileName) { +static std::vector readFile(const std::filesystem::path& fileName) { std::ifstream file(fileName, std::ios::binary | std::ios::ate); REQUIRE(file); std::streamsize size = file.tellg(); file.seekg(0, std::ios::beg); - std::vector buffer(static_cast(size)); + std::vector buffer(static_cast(size)); file.read(reinterpret_cast(buffer.data()), size); return buffer; diff --git a/CesiumAsync/include/CesiumAsync/CacheItem.h b/CesiumAsync/include/CesiumAsync/CacheItem.h index 29e917b13..1eecbf6c4 100644 --- a/CesiumAsync/include/CesiumAsync/CacheItem.h +++ b/CesiumAsync/include/CesiumAsync/CacheItem.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace CesiumAsync { @@ -23,7 +24,7 @@ namespace CesiumAsync { CacheResponse( uint16_t cacheStatusCode, HttpHeaders&& cacheHeaders, - std::vector&& cacheData + std::vector&& cacheData ) : statusCode(cacheStatusCode), headers(std::move(cacheHeaders)), @@ -43,7 +44,7 @@ namespace CesiumAsync { /** * @brief The body data of the response. */ - std::vector data; + std::vector data; }; /** diff --git a/CesiumAsync/include/CesiumAsync/CachingAssetAccessor.h b/CesiumAsync/include/CesiumAsync/CachingAssetAccessor.h index 3b41d7796..a495ab40e 100644 --- a/CesiumAsync/include/CesiumAsync/CachingAssetAccessor.h +++ b/CesiumAsync/include/CesiumAsync/CachingAssetAccessor.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace CesiumAsync { class AsyncSystem; @@ -44,7 +45,7 @@ namespace CesiumAsync { const AsyncSystem& asyncSystem, const std::string& url, const std::vector& headers, - const gsl::span& contentPayload) override; + const gsl::span& contentPayload) override; /** @copydoc IAssetAccessor::tick */ virtual void tick() noexcept override; diff --git a/CesiumAsync/include/CesiumAsync/IAssetAccessor.h b/CesiumAsync/include/CesiumAsync/IAssetAccessor.h index 75b2a4162..845774a1e 100644 --- a/CesiumAsync/include/CesiumAsync/IAssetAccessor.h +++ b/CesiumAsync/include/CesiumAsync/IAssetAccessor.h @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace CesiumAsync { @@ -53,7 +54,7 @@ namespace CesiumAsync { const AsyncSystem& asyncSystem, const std::string& url, const std::vector& headers = std::vector(), - const gsl::span& contentPayload = {} + const gsl::span& contentPayload = {} ) = 0; /** diff --git a/CesiumAsync/include/CesiumAsync/IAssetResponse.h b/CesiumAsync/include/CesiumAsync/IAssetResponse.h index a21f8cee5..2788ac919 100644 --- a/CesiumAsync/include/CesiumAsync/IAssetResponse.h +++ b/CesiumAsync/include/CesiumAsync/IAssetResponse.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace CesiumAsync { @@ -36,7 +37,7 @@ namespace CesiumAsync { /** * @brief Returns the data of this response */ - virtual gsl::span data() const = 0; + virtual gsl::span data() const = 0; }; } diff --git a/CesiumAsync/include/CesiumAsync/ICacheDatabase.h b/CesiumAsync/include/CesiumAsync/ICacheDatabase.h index bf482f397..2a7a53520 100644 --- a/CesiumAsync/include/CesiumAsync/ICacheDatabase.h +++ b/CesiumAsync/include/CesiumAsync/ICacheDatabase.h @@ -4,6 +4,7 @@ #include "CesiumAsync/CacheItem.h" #include "CesiumAsync/IAssetRequest.h" #include +#include namespace CesiumAsync { /** @@ -48,7 +49,7 @@ namespace CesiumAsync { const HttpHeaders& requestHeaders, uint16_t statusCode, const HttpHeaders& responseHeaders, - const gsl::span& responseData + const gsl::span& responseData ) = 0; /** diff --git a/CesiumAsync/include/CesiumAsync/SqliteCache.h b/CesiumAsync/include/CesiumAsync/SqliteCache.h index e1c96830c..b1e9fadd5 100644 --- a/CesiumAsync/include/CesiumAsync/SqliteCache.h +++ b/CesiumAsync/include/CesiumAsync/SqliteCache.h @@ -5,6 +5,7 @@ #include #include #include +#include #include struct sqlite3; @@ -44,7 +45,7 @@ namespace CesiumAsync { const HttpHeaders& requestHeaders, uint16_t statusCode, const HttpHeaders& responseHeaders, - const gsl::span& responseData + const gsl::span& responseData ) override; /** @copydoc ICacheDatabase::prune*/ diff --git a/CesiumAsync/src/CachingAssetAccessor.cpp b/CesiumAsync/src/CachingAssetAccessor.cpp index 64e8b7b74..5eee7e34b 100644 --- a/CesiumAsync/src/CachingAssetAccessor.cpp +++ b/CesiumAsync/src/CachingAssetAccessor.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace CesiumAsync { class CacheAssetResponse : public IAssetResponse { @@ -33,8 +34,8 @@ namespace CesiumAsync { return this->_pCacheItem->cacheResponse.headers; } - virtual gsl::span data() const override { - return gsl::span( + virtual gsl::span data() const override { + return gsl::span( this->_pCacheItem->cacheResponse.data.data(), this->_pCacheItem->cacheResponse.data.size()); } @@ -219,7 +220,7 @@ namespace CesiumAsync { const AsyncSystem& asyncSystem, const std::string& url, const std::vector& headers, - const gsl::span& contentPayload) + const gsl::span& contentPayload) { return this->_pAssetAccessor->post(asyncSystem, url, headers, contentPayload); } diff --git a/CesiumAsync/src/SqliteCache.cpp b/CesiumAsync/src/SqliteCache.cpp index 1fc5d4473..e2e331920 100644 --- a/CesiumAsync/src/SqliteCache.cpp +++ b/CesiumAsync/src/SqliteCache.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace CesiumAsync { @@ -219,9 +220,9 @@ namespace CesiumAsync { uint16_t statusCode = static_cast(sqlite3_column_int(this->_getEntryStmtWrapper.get(), 3)); - const uint8_t* rawResponseData = reinterpret_cast(sqlite3_column_blob(this->_getEntryStmtWrapper.get(), 4)); + const std::byte* rawResponseData = reinterpret_cast(sqlite3_column_blob(this->_getEntryStmtWrapper.get(), 4)); int responseDataSize = sqlite3_column_bytes(this->_getEntryStmtWrapper.get(), 4); - std::vector responseData(rawResponseData, rawResponseData + responseDataSize); + std::vector responseData(rawResponseData, rawResponseData + responseDataSize); // parse request std::string serializedRequestHeaders = reinterpret_cast(sqlite3_column_text(this->_getEntryStmtWrapper.get(), 5)); @@ -279,7 +280,7 @@ namespace CesiumAsync { const HttpHeaders& requestHeaders, uint16_t statusCode, const HttpHeaders& responseHeaders, - const gsl::span& responseData + const gsl::span& responseData ) { std::lock_guard guard(this->_mutex); diff --git a/CesiumAsync/test/MockAssetResponse.h b/CesiumAsync/test/MockAssetResponse.h index d84ab141f..7281c5803 100644 --- a/CesiumAsync/test/MockAssetResponse.h +++ b/CesiumAsync/test/MockAssetResponse.h @@ -2,13 +2,14 @@ #include "CesiumAsync/IAssetResponse.h" #include +#include class MockAssetResponse : public CesiumAsync::IAssetResponse { public: MockAssetResponse(uint16_t statusCode, const std::string& contentType, const CesiumAsync::HttpHeaders& headers, - const std::vector& data) + const std::vector& data) : _statusCode{statusCode} , _contentType{contentType} , _headers{headers} @@ -21,14 +22,14 @@ class MockAssetResponse : public CesiumAsync::IAssetResponse { virtual const CesiumAsync::HttpHeaders& headers() const override { return this->_headers; } - virtual gsl::span data() const override { - return gsl::span(_data.data(), _data.size()); + virtual gsl::span data() const override { + return gsl::span(_data.data(), _data.size()); } private: uint16_t _statusCode; std::string _contentType; CesiumAsync::HttpHeaders _headers; - std::vector _data; + std::vector _data; }; diff --git a/CesiumAsync/test/TestCacheAssetAccessor.cpp b/CesiumAsync/test/TestCacheAssetAccessor.cpp index 5414044a5..1c55cbf8f 100644 --- a/CesiumAsync/test/TestCacheAssetAccessor.cpp +++ b/CesiumAsync/test/TestCacheAssetAccessor.cpp @@ -7,6 +7,7 @@ #include "MockAssetResponse.h" #include "ResponseCacheControl.h" #include +#include #include using namespace CesiumAsync; @@ -21,7 +22,7 @@ class MockStoreCacheDatabase : public ICacheDatabase { HttpHeaders requestHeaders; uint16_t statusCode; HttpHeaders responseHeaders; - std::vector responseData; + std::vector responseData; }; MockStoreCacheDatabase() @@ -45,7 +46,7 @@ class MockStoreCacheDatabase : public ICacheDatabase { const HttpHeaders& requestHeaders, uint16_t statusCode, const HttpHeaders& responseHeaders, - const gsl::span& responseData + const gsl::span& responseData ) override { this->storeRequestParam = StoreRequestParameters { key, @@ -55,7 +56,7 @@ class MockStoreCacheDatabase : public ICacheDatabase { requestHeaders, statusCode, responseHeaders, - std::vector(responseData.begin(), responseData.end()) + std::vector(responseData.begin(), responseData.end()) }; this->storeResponseCall = true; return true; @@ -100,7 +101,7 @@ class MockAssetAccessor : public IAssetAccessor { const AsyncSystem& asyncSystem, const std::string& /* url */, const std::vector& /* headers */, - const gsl::span& /* contentPayload */ + const gsl::span& /* contentPayload */ ) override { return asyncSystem.createResolvedFuture(std::shared_ptr(testRequest)); } @@ -129,7 +130,7 @@ TEST_CASE("Test the condition of caching the request") { {"Content-Type", "app/json"}, {"Cache-Control", "must-revalidate, max-age=100"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -162,7 +163,7 @@ TEST_CASE("Test the condition of caching the request") { {"Content-Type", "app/json"}, {"Expires", "Wed, 21 Oct 5020 07:28:00 GMT"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -195,7 +196,7 @@ TEST_CASE("Test the condition of caching the request") { {"Content-Type", "app/json"}, {"Cache-Control", "must-revalidate, max-age=100, public, private"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "POST", @@ -226,7 +227,7 @@ TEST_CASE("Test the condition of caching the request") { {"Content-Type", "app/json"}, {"Cache-Control", "must-revalidate, public, private, max-age=100"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -257,7 +258,7 @@ TEST_CASE("Test the condition of caching the request") { {"Content-Type", "app/json"}, {"Cache-Control", "no-store"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -288,7 +289,7 @@ TEST_CASE("Test the condition of caching the request") { {"Content-Type", "app/json"}, {"Cache-Control", "must-revalidate, no-cache"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -318,7 +319,7 @@ TEST_CASE("Test the condition of caching the request") { HttpHeaders { {"Content-Type", "app/json"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -349,7 +350,7 @@ TEST_CASE("Test the condition of caching the request") { {"Content-Type", "app/json"}, {"Expires", "Wed, 21 Oct 2010 07:28:00 GMT"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -383,7 +384,7 @@ TEST_CASE("Test calculation of expiry time for the cached response") { {"Content-Type", "app/json"}, {"Cache-Control", "must-revalidate, private, max-age=400"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -415,7 +416,7 @@ TEST_CASE("Test calculation of expiry time for the cached response") { {"Content-Type", "app/json"}, {"Expires", "Wed, 21 Oct 2021 07:28:00 GMT"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -449,7 +450,7 @@ TEST_CASE("Test serving cache item") { {"Content-Type", "app/json"}, {"Response-Header", "Response-Value"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -495,7 +496,7 @@ TEST_CASE("Test serving cache item") { {"Content-Type", "app/json"}, {"Response-Header", "Response-Value"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -518,7 +519,7 @@ TEST_CASE("Test serving cache item") { {"Cache-Response-Header", "Cache-Response-Value"}, {"Cache-Control", "max-age=100, private"} }, - std::vector()); + std::vector()); CacheItem cacheItem(currentTime + 100, std::move(cacheRequest), std::move(cacheResponse)); mockCacheDatabase->cacheItem = cacheItem; @@ -571,7 +572,7 @@ TEST_CASE("Test serving cache item") { {"Revalidation-Response-Header", "Revalidation-Response-Value"}, {"Cache-Control", "max-age=300, must-revalidate, private"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -594,7 +595,7 @@ TEST_CASE("Test serving cache item") { {"Cache-Response-Header", "Cache-Response-Value"}, {"Cache-Control", "max-age=100, private"} }, - std::vector()); + std::vector()); CacheItem cacheItem(currentTime - 100, std::move(cacheRequest), std::move(cacheResponse)); mockCacheDatabase->cacheItem = cacheItem; @@ -649,7 +650,7 @@ TEST_CASE("Test serving cache item") { {"Content-Type", "app/json"}, {"Revalidation-Response-Header", "Revalidation-Response-Value"} }, - std::vector()); + std::vector()); std::shared_ptr mockRequest = std::make_shared( "GET", @@ -672,7 +673,7 @@ TEST_CASE("Test serving cache item") { {"Cache-Response-Header", "Cache-Response-Value"}, {"Cache-Control", "max-age=100, private"} }, - std::vector()); + std::vector()); CacheItem cacheItem(currentTime - 100, std::move(cacheRequest), std::move(cacheResponse)); mockCacheDatabase->cacheItem = cacheItem; diff --git a/CesiumAsync/test/TestDiskCache.cpp b/CesiumAsync/test/TestDiskCache.cpp index 012475818..28f614cf6 100644 --- a/CesiumAsync/test/TestDiskCache.cpp +++ b/CesiumAsync/test/TestDiskCache.cpp @@ -4,6 +4,7 @@ #include "MockAssetResponse.h" #include "ResponseCacheControl.h" #include +#include using namespace CesiumAsync; @@ -17,7 +18,7 @@ TEST_CASE("Test disk cache with Sqlite") { { "Response-Header", "Response-Value" }, { "Content-Type", "text/html" } }; - std::vector responseData = {0, 1, 2, 3, 4}; + std::vector responseData = { std::byte(0), std::byte(1), std::byte(2), std::byte(3), std::byte(4) }; std::unique_ptr response = std::make_unique( static_cast(200), "text/html", @@ -53,7 +54,7 @@ TEST_CASE("Test disk cache with Sqlite") { REQUIRE(cacheResponse.headers.at("Content-Type") == "text/html"); REQUIRE(cacheResponse.statusCode == 200); REQUIRE(cacheResponse.headers.at("Response-Header") == "Response-Value"); - REQUIRE(cacheResponse.data == std::vector{ 0, 1, 2, 3, 4 }); + REQUIRE(cacheResponse.data == std::vector{ std::byte(0), std::byte(1), std::byte(2), std::byte(3), std::byte(4) }); std::optional cacheControl = ResponseCacheControl::parseFromResponseHeaders(cacheResponse.headers); REQUIRE(!cacheControl.has_value()); @@ -69,7 +70,7 @@ TEST_CASE("Test disk cache with Sqlite") { {"Content-Type", "text/html"}, {"Cache-Control", "must-revalidate, no-store, public, proxy-revalidate"} }; - std::vector responseData = {0, 1, 2, 3, 4}; + std::vector responseData = { std::byte(0), std::byte(1), std::byte(2), std::byte(3), std::byte(4) }; std::unique_ptr response = std::make_unique( static_cast(200), "text/html", responseHeaders, responseData); @@ -111,7 +112,7 @@ TEST_CASE("Test disk cache with Sqlite") { REQUIRE(cacheResponse.headers.at("Content-Type") == "text/html"); REQUIRE(cacheResponse.statusCode == 200); REQUIRE(cacheResponse.headers.at("Response-Header-" + std::to_string(i)) == "Response-Value-" + std::to_string(i)); - REQUIRE(cacheResponse.data == std::vector{ 0, 1, 2, 3, 4 }); + REQUIRE(cacheResponse.data == std::vector{ std::byte(0), std::byte(1), std::byte(2), std::byte(3), std::byte(4) }); std::optional cacheControl = ResponseCacheControl::parseFromResponseHeaders(cacheResponse.headers); REQUIRE(cacheControl.has_value()); @@ -133,7 +134,7 @@ TEST_CASE("Test disk cache with Sqlite") { {"Content-Type", "text/html"}, {"Response-Header", "Response-Value"} }; - std::vector responseData = {0, 1, 2, 3, 4}; + std::vector responseData = { std::byte(0), std::byte(1), std::byte(2), std::byte(3), std::byte(4) }; std::unique_ptr response = std::make_unique( static_cast(200), "text/html", diff --git a/CesiumGltf/include/CesiumGltf/AccessorView.h b/CesiumGltf/include/CesiumGltf/AccessorView.h index 84f68d0dd..19f42afb7 100644 --- a/CesiumGltf/include/CesiumGltf/AccessorView.h +++ b/CesiumGltf/include/CesiumGltf/AccessorView.h @@ -2,6 +2,7 @@ #include "CesiumGltf/Model.h" #include +#include namespace CesiumGltf { @@ -64,7 +65,7 @@ namespace CesiumGltf { template class AccessorView final { private: - const uint8_t* _pData; + const std::byte* _pData; int64_t _stride; int64_t _offset; int64_t _size; @@ -101,7 +102,7 @@ namespace CesiumGltf { * @param offset The offset from the start of the buffer to the first element. * @param size The total number of elements. */ - AccessorView(const uint8_t* pData, int64_t stride, int64_t offset, int64_t size) : + AccessorView(const std::byte* pData, int64_t stride, int64_t offset, int64_t size) : _pData(pData), _stride(stride), _offset(offset), @@ -199,7 +200,7 @@ namespace CesiumGltf { return; } - const std::vector& data = pBuffer->cesium.data; + const std::vector& data = pBuffer->cesium.data; int64_t bufferBytes = int64_t(data.size()); if (pBufferView->byteOffset + pBufferView->byteLength > bufferBytes) { this->_status = AccessorViewStatus::BufferTooSmall; diff --git a/CesiumGltf/include/CesiumGltf/BufferCesium.h b/CesiumGltf/include/CesiumGltf/BufferCesium.h index 4e4ed068a..29685bc2b 100644 --- a/CesiumGltf/include/CesiumGltf/BufferCesium.h +++ b/CesiumGltf/include/CesiumGltf/BufferCesium.h @@ -2,6 +2,7 @@ #include "CesiumGltf/Library.h" #include +#include namespace CesiumGltf { /** @@ -11,6 +12,6 @@ namespace CesiumGltf { /** * @brief The buffer's data. */ - std::vector data; + std::vector data; }; } diff --git a/CesiumGltfReader/include/CesiumGltf/Reader.h b/CesiumGltfReader/include/CesiumGltf/Reader.h index d457b48d0..8a7f289b4 100644 --- a/CesiumGltfReader/include/CesiumGltf/Reader.h +++ b/CesiumGltfReader/include/CesiumGltf/Reader.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace CesiumGltf { /** @@ -66,7 +67,7 @@ namespace CesiumGltf { * @param options Options for how to read the glTF. * @return The result of reading the glTF. */ - CESIUMGLTFREADER_API ModelReaderResult readModel(const gsl::span& data, const ReadModelOptions& options = ReadModelOptions()); + CESIUMGLTFREADER_API ModelReaderResult readModel(const gsl::span& data, const ReadModelOptions& options = ReadModelOptions()); /** * @brief The result of reading an image with {@link readImage}. @@ -100,5 +101,5 @@ namespace CesiumGltf { * @param data The buffer from which to read the image. * @return The result of reading the image. */ - CESIUMGLTFREADER_API ImageReaderResult readImage(const gsl::span& data); + CESIUMGLTFREADER_API ImageReaderResult readImage(const gsl::span& data); } diff --git a/CesiumGltfReader/src/Reader.cpp b/CesiumGltfReader/src/Reader.cpp index 1e2c4e017..2c41743b0 100644 --- a/CesiumGltfReader/src/Reader.cpp +++ b/CesiumGltfReader/src/Reader.cpp @@ -5,6 +5,7 @@ #include "ModelJsonHandler.h" #include #include +#include #define STB_IMAGE_IMPLEMENTATION #define STBI_FAILURE_USERMSG @@ -121,7 +122,7 @@ namespace { }; #pragma pack(pop) - bool isBinaryGltf(const gsl::span& data) { + bool isBinaryGltf(const gsl::span& data) { if (data.size() < sizeof(GlbHeader)) { return false; } @@ -129,7 +130,7 @@ namespace { return reinterpret_cast(data.data())->magic == 0x46546C67; } - ModelReaderResult readJsonModel(const gsl::span& data) { + ModelReaderResult readJsonModel(const gsl::span& data) { rapidjson::Reader reader; rapidjson::MemoryStream inputStream(reinterpret_cast(data.data()), data.size()); @@ -161,7 +162,7 @@ namespace { return result; } - ModelReaderResult readBinaryModel(const gsl::span& data) { + ModelReaderResult readBinaryModel(const gsl::span& data) { if (data.size() < sizeof(GlbHeader) + sizeof(ChunkHeader)) { return { std::nullopt, @@ -195,7 +196,7 @@ namespace { }; } - gsl::span glbData = data.subspan(0, pHeader->length); + gsl::span glbData = data.subspan(0, pHeader->length); const ChunkHeader* pJsonChunkHeader = reinterpret_cast(glbData.data() + sizeof(GlbHeader)); if (pJsonChunkHeader->chunkType != 0x4E4F534A) { @@ -217,8 +218,8 @@ namespace { }; } - gsl::span jsonChunk = glbData.subspan(jsonStart, pJsonChunkHeader->chunkLength); - gsl::span binaryChunk; + gsl::span jsonChunk = glbData.subspan(jsonStart, pJsonChunkHeader->chunkLength); + gsl::span binaryChunk; if (jsonEnd + sizeof(ChunkHeader) <= data.size()) { const ChunkHeader* pBinaryChunkHeader = reinterpret_cast(glbData.data() + jsonEnd); @@ -266,7 +267,7 @@ namespace { return result; } - buffer.cesium.data = std::vector(binaryChunk.begin(), binaryChunk.begin() + buffer.byteLength); + buffer.cesium.data = std::vector(binaryChunk.begin(), binaryChunk.begin() + buffer.byteLength); } return result; @@ -289,8 +290,8 @@ namespace { continue; } - gsl::span bufferSpan(buffer.cesium.data); - gsl::span bufferViewSpan = bufferSpan.subspan(static_cast(bufferView.byteOffset), static_cast(bufferView.byteLength)); + gsl::span bufferSpan(buffer.cesium.data); + gsl::span bufferViewSpan = bufferSpan.subspan(static_cast(bufferView.byteOffset), static_cast(bufferView.byteLength)); ImageReaderResult imageResult = readImage(bufferViewSpan); if (imageResult.image) { image.cesium = std::move(imageResult.image.value()); @@ -304,7 +305,7 @@ namespace { } } -ModelReaderResult CesiumGltf::readModel(const gsl::span& data, const ReadModelOptions& options) { +ModelReaderResult CesiumGltf::readModel(const gsl::span& data, const ReadModelOptions& options) { ModelReaderResult result = isBinaryGltf(data) ? readBinaryModel(data) : readJsonModel(data); if (result.model) { @@ -314,7 +315,7 @@ ModelReaderResult CesiumGltf::readModel(const gsl::span& data, co return result; } -ImageReaderResult CesiumGltf::readImage(const gsl::span& data) { +ImageReaderResult CesiumGltf::readImage(const gsl::span& data) { ImageReaderResult result; result.image.emplace(); @@ -324,7 +325,7 @@ ImageReaderResult CesiumGltf::readImage(const gsl::span& data) { image.channels = 4; int channelsInFile; - stbi_uc* pImage = stbi_load_from_memory(data.data(), static_cast(data.size()), &image.width, &image.height, &channelsInFile, image.channels); + stbi_uc* pImage = stbi_load_from_memory(reinterpret_cast(data.data()), static_cast(data.size()), &image.width, &image.height, &channelsInFile, image.channels); if (pImage) { image.pixelData.assign(pImage, pImage + image.width * image.height * image.channels * image.bytesPerChannel); stbi_image_free(pImage); diff --git a/CesiumGltfReader/src/decodeDataUrls.cpp b/CesiumGltfReader/src/decodeDataUrls.cpp index 2c8d97a5f..efcea0d22 100644 --- a/CesiumGltfReader/src/decodeDataUrls.cpp +++ b/CesiumGltfReader/src/decodeDataUrls.cpp @@ -2,11 +2,12 @@ #include "CesiumGltf/Reader.h" #include "decodeDataUrls.h" #include +#include namespace { - std::vector decodeBase64(gsl::span data) { - std::vector result(modp_b64_decode_len(data.size())); + std::vector decodeBase64(gsl::span data) { + std::vector result(modp_b64_decode_len(data.size())); size_t resultLength = modp_b64_decode(reinterpret_cast(result.data()), reinterpret_cast(data.data()), data.size()); if (resultLength == size_t(-1)) { @@ -21,7 +22,7 @@ namespace { struct DecodeResult { std::string mimeType; - std::vector data; + std::vector data; }; std::optional tryDecode(const std::string& uri) { @@ -53,7 +54,7 @@ namespace { result.mimeType = result.mimeType.substr(0, result.mimeType.size() - base64IndicatorLength); } - gsl::span data(reinterpret_cast(uri.data()) + dataDelimeter + 1, uri.size() - dataDelimeter - 1); + gsl::span data(reinterpret_cast(uri.data()) + dataDelimeter + 1, uri.size() - dataDelimeter - 1); if (isBase64Encoded) { result.data = decodeBase64(data); @@ -62,7 +63,7 @@ namespace { return std::nullopt; } } else { - result.data = std::vector(data.begin(), data.end()); + result.data = std::vector(data.begin(), data.end()); } return result; diff --git a/CesiumGltfReader/src/decodeDraco.cpp b/CesiumGltfReader/src/decodeDraco.cpp index 2e953a78e..8cc4d7237 100644 --- a/CesiumGltfReader/src/decodeDraco.cpp +++ b/CesiumGltfReader/src/decodeDraco.cpp @@ -3,6 +3,7 @@ #include "CesiumGltf/KHR_draco_mesh_compression.h" #include "CesiumGltf/Reader.h" #include +#include #ifdef _MSC_VER #pragma warning(push) @@ -47,7 +48,7 @@ namespace { return nullptr; } - gsl::span data(buffer.cesium.data.data() + bufferView.byteOffset, static_cast(bufferView.byteLength)); + gsl::span data(buffer.cesium.data.data() + bufferView.byteOffset, static_cast(bufferView.byteLength)); draco::DecoderBuffer decodeBuffer; decodeBuffer.Init(reinterpret_cast(data.data()), data.size()); diff --git a/CesiumGltfReader/test/TestReader.cpp b/CesiumGltfReader/test/TestReader.cpp index 4dfd4b166..5f7a1ae47 100644 --- a/CesiumGltfReader/test/TestReader.cpp +++ b/CesiumGltfReader/test/TestReader.cpp @@ -7,11 +7,12 @@ #include #include #include +#include using namespace CesiumGltf; namespace { - std::vector readFile(const std::string& path) { + std::vector readFile(const std::string& path) { FILE* fp = std::fopen(path.c_str(), "rb"); REQUIRE(fp); @@ -20,7 +21,7 @@ namespace { long pos = std::ftell(fp); std::fseek(fp, 0, SEEK_SET); - std::vector result(static_cast(pos)); + std::vector result(static_cast(pos)); size_t itemsRead = std::fread(result.data(), 1, result.size(), fp); REQUIRE(itemsRead == result.size()); @@ -63,7 +64,7 @@ TEST_CASE("CesiumGltf::Reader") { " }],"s + " \"surprise\":{\"foo\":true}"s + "}"s; - ModelReaderResult result = CesiumGltf::readModel(gsl::span(reinterpret_cast(s.c_str()), s.size())); + ModelReaderResult result = CesiumGltf::readModel(gsl::span(reinterpret_cast(s.c_str()), s.size())); CHECK(result.errors.empty()); REQUIRE(result.model.has_value()); @@ -93,7 +94,7 @@ TEST_CASE("CesiumGltf::Reader") { TEST_CASE("Read TriangleWithoutIndices") { std::filesystem::path gltfFile = CesiumGltfReader_TEST_DATA_DIR; gltfFile /= "TriangleWithoutIndices.gltf"; - std::vector data = readFile(gltfFile.string()); + std::vector data = readFile(gltfFile.string()); ModelReaderResult result = CesiumGltf::readModel(data); REQUIRE(result.model); diff --git a/CesiumIonClient/src/Connection.cpp b/CesiumIonClient/src/Connection.cpp index 3c4d71b01..86f4e6945 100644 --- a/CesiumIonClient/src/Connection.cpp +++ b/CesiumIonClient/src/Connection.cpp @@ -441,7 +441,7 @@ CesiumAsync::Future> Connection::createToken( } writer.EndObject(); - gsl::span tokenBytes(reinterpret_cast(tokenBuffer.GetString()), tokenBuffer.GetSize()); + gsl::span tokenBytes(reinterpret_cast(tokenBuffer.GetString()), tokenBuffer.GetSize()); return this->_pAssetAccessor->post( this->_asyncSystem, CesiumUtility::Uri::resolve(this->_apiUrl, "v1/tokens"), @@ -522,7 +522,7 @@ CesiumAsync::Future> Connection::createToken( writer.String(codeVerifier.c_str(), rapidjson::SizeType(codeVerifier.size())); writer.EndObject(); - gsl::span payload(reinterpret_cast(postBuffer.GetString()), postBuffer.GetSize()); + gsl::span payload(reinterpret_cast(postBuffer.GetString()), postBuffer.GetSize()); return pAssetAccessor->post( asyncSystem,