Skip to content

Commit

Permalink
Update clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
durner committed Dec 15, 2023
1 parent e889567 commit 274c341
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 87 deletions.
141 changes: 98 additions & 43 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,36 +1,68 @@
---
Language: Cpp
# BasedOnStyle: Chromium
Language: Cpp
AccessModifierOffset: 0
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: false
AlignOperands: Align
AlignTrailingComments:
Kind: Never
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: OnlyFirstIf
AllowShortLoopsOnASingleLine: true
AllowShortLambdasOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterClass: false
AfterControlStatement: MultiLine
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
AfterCaseLabel: false
BeforeLambdaBody: false
BeforeWhile: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
Expand All @@ -39,36 +71,50 @@ BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
ColumnLimit: 0
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: true
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Regex: '^"'
Priority: 1
- Regex: '^<llvm/.*>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 4
- Regex: '^<'
Priority: 3
- Regex: '.\*'
Priority: 5
IncludeIsMainRegex: '([-_](test|unittest))?$'
- Regex: ^"
Priority: 1
- Regex: ^<llvm/.*>
Priority: 2
- Regex: ^<.*\.h>
Priority: 4
- Regex: ^<
Priority: 3
- Regex: .\*
Priority: 5
IncludeIsMainRegex: ([-_](test|unittest))?$
IndentAccessModifiers: false
IndentCaseLabels: true
IndentWidth: 4
IndentCaseBlocks: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: true
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
Expand All @@ -81,20 +127,29 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: false
SortIncludes: true
ReflowComments: false
SortIncludes: CaseSensitive
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInAngles: Leave
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never
...
Standard: Latest
TabWidth: 4
UseTab: Never
2 changes: 1 addition & 1 deletion example/benchmark/include/network/s3_send_receiver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <mutex>
#include <thread>
#include <unordered_map>
#include <unistd.h>
#include <aws/core/Aws.h>
#include <aws/core/client/ClientConfiguration.h>
#include <aws/core/utils/Outcome.h>
Expand All @@ -25,6 +24,7 @@
#include <aws/s3-crt/model/GetObjectRequest.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/GetObjectRequest.h>
#include <unistd.h>
// ---------------------------------------------------------------------------
// AnyBlob - Universal Cloud Object Storage Library
// Dominik Durner, 2021
Expand Down
2 changes: 1 addition & 1 deletion example/benchmark/src/benchmark/bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include "cloud/aws_resolver.hpp"
#include "cloud/azure.hpp"
#include "cloud/gcp.hpp"
#include "network/transaction.hpp"
#include "network/original_message.hpp"
#include "network/s3_send_receiver.hpp"
#include "network/tasked_send_receiver.hpp"
#include "network/transaction.hpp"
#include "perfevent/PerfEvent.hpp"
#include "utils/timer.hpp"
#include "utils/utils.hpp"
Expand Down
2 changes: 1 addition & 1 deletion example/simple/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "cloud/provider.hpp"
#include "network/transaction.hpp"
#include "network/tasked_send_receiver.hpp"
#include "network/transaction.hpp"
#include <cstring>
#include <iostream>
//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion include/cloud/aws.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "cloud/provider.hpp"
#include "utils/data_vector.hpp"
#include <cassert>
#include <mutex>
#include <memory>
#include <mutex>
#include <string>
//---------------------------------------------------------------------------
// AnyBlob - Universal Cloud Object Storage Library
Expand Down
3 changes: 1 addition & 2 deletions include/cloud/gcp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class GCP : public Provider {
/// Allows multipart upload if size > 0
[[nodiscard]] uint64_t multipartUploadSize() const override { return 128ull << 20; }


/// Builds the http request for downloading a blob or listing the directory
[[nodiscard]] std::unique_ptr<utils::DataVector<uint8_t>> getRequest(const std::string& filePath, const std::pair<uint64_t, uint64_t>& range) const override;
/// Builds the http request for putting objects without the object data itself
Expand All @@ -84,7 +83,7 @@ class GCP : public Provider {
[[nodiscard]] std::unique_ptr<utils::DataVector<uint8_t>> putRequest(const std::string& filePath, std::string_view object) const override {
return putRequestGeneric(filePath, object, 0, "");
}
// Builds the http request for deleting an objects
// Builds the http request for deleting an objects
[[nodiscard]] std::unique_ptr<utils::DataVector<uint8_t>> deleteRequest(const std::string& filePath) const override {
return deleteRequestGeneric(filePath, "");
}
Expand Down
8 changes: 3 additions & 5 deletions include/cloud/provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace cloud {
//---------------------------------------------------------------------------
/// Implements the cloud provider abstraction
class Provider {
public:
public:
/// The remote prefixes count
static constexpr unsigned remoteFileCount = 6;
/// The remote prefixes
Expand Down Expand Up @@ -75,8 +75,7 @@ class Provider {
uint64_t network;
};


protected:
protected:
CloudService _type;
/// Builds the http request for downloading a blob or listing a directory
[[nodiscard]] virtual std::unique_ptr<utils::DataVector<uint8_t>> getRequest(const std::string& filePath, const std::pair<uint64_t, uint64_t>& range) const = 0;
Expand All @@ -103,7 +102,7 @@ class Provider {
/// Initialize secret
virtual void initSecret(network::TaskedSendReceiver& /*sendReceiver*/) {}

public:
public:
/// The destructor
virtual ~Provider() = default;
/// Gets the cloud provider type
Expand All @@ -123,7 +122,6 @@ class Provider {
/// Parse a row from csv file
[[nodiscard]] static std::vector<std::string> parseCSVRow(std::string_view body);


/// Create a provider (keyId is access email for GCP/Azure)
[[nodiscard]] static std::unique_ptr<Provider> makeProvider(const std::string& filepath, bool https = true, const std::string& keyId = "", const std::string& keyFile = "", network::TaskedSendReceiver* sendReceiver = nullptr);

Expand Down
1 change: 0 additions & 1 deletion include/network/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct Config {
/// Total requests example: 100,000 Mbits / 400 Mbits = 250 Requests
static constexpr uint64_t defaultCoreThroughput = 8000;


/// Throughput per core in Mbit/s
uint64_t coreThroughput;
/// Concurrent requests to achieve coreThroughput
Expand Down
3 changes: 1 addition & 2 deletions include/network/message_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ struct MessageTask {
std::string_view s(reinterpret_cast<char*>(sendingMessage->message->data()), sendingMessage->message->size());
if (s.find("HTTP") != std::string_view::npos && sendingMessage->port == 443) {
return std::make_unique<HTTPSMessage>(sendingMessage, context, std::forward<Args>(args)...);
}
else if (s.find("HTTP") != std::string_view::npos) {
} else if (s.find("HTTP") != std::string_view::npos) {
return std::make_unique<HTTPMessage>(sendingMessage, std::forward<Args>(args)...);
}
return nullptr;
Expand Down
6 changes: 3 additions & 3 deletions include/network/tls_context.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
#include <memory>
#include <array>
#include <memory>
#include <unordered_map>
#include <openssl/types.h>
#include <openssl/ssl.h>
#include <openssl/types.h>
//---------------------------------------------------------------------------
// AnyBlob - Universal Cloud Object Storage Library
// Dominik Durner, 2023
Expand All @@ -28,7 +28,7 @@ class TLSContext {
/// The cache mask
static constexpr uint64_t cacheMask = (~0ull) >> (64 - cachePower);
/// The session cache
std::array<std::pair<uint64_t, SSL_SESSION*>, 1ull << cachePower> _sessionCache;
std::array<std::pair<uint64_t, SSL_SESSION*>, 1ull << cachePower> _sessionCache;

public:
/// The constructor
Expand Down
12 changes: 6 additions & 6 deletions include/utils/data_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ class DataVector {
}

/// Get the data
[[ nodiscard ]] constexpr T* data() {
[[nodiscard]] constexpr T* data() {
return _data;
}

/// Get the data
[[ nodiscard ]] constexpr const T* cdata() const {
[[nodiscard]] constexpr const T* cdata() const {
return _data;
}

/// Get the size
[[ nodiscard ]] constexpr uint64_t size() const {
[[nodiscard]] constexpr uint64_t size() const {
return _size;
}

/// Get the capacity
[[ nodiscard ]] constexpr uint64_t capacity() const {
[[nodiscard]] constexpr uint64_t capacity() const {
return _capacity;
}

Expand All @@ -80,7 +80,7 @@ class DataVector {
}

/// Is the data owned
[[ nodiscard ]] constexpr bool owned() {
[[nodiscard]] constexpr bool owned() {
return _dataOwned || !_capacity;
}

Expand All @@ -107,7 +107,7 @@ class DataVector {
}

/// Transfer the ownership of the data
[[ nodiscard ]] constexpr std::unique_ptr<T[]> transferBuffer() {
[[nodiscard]] constexpr std::unique_ptr<T[]> transferBuffer() {
return move(_dataOwned);
}
};
Expand Down
4 changes: 2 additions & 2 deletions include/utils/load_tracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class LoadTracker {
/// Get the active cpu times
static constexpr size_t getActiveTime(const CPUData& e) {
return e.times[static_cast<uint8_t>(CPUStates::S_USER)] + e.times[static_cast<uint8_t>(CPUStates::S_NICE)] +
e.times[static_cast<uint8_t>(CPUStates::S_SYSTEM)] + e.times[static_cast<uint8_t>(CPUStates::S_IRQ)] +
e.times[static_cast<uint8_t>(CPUStates::S_SOFTIRQ)] + e.times[static_cast<uint8_t>(CPUStates::S_STEAL)];
e.times[static_cast<uint8_t>(CPUStates::S_SYSTEM)] + e.times[static_cast<uint8_t>(CPUStates::S_IRQ)] +
e.times[static_cast<uint8_t>(CPUStates::S_SOFTIRQ)] + e.times[static_cast<uint8_t>(CPUStates::S_STEAL)];
}

/// Write stats as csv
Expand Down
Loading

0 comments on commit 274c341

Please sign in to comment.