Skip to content

Commit a160385

Browse files
Push nuget GitHub (#1)
* Update azure-pipelines.yml * Updated the clang-format. Updated to use nuget.config * Updated the nuspec to include the repository tag
1 parent a6f6eb5 commit a160385

File tree

5 files changed

+94
-80
lines changed

5 files changed

+94
-80
lines changed

.clang-format

+34-25
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,67 @@
1-
# Visual Studio generated .clang-format file
1+
# SiddiqSoft clang-format
2+
# Version 2, August 2021
23

3-
# The style options in this file are a best effort attempt to replicate the
4-
# current IDE formatting configuration from Tools > Options. The following
5-
# style options, however, should be verified:
6-
# AfterClass, AfterControlStatement, AfterEnum, AfterFunction, AfterNamespace,
7-
# AfterStruct, AfterUnion
4+
Language: Cpp
85

96
AccessModifierOffset: -4
107

118
AlignAfterOpenBracket: Align # ours is Align
12-
AlignConsecutiveDeclarations: true
13-
AlignOperands: true
9+
#AlignArrayOfStructures: Left
10+
AlignConsecutiveDeclarations: Consecutive
11+
AlignOperands: AlignAfterOperator
1412
AlignTrailingComments: true
15-
AlignConsecutiveAssignments: true
13+
AlignConsecutiveAssignments: AcrossEmptyLines
1614
AlignEscapedNewlines: DontAlign
15+
AlignConsecutiveMacros: AcrossEmptyLines
1716

18-
AllowShortBlocksOnASingleLine: true
17+
AllowAllArgumentsOnNextLine: true
18+
AllowShortBlocksOnASingleLine: Empty
1919
AllowShortFunctionsOnASingleLine: Inline
2020
AllowShortIfStatementsOnASingleLine: true
2121
AllowShortLoopsOnASingleLine: false
2222
AlwaysBreakAfterDefinitionReturnType: None
2323
AlwaysBreakBeforeMultilineStrings : false
2424
AllowAllParametersOfDeclarationOnNextLine : false
2525
AllowShortCaseLabelsOnASingleLine : true
26+
AllowShortLambdasOnASingleLine: Inline
27+
AlwaysBreakTemplateDeclarations: Yes
2628

2729
BinPackArguments : false
2830
BinPackParameters : false
2931

30-
BasedOnStyle: WebKit
32+
33+
BreakBeforeBraces: Custom
3134
BraceWrapping:
35+
AfterCaseLabel: false
3236
AfterClass: true # TODO: verify
33-
# AfterControlStatement: true # TODO: verify
34-
# AfterEnum: true # TODO: verify
37+
AfterControlStatement: MultiLine
38+
AfterEnum: true # TODO: verify
3539
AfterFunction: true # TODO: verify
36-
# AfterNamespace: true # TODO: verify
37-
# AfterStruct: true # TODO: verify
38-
# AfterUnion: true # TODO: verify
40+
AfterNamespace: true # TODO: verify
41+
AfterStruct: true # TODO: verify
42+
AfterUnion: true # TODO: verify
3943
BeforeCatch: true
4044
BeforeElse: true
41-
# IndentBraces: false
42-
# SplitEmptyFunction: true
43-
# SplitEmptyRecord: true
45+
BeforeLambdaBody: false
46+
BeforeWhile: false
47+
IndentBraces: false
48+
SplitEmptyFunction: true
49+
SplitEmptyRecord: true
4450

45-
BreakBeforeBraces: Allman
46-
BreakConstructorInitializers: BeforeComma
51+
BasedOnStyle: WebKit
52+
#BreakConstructorInitializersStyle: AfterComma
4753
BreakBeforeTernaryOperators : true
4854
BreakBeforeBinaryOperators : None
4955
BreakInheritanceList : BeforeComma
56+
BreakBeforeConceptDeclarations: true
5057

5158
ContinuationIndentWidth : 8
5259
ColumnLimit: 132
5360
Cpp11BracedListStyle: true
54-
IndentCaseLabels: false
61+
IndentCaseLabels: true
5562
IndentPPDirectives: None
5663
IndentWidth: 4
64+
IndentRequires: true
5765
PointerAlignment: Left
5866
SpaceAfterCStyleCast: false
5967
SpaceBeforeAssignmentOperators: true
@@ -65,13 +73,14 @@ MaxEmptyLinesToKeep: 2
6573
NamespaceIndentation: All
6674
CompactNamespaces : false
6775
FixNamespaceComments : true
68-
Standard: Cpp11
76+
Standard: Latest
6977
TabWidth: 4
70-
UseTab: AlignWithSpaces
78+
UseTab: ForIndentation
7179
SortIncludes: false
7280
SortUsingDeclarations: false
7381
IncludeBlocks : Preserve
74-
ReflowComments: false
82+
ReflowComments: true
83+
#LambdaBodyIndentation: Signature
7584

7685
ConstructorInitializerAllOnOneLineOrOnePerLine: false
7786
ConstructorInitializerIndentWidth: 4

azure-pipelines.yml

+2-11
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ steps:
4242
inputs:
4343
command: 'restore'
4444
restoreSolution: '**/*.sln'
45-
feedsToUse: 'select'
46-
vstsFeed: 'ec2759e0-0587-4306-8a8d-8695f15e2336'
45+
feedsToUse: 'config'
46+
externalFeedCredentials: 'github-nuget-package-sqs'
4747
continueOnError: false
4848

4949
- task: VSBuild@1
@@ -91,15 +91,6 @@ steps:
9191
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
9292
continueOnError: true
9393

94-
- task: NuGetCommand@2
95-
displayName: 'NuGet push'
96-
inputs:
97-
command: 'push'
98-
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg;build/*.nupkg;!build/*symbols.nupkg'
99-
nuGetFeedType: 'external'
100-
publishFeedCredentials: 'github-nuget-package-sqs'
101-
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
102-
10394
- task: GitHubRelease@1
10495
inputs:
10596
gitHubConnection: 'github-packages-sqs'

nuget.config

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<packageSources>
4+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
5+
<add key="github" value="https://nuget.pkg.github.com/SiddiqSoft/index.json" />
6+
</packageSources>
7+
</configuration>

nuget/SiddiqSoft.TimeThis.nuspec

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<description>Simple stopwatch implementation with optional callback on destructor</description>
1515
<tags>lambda destructor onexit time stopwatch timer cpp20 source_location scoped native nativepackage cpp</tags>
1616
<projectUrl>https://github.com/SiddiqSoft/TimeThis</projectUrl>
17+
<repository type="git" url="https://github.com/SiddiqSoft/TimeThis" />
1718
<requireLicenseAcceptance>true</requireLicenseAcceptance>
1819
<license type="expression">BSD-3-Clause</license>
1920
<icon>docs\Siddiq-Software-Avatar.png</icon>

src/TimeThis.hpp

+50-44
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
/*
2-
TimeThis : Simple stopwatch implementation with optional callback on destructor
3-
Version 1.0.0
2+
TimeThis : Simple stopwatch implementation with optional callback on destructor
3+
Version 1.0.0
44
5-
https://github.com/SiddiqSoft/TimeThis
5+
https://github.com/SiddiqSoft/TimeThis
66
7-
BSD 3-Clause License
7+
BSD 3-Clause License
88
9-
Copyright (c) 2021, Siddiq Software LLC
10-
All rights reserved.
9+
Copyright (c) 2021, Siddiq Software LLC
10+
All rights reserved.
1111
12-
Redistribution and use in source and binary forms, with or without
13-
modification, are permitted provided that the following conditions are met:
12+
Redistribution and use in source and binary forms, with or without
13+
modification, are permitted provided that the following conditions are met:
1414
15-
1. Redistributions of source code must retain the above copyright notice, this
16-
list of conditions and the following disclaimer.
15+
1. Redistributions of source code must retain the above copyright notice, this
16+
list of conditions and the following disclaimer.
1717
18-
2. Redistributions in binary form must reproduce the above copyright notice,
19-
this list of conditions and the following disclaimer in the documentation
20-
and/or other materials provided with the distribution.
18+
2. Redistributions in binary form must reproduce the above copyright notice,
19+
this list of conditions and the following disclaimer in the documentation
20+
and/or other materials provided with the distribution.
2121
22-
3. Neither the name of the copyright holder nor the names of its
23-
contributors may be used to endorse or promote products derived from
24-
this software without specific prior written permission.
22+
3. Neither the name of the copyright holder nor the names of its
23+
contributors may be used to endorse or promote products derived from
24+
this software without specific prior written permission.
2525
26-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
30-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
30+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
*/
3737

3838
#pragma once
39-
#ifndef TimeThis_HPP
40-
#define TimeThis_HPP 1
39+
#ifndef TIMETHIS_HPP
40+
#define TIMETHIS_HPP 1
4141

4242
#include <functional>
4343
#include <chrono>
@@ -59,13 +59,16 @@ namespace siddiqsoft
5959
{
6060
/// @brief Calculates the duration since the creation of this object
6161
/// @return Value representing the elapsed duration as timepoint
62-
auto elapsed() const { return std::chrono::system_clock::now() - startTimestamp; }
62+
auto elapsed() const
63+
{
64+
return std::chrono::system_clock::now() - startTimestamp;
65+
}
6366

6467
#if defined(__cpp_lib_source_location)
6568
/// @brief When source_location is available, collect the calling location
6669
explicit TimeThis(const std::source_location& sl = std::source_location::current())
67-
: sourceLocation(sl)
68-
, startTimestamp(std::chrono::system_clock::now())
70+
: sourceLocation(sl)
71+
, startTimestamp(std::chrono::system_clock::now())
6972
{
7073
}
7174

@@ -74,9 +77,9 @@ namespace siddiqsoft
7477
/// @param context Reference to the context
7578
explicit TimeThis(std::function<void(const std::chrono::system_clock::duration&)>&& callback,
7679
const std::source_location& sl = std::source_location::current())
77-
: sourceLocation(sl)
78-
, mCallback(std::move(callback))
79-
, startTimestamp(std::chrono::system_clock::now())
80+
: sourceLocation(sl)
81+
, mCallback(std::move(callback))
82+
, startTimestamp(std::chrono::system_clock::now())
8083
{
8184
}
8285

@@ -92,16 +95,16 @@ namespace siddiqsoft
9295
#else
9396
/// @brief Default constructor notes the start time
9497
TimeThis()
95-
: startTimestamp(std::chrono::system_clock::now())
98+
: startTimestamp(std::chrono::system_clock::now())
9699
{
97100
}
98101

99102
/// @brief Construct an object which holds the callback to be executed upon destruction
100103
/// @param callback The callback takes timepoint representing the final calculation of the delta
101104
/// @param context Reference to the context
102105
explicit TimeThis(std::function<void(const std::chrono::system_clock::duration&)>&& callback) noexcept
103-
: mCallback(std::move(callback))
104-
, startTimestamp(std::chrono::system_clock::now())
106+
: mCallback(std::move(callback))
107+
, startTimestamp(std::chrono::system_clock::now())
105108
{
106109
}
107110

@@ -116,11 +119,13 @@ namespace siddiqsoft
116119
}
117120
#endif
118121

119-
/// @brief Not supported. Makes no sense to copy another instance as the use-case should allow for a single task per callback.
122+
/// @brief Not supported. Makes no sense to copy another instance as the use-case should allow for a single task per
123+
/// callback.
120124
/// @param ignored
121125
TimeThis(TimeThis&) = delete;
122126

123-
/// @brief Not supported. Makes no sense to move another instance as the use-case should allow for a single task per callback.
127+
/// @brief Not supported. Makes no sense to move another instance as the use-case should allow for a single task per
128+
/// callback.
124129
/// @param ignored
125130
TimeThis(TimeThis&&) = delete;
126131

@@ -157,23 +162,24 @@ namespace siddiqsoft
157162

158163
#if defined __cpp_lib_format
159164
/// @brief Formatter for std::format
160-
template <> struct std::formatter<siddiqsoft::TimeThis> : std::formatter<std::string>
165+
template <>
166+
struct std::formatter<siddiqsoft::TimeThis> : std::formatter<std::string>
161167
{
162168
auto format(const siddiqsoft::TimeThis& sv, std::format_context& ctx)
163169
{
164170
#if defined __cpp_lib_source_location
165171
return std::formatter<std::string>::format(
166-
std::format("{} started on {:%FT%T}Z took {}us",
172+
std::format("{} started on {:%FT%T}Z took {}us",
167173
sv.sourceLocation.function_name(),
168174
sv.startTimestamp,
169175
std::chrono::duration_cast<std::chrono::microseconds>(sv.elapsed()).count()),
170-
ctx);
176+
ctx);
171177
#else
172178
return std::formatter<std::string>::format(
173-
std::format("scope started on {:%FT%T}Z took {}us",
179+
std::format("scope started on {:%FT%T}Z took {}us",
174180
std::chrono::duration_cast<std::chrono::microseconds>(sv.elapsed()).count(),
175181
sv.startTimestamp),
176-
ctx);
182+
ctx);
177183
#endif
178184
}
179185
};

0 commit comments

Comments
 (0)