Skip to content

Commit

Permalink
Fixed build
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Feb 15, 2024
1 parent 57d5aa1 commit aead428
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
1 change: 1 addition & 0 deletions Sources/Jazz2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@
<ClInclude Include="$(ExtensionLibraryPath)\Containers\SequenceHelpers.h" />
<ClInclude Include="$(ExtensionLibraryPath)\Containers\StringUtils.h" />
<ClInclude Include="$(ExtensionLibraryPath)\Containers\StringConcatenable.h" />
<ClInclude Include="$(ExtensionLibraryPath)\Containers\StringStl.h" />
<ClInclude Include="simdjson\simdjson.h" />
</ItemGroup>
<ItemGroup>
Expand Down
70 changes: 70 additions & 0 deletions Sources/Shared/Containers/StringStl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
// 2017, 2018, 2019, 2020, 2021, 2022, 2023
// Vladimír Vondruš <[email protected]> and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#pragma once

/** @file
@brief STL @ref std::string compatibility for @ref Death::Containers::String and @ref Death::Containers::StringView
Including this header allows you to convert a
@ref Death::Containers::String / @ref Death::Containers::StringView from
and to a @ref std::string.
*/

#include <string>

#include "String.h"
#include "StringView.h"

namespace Death { namespace Containers { namespace Implementation {
//###==##====#=====--==~--~=~- --- -- - - - -

template<> struct StringConverter<std::string> {
static String from(const std::string& other) {
return String{other.data(), other.size()};
}
static std::string to(const String& other) {
return std::string{other.data(), other.size()};
}
};

template<> struct StringViewConverter<const char, std::string> {
static StringView from(const std::string& other) {
return StringView{other.data(), other.size(), StringViewFlags::NullTerminated};
}
static std::string to(StringView other) {
return std::string{other.data(), other.size()};
}
};

template<> struct StringViewConverter<char, std::string> {
static MutableStringView from(std::string& other) {
// .data() returns a const pointer until C++17, so have to use &other[0]. It's guaranteed
// to return a pointer to a single null character if the string is empty.
return MutableStringView{&other[0], other.size(), StringViewFlags::NullTerminated};
}
static std::string to(MutableStringView other) {
return std::string{other.data(), other.size()};
}
};

}}}
2 changes: 1 addition & 1 deletion Sources/Shared/IO/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ namespace Death { namespace IO {
buffer[pathLength] = '\0';
const char* baseName = ::basename(buffer);
if (hidden && baseName != nullptr && baseName[0] != '.') {
String newPath = CombinePath(GetDirectoryName(nullTerminatedPath), "."_s + baseName);
String newPath = CombinePath(GetDirectoryName(nullTerminatedPath), String("."_s + baseName));
return (::rename(nullTerminatedPath.data(), newPath.data()) == 0);
} else if (!hidden && baseName != nullptr && baseName[0] == '.') {
std::int32_t numDots = 0;
Expand Down
1 change: 1 addition & 0 deletions cmake/ncine_headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ set(HEADERS
${NCINE_SOURCE_DIR}/Shared/Containers/StaticArray.h
${NCINE_SOURCE_DIR}/Shared/Containers/String.h
${NCINE_SOURCE_DIR}/Shared/Containers/StringConcatenable.h
${NCINE_SOURCE_DIR}/Shared/Containers/StringStl.h
${NCINE_SOURCE_DIR}/Shared/Containers/StringStlView.h
${NCINE_SOURCE_DIR}/Shared/Containers/StringUtils.h
${NCINE_SOURCE_DIR}/Shared/Containers/StringView.h
Expand Down

0 comments on commit aead428

Please sign in to comment.