Skip to content

Commit

Permalink
BufferWriter: remove C string write overloads, use const void MemSpan.
Browse files Browse the repository at this point in the history
  • Loading branch information
SolidWallOfCode committed Jul 25, 2023
1 parent 734be78 commit 23eb3fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
18 changes: 0 additions & 18 deletions code/include/swoc/BufferWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,6 @@ class BufferWriter {
*/
virtual BufferWriter &write(void const *data, size_t length);

/** Write C-string.
*
* @param s String pointer.
* @return @a this
*
* @a s is presumed to ba nul terminated.
*/
BufferWriter & write(char const *s) { return this->write(s, strlen(s)); }

/** Write C-string.
*
* @param s String pointer.
* @return @a this
*
* @a s is presumed to ba nul terminated.
*/
BufferWriter & write(char *s) { return this->write(s, strlen(s)); }

/** Write data to the buffer.
*
* @param span Data source.
Expand Down
4 changes: 2 additions & 2 deletions code/include/swoc/TextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,8 @@ class TextView : public std::string_view {
* @param count Number of bytes in the view.
* @return The view starting at @a pos for @a count bytes.
*
* The returned view is clipped by @a this. @a count is reduced such that it covers only data
* in @a this.
* The returned view is clipped by @a this - that is, it will not extend beyond the original view.
* @a count is reduced such that it covers only data in @a this.
*
* @note This is provided primarily for co-variance, i.e. the returned view is a @c TextView
* instead of a @c std::string_view.
Expand Down
15 changes: 12 additions & 3 deletions code/include/swoc/bwf_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,12 @@ template <typename F> class NameMap {
*/
self_type &assign(std::string_view const &name, Generator const &generator);

bool contains(std::string_view name) {
return _map.end() != _map.find(name);
}
/** Check if a specific name is contained in this mapping.
*
* @param name Name to check.
* @return @c true if present, @c false if not.
*/
bool contains(std::string_view name);

protected:
/// Copy @a name in to local storage and return a view of it.
Expand Down Expand Up @@ -558,6 +561,12 @@ template <typename F> NameMap<F>::NameMap(std::initializer_list<std::tuple<std::
}
}

template <typename F>
bool
NameMap<F>::contains(std::string_view name) {
return _map.end() != _map.find(name);
}

template <typename F>
std::string_view
NameMap<F>::localize(std::string_view const &name) {
Expand Down

0 comments on commit 23eb3fc

Please sign in to comment.