Skip to content

Commit

Permalink
Merge branch 'bloomberg:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger authored Jan 26, 2022
2 parents 7615252 + 3bf629c commit fa46c05
Show file tree
Hide file tree
Showing 918 changed files with 204,667 additions and 73,346 deletions.
1 change: 1 addition & 0 deletions .arclint
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"debug-mode" : false,
"options" : [
"-nodefinc",
"-std=c++17",
"-cl='set ident_header bsls_ident'"
],
"header-paths" : [
Expand Down
1 change: 1 addition & 0 deletions .bde-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BasedOnStyle: BDE
694 changes: 691 additions & 3 deletions debian/changelog

Large diffs are not rendered by default.

45 changes: 36 additions & 9 deletions debian/cmakedpkgconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
"libpcre2-dev": [ "pcre2", "pcre2-symlinks",
"pcre2-headers", "pcre2-meta",
"pcre2-release-symlink",
"pcre2-pkgconfig" ]
"pcre2-pkgconfig" ],
"libryu-dev": [ "ryu", "ryu-symlinks",
"ryu-headers", "ryu-meta",
"ryu-release-symlink",
"ryu-pkgconfig" ]
}
},
{
Expand All @@ -51,7 +55,11 @@
"libpcre2-dev": [ "pcre2", "pcre2-symlinks",
"pcre2-release-symlink",
"pcre2-pkgconfig",
"pcre2-pic-symlink-hack" ]
"pcre2-pic-symlink-hack" ],
"libryu-dev": [ "ryu", "ryu-symlinks",
"ryu-release-symlink",
"ryu-pkgconfig",
"ryu-pic-symlink-hack" ]
}
},
{
Expand Down Expand Up @@ -87,7 +95,8 @@
"libbdl-dev-extra": [ "bdl", "bdl-symlinks" ],
"libbsl-dev-extra": [ "bsl", "bsl-symlinks" ],
"libinteldfp-dev-extra": [ "inteldfp", "inteldfp-symlinks" ],
"libpcre2-dev-extra": [ "pcre2", "pcre2-symlinks" ]
"libpcre2-dev-extra": [ "pcre2", "pcre2-symlinks" ],
"libryu-dev-extra": [ "ryu", "ryu-symlinks" ]
}
},
{
Expand Down Expand Up @@ -129,7 +138,11 @@
"libpcre2-dev": [ "pcre2", "pcre2-symlinks",
"pcre2-headers", "pcre2-meta",
"pcre2-release-symlink",
"pcre2-pkgconfig" ]
"pcre2-pkgconfig" ],
"libryu-dev": [ "ryu", "ryu-symlinks",
"ryu-headers", "ryu-meta",
"ryu-release-symlink",
"ryu-pkgconfig" ]
}
},
{
Expand All @@ -155,7 +168,11 @@
"libpcre2-dev": [ "pcre2", "pcre2-symlinks",
"pcre2-release-symlink",
"pcre2-pkgconfig",
"pcre2-pic-symlink-hack" ]
"pcre2-pic-symlink-hack" ],
"libryu-dev": [ "ryu", "ryu-symlinks",
"ryu-release-symlink",
"ryu-pkgconfig",
"ryu-pic-symlink-hack" ]
}
},
{
Expand Down Expand Up @@ -191,7 +208,8 @@
"libbdl-dev-extra": [ "bdl", "bdl-symlinks" ],
"libbsl-dev-extra": [ "bsl", "bsl-symlinks" ],
"libinteldfp-dev-extra": [ "inteldfp", "inteldfp-symlinks" ],
"libpcre2-dev-extra": [ "pcre2", "pcre2-symlinks" ]
"libpcre2-dev-extra": [ "pcre2", "pcre2-symlinks" ],
"libryu-dev-extra": [ "ryu", "ryu-symlinks" ]
}
},
{
Expand Down Expand Up @@ -233,7 +251,11 @@
"libpcre2-dev": [ "pcre2", "pcre2-symlinks",
"pcre2-headers", "pcre2-meta",
"pcre2-release-symlink",
"pcre2-pkgconfig" ]
"pcre2-pkgconfig" ],
"libryu-dev": [ "ryu", "ryu-symlinks",
"ryu-headers", "ryu-meta",
"ryu-release-symlink",
"ryu-pkgconfig" ]
}
},
{
Expand All @@ -259,7 +281,11 @@
"libpcre2-dev": [ "pcre2", "pcre2-symlinks",
"pcre2-release-symlink",
"pcre2-pkgconfig",
"pcre2-pic-symlink-hack" ]
"pcre2-pic-symlink-hack" ],
"libryu-dev": [ "ryu", "ryu-symlinks",
"ryu-release-symlink",
"ryu-pkgconfig",
"ryu-pic-symlink-hack" ]
}
},
{
Expand Down Expand Up @@ -295,7 +321,8 @@
"libbdl-dev-extra": [ "bdl", "bdl-symlinks" ],
"libbsl-dev-extra": [ "bsl", "bsl-symlinks" ],
"libinteldfp-dev-extra": [ "inteldfp", "inteldfp-symlinks" ],
"libpcre2-dev-extra": [ "pcre2", "pcre2-symlinks" ]
"libpcre2-dev-extra": [ "pcre2", "pcre2-symlinks" ],
"libryu-dev-extra": [ "ryu", "ryu-symlinks" ]
}
},
{
Expand Down
21 changes: 17 additions & 4 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Description: BDL
groups/bdl extra libraries

Package: libbsl-dev-extra
Depends: libbsl-dev
Depends: libbsl-dev, libryu-dev-extra
Architecture: any
Conflicts: libbsl-dev (<< 3.41.0.0), libbsl-extra-dev
Replaces: libbsl-extra-dev
Description: BSL
Description: BSL
groups/bsl extra libraries


Expand All @@ -65,16 +65,17 @@ Description: BDL
groups/bdl development files

Package: libbsl-dev
Depends: libryu-dev
Architecture: any
Description: BSL
Description: BSL
groups/bsl development files



Package: libinteldfp-dev-extra
Depends: libinteldfp-dev
Architecture: any
Description: Intel Decimal Floating-Point Math Library
Description: Intel Decimal Floating-Point Math Library
thirdparty/inteldfp extra libraries

Package: libinteldfp-dev
Expand All @@ -92,3 +93,15 @@ Description: PCRE 2 Regular Expression Library
Package: libpcre2-dev
Architecture: any
Description: PCRE 2 Regular Expression Library



Package: libryu-dev-extra
Depends: libryu-dev
Architecture: any
Description: Bloomberg LP Extended Ryu Float Formatting Library
thirdparty/ryu extra libraries

Package: libryu-dev
Architecture: any
Description: Bloomberg LP Extended Ryu Float Formatting Library
1 change: 1 addition & 0 deletions debian/libryu-dev-extra.lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libryu-dev-extra: blp-bde-metadata-missing
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include $(DEBHELPER_PATH)/bde-debhelper.cmake2.mk

debian/bde-build-stamp: debian/lintian-overrides-stamp
debian/lintian-overrides-stamp:
for uor in bal bbl bdl bsl inteldfp pcre2; do \
for uor in bal bbl bdl bsl inteldfp pcre2 ryu; do \
mkdir -p debian/lib$${uor}-dev-extra$(PREFIX)/share/lintian/overrides; \
cp debian/lib$${uor}-dev-extra.lintian-overrides \
debian/lib$${uor}-dev-extra$(PREFIX)/share/lintian/overrides/lib$${uor}-dev-extra; \
Expand Down
80 changes: 43 additions & 37 deletions groups/bal/balb/balb_controlmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
#include <bslmt_readlockguard.h>
#include <bslmt_writelockguard.h>

#include <bdlsb_fixedmeminstreambuf.h>

#include <bdlb_string.h>
#include <bdlb_stringviewutil.h>

#include <bslma_default.h>
#include <bsls_assert.h>
Expand All @@ -26,32 +29,20 @@
#include <bsl_utility.h>

namespace BloombergLP {
namespace balb {

namespace {

template <class FIRST, class SECOND>
struct MapKeyExtractor {
const FIRST& operator() (const bsl::pair<FIRST, SECOND>& pair) {
return pair.first;
}
};

template <class FIRST, class SECOND, class TC, class TA>
MapKeyExtractor<FIRST, SECOND>
GetExtractor(const bsl::map<FIRST, SECOND, TC, TA>&) {
return MapKeyExtractor<FIRST, SECOND>();
}
// --------------------------------------
// class ControlManager::CaselessLessThan
// --------------------------------------

inline
bool isLessThanCaseless(const bsl::string& lhsString,
const bsl::string& rhsString)
bool ControlManager::CaselessLessThan::operator()(
const bsl::string_view& lhs,
const bsl::string_view& rhs) const
{
return -1 == bdlb::String::lowerCaseCmp(lhsString, rhsString);
return bdlb::StringViewUtil::lowerCaseCmp(lhs, rhs) < 0;
}

} // close unnamed namespace

namespace balb {
// --------------------
// class ControlManager
// --------------------
Expand All @@ -60,50 +51,62 @@ namespace balb {

ControlManager::ControlManager(bslma::Allocator *basicAllocator)
: d_allocator_p(bslma::Default::allocator(basicAllocator))
, d_registry(&isLessThanCaseless, basicAllocator)
, d_registry(basicAllocator)
{ }

ControlManager::~ControlManager()
{ }

// MANIPULATORS

int ControlManager::registerHandler(const bsl::string& prefix,
const bsl::string& arguments,
const bsl::string& description,
const ControlHandler& handler)
int ControlManager::registerHandler(const bsl::string_view& prefix,
const bsl::string_view& arguments,
const bsl::string_view& description,
const ControlHandler& handler)
{
typedef Registry::iterator Iterator;

bslmt::WriteLockGuard<bslmt::RWMutex> guard(&d_registryMutex);

int rc = 0;
ControlManager_Entry entry(handler, arguments, description);

Registry::iterator it = d_registry.find(prefix);
Iterator it = d_registry.find(prefix);
if (it != d_registry.end()) {
it->second = entry;
rc = 1;
}
else {
d_registry.insert(bsl::make_pair(prefix, entry));
bsl::pair<Iterator, bool> rcPair = d_registry.emplace(prefix, entry);
BSLS_ASSERT(rcPair.second); (void) rcPair;
}

return rc;
}

int ControlManager::deregisterHandler(const bsl::string& prefix)
int ControlManager::deregisterHandler(const bsl::string_view& prefix)
{
bslmt::WriteLockGuard<bslmt::RWMutex> guard(&d_registryMutex);

return (0 == d_registry.erase(prefix));
Registry::iterator it = d_registry.find(prefix);
if (d_registry.end() != it) {
d_registry.erase(it);

return 0; // RETURN
}

return 1;
}

int ControlManager::dispatchMessage(const bsl::string& message) const
int ControlManager::dispatchMessage(const bsl::string_view& message) const
{
BSLS_LOG_TRACE("Dispatching control message '%s'", message.c_str());
const int len = static_cast<int>(message.length());
BSLS_LOG_TRACE("Dispatching control message '%.*s'", len, message.data());

bsl::string token;
bsl::istringstream messageStream(message);
bdlsb::FixedMemInStreamBuf isb(message.data(), message.length());
bsl::istream messageStream(&isb);

bsl::string token;
messageStream >> token;

bslmt::ReadLockGuard<bslmt::RWMutex> registryGuard(&d_registryMutex);
Expand All @@ -122,6 +125,9 @@ int ControlManager::dispatchMessage(const bsl::string& message) const
int ControlManager::dispatchMessage(const bsl::string& prefix,
bsl::istream& stream) const
{
// Imp note: 'prefix' has to be 'bsl::string' and not a string view for the
// sake of being able to be passed to the callback.

BSLS_LOG_TRACE("Dispatching control message '%s'", prefix.c_str());

bslmt::ReadLockGuard<bslmt::RWMutex> registryGuard(&d_registryMutex);
Expand All @@ -137,8 +143,8 @@ int ControlManager::dispatchMessage(const bsl::string& prefix,
return -1;
}

void ControlManager::printUsage(bsl::ostream& stream,
const bsl::string& preamble) const
void ControlManager::printUsage(bsl::ostream& stream,
const bsl::string_view& preamble) const
{
stream << preamble << bsl::endl;
d_registryMutex.lockRead();
Expand Down Expand Up @@ -174,8 +180,8 @@ ControlManager::ControlManager_Entry::~ControlManager_Entry()

ControlManager::ControlManager_Entry::ControlManager_Entry(
const ControlManager::ControlHandler& callback,
const bsl::string& arguments,
const bsl::string& description,
const bsl::string_view& arguments,
const bsl::string_view& description,
bslma::Allocator *basicAllocator)
: d_callback(bsl::allocator_arg_t(),
bsl::allocator<ControlManager::ControlHandler>(basicAllocator),
Expand Down
Loading

0 comments on commit fa46c05

Please sign in to comment.