Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc #125

Merged
merged 5 commits into from
Jul 7, 2024
Merged

Misc #125

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AllowShortFunctionsOnASingleLine: None
BraceWrapping:
AfterNamespace: true
BeforeWhile: true
# BreakAfterAttributes: Always # clang-format-16
BreakAfterAttributes: Always
BreakBeforeBraces: Allman
ColumnLimit: 120
FixNamespaceComments: true
Expand Down
5 changes: 5 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
Checks: '*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-modernize-use-trailing-return-type,-llvm*'
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
156 changes: 156 additions & 0 deletions cfb_utils/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions src/CfbfStreamLocation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class CfbfStreamLocation
std::vector<std::string> mStreamLocation{};
};

[[maybe_unused]] static std::string to_string(const CfbfStreamLocation& aLocation)
[[maybe_unused]]
static std::string to_string(const CfbfStreamLocation& aLocation)
{
std::string locStr{};
for(const auto& locPart : aLocation.get_vector())
Expand All @@ -106,17 +107,20 @@ class CfbfStreamLocation
return locStr;
}

[[maybe_unused]] static bool operator==(const CfbfStreamLocation& aLhs, const std::vector<std::string>& aRhs)
[[maybe_unused]]
static bool operator==(const CfbfStreamLocation& aLhs, const std::vector<std::string>& aRhs)
{
return aLhs.get_vector() == aRhs;
}

[[maybe_unused]] static bool operator==(const std::vector<std::string>& aLhs, const CfbfStreamLocation& aRhs)
[[maybe_unused]]
static bool operator==(const std::vector<std::string>& aLhs, const CfbfStreamLocation& aRhs)
{
return aRhs == aLhs;
}

[[maybe_unused]] static bool operator==(const CfbfStreamLocation& aLhs, const CfbfStreamLocation& aRhs)
[[maybe_unused]]
static bool operator==(const CfbfStreamLocation& aLhs, const CfbfStreamLocation& aRhs)
{
return aLhs.get_vector() == aRhs.get_vector();
}
Expand Down
11 changes: 5 additions & 6 deletions src/ContainerContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ namespace fs = std::filesystem;
OOCP::ContainerContext::ContainerContext(
const fs::path& aInputCfbfFile, const fs::path& aExtractedCfbfPath, ParserConfig aCfg, Database& aDb)
: mDb{aDb},
mInputCfbfFile{aInputCfbfFile},
mExtractedCfbfPath{aExtractedCfbfPath},
mCfg{aCfg},
mFileFormatVersion{FileFormatVersion::C},
mLogLevel{spdlog::level::trace},
mLogger{"tmp"}
{
mInputCfbfFile = aInputCfbfFile;
mExtractedCfbfPath = aExtractedCfbfPath;
mCfg = aCfg;
mFileFormatVersion = FileFormatVersion::C;
mLogLevel = spdlog::level::trace;

const fs::path logPath = mExtractedCfbfPath / "logs" / "OpenOrCadParser.log";
configureLogger(logPath);
}
Expand Down
3 changes: 2 additions & 1 deletion src/ContainerContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ struct ParserConfig
bool mKeepTmpFiles{true}; //!< Do not delete temporary files after parser completed
};

[[maybe_unused]] static std::string to_string(const ParserConfig& aCfg)
[[maybe_unused]]
static std::string to_string(const ParserConfig& aCfg)
{
std::string str;
str += fmt::format("mSkipUnknownPrim = {}\n", aCfg.mSkipUnknownPrim);
Expand Down
4 changes: 1 addition & 3 deletions src/ContainerExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

namespace fs = std::filesystem;

using namespace OOCP;

OOCP::ContainerExtractor::ContainerExtractor(const fs::path& aContainer)
{
mContainer = aContainer;
Expand Down Expand Up @@ -62,7 +60,7 @@ void OOCP::ContainerExtractor::outputFileInfo() const
<< "mini fat sector: " << hdr->numMiniFATSector << std::endl;
}

void ContainerExtractor::outputEntryInfo(const CFB::COMPOUND_FILE_ENTRY* aEntry) const
void OOCP::ContainerExtractor::outputEntryInfo(const CFB::COMPOUND_FILE_ENTRY* aEntry) const
{
std::clog << "entry type: "
<< (mReader->IsPropertyStream(aEntry) ? "property" : (mReader->IsStream(aEntry) ? "stream" : "directory"))
Expand Down
4 changes: 3 additions & 1 deletion src/DataStream.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <algorithm>
#include <cstdint>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>

#include <fmt/core.h>
#include <spdlog/spdlog.h>
Expand Down Expand Up @@ -213,7 +215,7 @@ std::string OOCP::DataStream::dataToStr(const std::vector<uint8_t>& aData)
preamble = fmt::format("0x{:08x}: ", getCurrentOffset());
}

char c = static_cast<char>(aData[i]);
const char c = static_cast<char>(aData[i]);
line_hex += fmt::format("{:02x}", aData[i]);
line_str += std::isprint(c) ? c : '.';

Expand Down
6 changes: 4 additions & 2 deletions src/Database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class Database
std::vector<std::shared_ptr<Stream>> mStreams;
};

