Fixes #340: namespace indentation unification (#350)

* Namespace no longer induce indentation
* Namespace opening brace now on same line as namespace name
* Namespace closing brace now has an empty line before it unless the namespace contents were short and with no empty lines
* Namespace closing brace now always followed by a comment with the closed namespace' name
This commit is contained in:
Eyal Rozenberg 2022-07-11 00:00:50 +03:00 committed by GitHub
parent 8d18c3ed0b
commit 513afbc6dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,8 +79,7 @@ THE SOFTWARE.
#define CXXOPTS_NULL_DEREF_IGNORE #define CXXOPTS_NULL_DEREF_IGNORE
#endif #endif
namespace cxxopts namespace cxxopts {
{
static constexpr struct { static constexpr struct {
uint8_t major, minor, patch; uint8_t major, minor, patch;
} version = { } version = {
@ -99,8 +98,7 @@ namespace cxxopts
#ifdef CXXOPTS_USE_UNICODE #ifdef CXXOPTS_USE_UNICODE
#include <unicode/unistr.h> #include <unicode/unistr.h>
namespace cxxopts namespace cxxopts {
{
using String = icu::UnicodeString; using String = icu::UnicodeString;
inline inline
@ -223,10 +221,10 @@ namespace cxxopts
{ {
return s.isEmpty(); return s.isEmpty();
} }
}
namespace std } // namespace cxxopts
{
namespace std {
inline inline
cxxopts::UnicodeStringIterator cxxopts::UnicodeStringIterator
begin(const icu::UnicodeString& s) begin(const icu::UnicodeString& s)
@ -240,13 +238,13 @@ namespace std
{ {
return cxxopts::UnicodeStringIterator(&s, s.length()); return cxxopts::UnicodeStringIterator(&s, s.length());
} }
}
} // namespace std
//ifdef CXXOPTS_USE_UNICODE //ifdef CXXOPTS_USE_UNICODE
#else #else
namespace cxxopts namespace cxxopts {
{
using String = std::string; using String = std::string;
template <typename T> template <typename T>
@ -297,15 +295,14 @@ namespace cxxopts
{ {
return s.empty(); return s.empty();
} }
} // namespace cxxopts } // namespace cxxopts
//ifdef CXXOPTS_USE_UNICODE //ifdef CXXOPTS_USE_UNICODE
#endif #endif
namespace cxxopts namespace cxxopts {
{ namespace {
namespace
{
#ifdef _WIN32 #ifdef _WIN32
const std::string LQUOTE("\'"); const std::string LQUOTE("\'");
const std::string RQUOTE("\'"); const std::string RQUOTE("\'");
@ -547,10 +544,8 @@ namespace cxxopts
#endif #endif
} }
namespace values namespace values {
{ namespace parser_tool {
namespace parser_tool
{
struct IntegerDesc struct IntegerDesc
{ {
std::string negative = ""; std::string negative = "";
@ -705,8 +700,7 @@ namespace cxxopts
#else // CXXOPTS_NO_REGEX #else // CXXOPTS_NO_REGEX
namespace namespace {
{
std::basic_regex<char> integer_pattern std::basic_regex<char> integer_pattern
("(-)?(0x)?([0-9a-zA-Z]+)|((0x)?0)"); ("(-)?(0x)?([0-9a-zA-Z]+)|((0x)?0)");
@ -745,6 +739,7 @@ namespace cxxopts
} }
return desc; return desc;
} }
inline bool IsTrueText(const std::string &text) inline bool IsTrueText(const std::string &text)
@ -799,10 +794,9 @@ namespace cxxopts
#endif // CXXOPTS_NO_REGEX #endif // CXXOPTS_NO_REGEX
#undef CXXOPTS_NO_REGEX #undef CXXOPTS_NO_REGEX
} } // namespace parser_tool
namespace detail namespace detail {
{
template <typename T, bool B> template <typename T, bool B>
struct SignedCheck; struct SignedCheck;
@ -844,6 +838,7 @@ namespace cxxopts
{ {
SignedCheck<T, std::numeric_limits<T>::is_signed>()(negative, value, text); SignedCheck<T, std::numeric_limits<T>::is_signed>()(negative, value, text);
} }
} // namespace detail } // namespace detail
template <typename R, typename T> template <typename R, typename T>
@ -1900,8 +1895,7 @@ namespace cxxopts
std::string m_group; std::string m_group;
}; };
namespace namespace {
{
constexpr size_t OPTION_LONGEST = 30; constexpr size_t OPTION_LONGEST = 30;
constexpr size_t OPTION_DESC_GAP = 2; constexpr size_t OPTION_DESC_GAP = 2;