Skip to content

Commit

Permalink
Apply make format to codebase (AcademySoftwareFoundation#1088)
Browse files Browse the repository at this point in the history
* tweak .clang-format

* apply make-format to the c++ codebase

* tweak the namespaces and constructors

* apply new format options

Co-authored-by: ssteinbach <[email protected]>
  • Loading branch information
ssteinbach and ssteinbach authored Oct 26, 2021
1 parent 7c285db commit 0aa7765
Show file tree
Hide file tree
Showing 77 changed files with 4,818 additions and 3,228 deletions.
22 changes: 11 additions & 11 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ AlignTrailingComments: true
# AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
# AllowAllConstructorInitializersOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
# AllowShortLambdasOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: TopLevel
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterReturnType: TopLevelDefinitions
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
Expand All @@ -50,8 +50,8 @@ BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
Expand Down Expand Up @@ -104,7 +104,7 @@ SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: false
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
Expand All @@ -113,8 +113,8 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
Standard: c++14
TabWidth: 4
#UseTab: ForIndentation
UseTab: Never
...
50 changes: 24 additions & 26 deletions src/opentime/errorStatus.cpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
#include "opentime/errorStatus.h"

namespace opentime { namespace OPENTIME_VERSION {

std::string ErrorStatus::outcome_to_string(Outcome o) {
switch(o) {
case OK:
return std::string();
case INVALID_TIMECODE_RATE:
return "invalid timecode rate";
case INVALID_TIMECODE_STRING:
return "string is not a valid timecode string";
case TIMECODE_RATE_MISMATCH:
return "timecode specifies a frame higher than its rate";
case INVALID_TIME_STRING:
return "invalid time string";
case NEGATIVE_VALUE:
return "value cannot be negative here";
case INVALID_RATE_FOR_DROP_FRAME_TIMECODE:
return "rate is not valid for drop frame timecode";
default:
return "unknown/illegal ErrorStatus::Outcome code";
namespace opentime { namespace OPENTIME_VERSION {

std::string
ErrorStatus::outcome_to_string(Outcome o)
{
switch (o)
{
case OK:
return std::string();
case INVALID_TIMECODE_RATE:
return "invalid timecode rate";
case INVALID_TIMECODE_STRING:
return "string is not a valid timecode string";
case TIMECODE_RATE_MISMATCH:
return "timecode specifies a frame higher than its rate";
case INVALID_TIME_STRING:
return "invalid time string";
case NEGATIVE_VALUE:
return "value cannot be negative here";
case INVALID_RATE_FOR_DROP_FRAME_TIMECODE:
return "rate is not valid for drop frame timecode";
default:
return "unknown/illegal ErrorStatus::Outcome code";
};
}

} }





}} // namespace opentime::OPENTIME_VERSION
42 changes: 25 additions & 17 deletions src/opentime/errorStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#include "opentime/version.h"
#include <string>

namespace opentime { namespace OPENTIME_VERSION {

struct ErrorStatus {
enum Outcome {
namespace opentime { namespace OPENTIME_VERSION {

struct ErrorStatus
{
enum Outcome
{
OK = 0,
INVALID_TIMECODE_RATE,
INVALID_TIMECODE_STRING,
Expand All @@ -16,32 +18,38 @@ struct ErrorStatus {
INVALID_RATE_FOR_DROP_FRAME_TIMECODE,
};

ErrorStatus() : outcome {OK} {}

ErrorStatus(Outcome in_outcome) :
outcome {in_outcome},
details {outcome_to_string(in_outcome)} {}
ErrorStatus()
: outcome{ OK }
{}

ErrorStatus(Outcome in_outcome)
: outcome{ in_outcome }
, details{ outcome_to_string(in_outcome) }
{}

ErrorStatus(Outcome in_outcome, std::string const& in_details)
: outcome {in_outcome},
details {in_details} {}

Outcome outcome;
: outcome{ in_outcome }
, details{ in_details }
{}

Outcome outcome;
std::string details;

static std::string outcome_to_string(Outcome);
};

// Check whether the given ErrorStatus is an error.
constexpr bool is_error(const ErrorStatus& es) noexcept
constexpr bool
is_error(const ErrorStatus& es) noexcept
{
return ErrorStatus::Outcome::OK != es.outcome;
}

// Check whether the given ErrorStatus is non-null and an error.
constexpr bool is_error(const ErrorStatus* es) noexcept
constexpr bool
is_error(const ErrorStatus* es) noexcept
{
return es && ErrorStatus::Outcome::OK != es->outcome;
}

} }
}} // namespace opentime::OPENTIME_VERSION
Loading

0 comments on commit 0aa7765

Please sign in to comment.