[[maybe_unused]] static std::string to_string(const Database& aObj)
[[maybe_unused]]
static std::string to_string(const Database& aObj)
{
std::string str;

Expand All @@ -52,7 +53,8 @@ class Database
return str;
}

[[maybe_unused]] static std::ostream& operator<<(std::ostream& aOs, const Database& aVal)
[[maybe_unused]]
static std::ostream& operator<<(std::ostream& aOs, const Database& aVal)
{
aOs << to_string(aVal);

Expand Down
9 changes: 6 additions & 3 deletions src/Enums/Color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,20 @@ enum class Color
Default = 48
};

[[maybe_unused]] static constexpr Color ToColor(uint32_t aVal)
[[maybe_unused]]
static constexpr Color ToColor(uint32_t aVal)
{
return ToEnum<Color, decltype(aVal)>(aVal);
}

[[maybe_unused]] static std::string to_string(const Color& aVal)
[[maybe_unused]]
static std::string to_string(const Color& aVal)
{
return std::string{magic_enum::enum_name<decltype(aVal)>(aVal)};
}

[[maybe_unused]] static std::ostream& operator<<(std::ostream& aOs, const Color& aVal)
[[maybe_unused]]
static std::ostream& operator<<(std::ostream& aOs, const Color& aVal)
{
aOs << to_string(aVal);
return aOs;
Expand Down
9 changes: 6 additions & 3 deletions src/Enums/ComponentType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ enum class ComponentType
// too often to be a realistic corruption issue but I need to confirm this.
};

[[maybe_unused]] static constexpr ComponentType ToComponentType(uint16_t aVal)
[[maybe_unused]]
static constexpr ComponentType ToComponentType(uint16_t aVal)
{
// See the explanation at HACKY_VALUE for this hack
if(aVal > 100U)
Expand All @@ -70,12 +71,14 @@ enum class ComponentType
return ToEnum<ComponentType, decltype(aVal)>(aVal);
}

[[maybe_unused]] static std::string to_string(const ComponentType& aVal)
[[maybe_unused]]
static std::string to_string(const ComponentType& aVal)
{
return std::string{magic_enum::enum_name<decltype(aVal)>(aVal)};
}

[[maybe_unused]] static std::ostream& operator<<(std::ostream& aOs, const ComponentType& aVal)
[[maybe_unused]]
static std::ostream& operator<<(std::ostream& aOs, const ComponentType& aVal)
{
aOs << to_string(aVal);
return aOs;
Expand Down
6 changes: 4 additions & 2 deletions src/Enums/DirectoryType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ enum class DirectoryType
ViewsDirectory
};

[[maybe_unused]] static std::string to_string(const DirectoryType& aVal)
[[maybe_unused]]
static std::string to_string(const DirectoryType& aVal)
{
switch(aVal)
{
Expand Down Expand Up @@ -52,7 +53,8 @@ enum class DirectoryType
}
}

[[maybe_unused]] static std::ostream& operator<<(std::ostream& aOs, const DirectoryType& aVal)
[[maybe_unused]]
static std::ostream& operator<<(std::ostream& aOs, const DirectoryType& aVal)
{
aOs << to_string(aVal);
return aOs;
Expand Down
9 changes: 6 additions & 3 deletions src/Enums/FillStyle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ enum class FillStyle
HatchPattern = 2 // Refer to HatchStyle
};

[[maybe_unused]] static constexpr FillStyle ToFillStyle(uint32_t aVal)
[[maybe_unused]]
static constexpr FillStyle ToFillStyle(uint32_t aVal)
{
return ToEnum<FillStyle, decltype(aVal)>(aVal);
}

[[maybe_unused]] static std::string to_string(const FillStyle& aVal)
[[maybe_unused]]
static std::string to_string(const FillStyle& aVal)
{
return std::string{magic_enum::enum_name<decltype(aVal)>(aVal)};
}

[[maybe_unused]] static std::ostream& operator<<(std::ostream& aOs, const FillStyle& aVal)
[[maybe_unused]]
static std::ostream& operator<<(std::ostream& aOs, const FillStyle& aVal)
{
aOs << to_string(aVal);
return aOs;
Expand Down
Loading
Loading