1
0
Fork 0

added StringRef implementation file to implement operator<<

This commit is contained in:
jsteemann 2016-10-28 16:03:53 +02:00
parent 893a7ab2b4
commit 0f06a219b6
3 changed files with 38 additions and 0 deletions

32
lib/Basics/StringRef.cpp Normal file
View File

@ -0,0 +1,32 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include "StringRef.h"
#include <iostream>
std::ostream& operator<<(std::ostream& stream, arangodb::StringRef const& ref) {
stream << std::string(ref.data(), ref.length());
return stream;
}

View File

@ -30,6 +30,8 @@
#include <velocypack/Slice.h>
#include <velocypack/Value.h>
#include <iosfwd>
namespace arangodb {
/// @brief a struct describing a C character array
@ -174,6 +176,8 @@ class StringRef {
}
std::ostream& operator<<(std::ostream&, arangodb::StringRef const&);
inline bool operator==(arangodb::StringRef const& lhs, arangodb::StringRef const& rhs) {
return (lhs.size() == rhs.size() && memcmp(lhs.data(), rhs.data(), lhs.size()) == 0);
}
@ -227,4 +231,5 @@ struct equal_to<arangodb::StringRef> {
}
#endif

View File

@ -140,6 +140,7 @@ add_library(${LIB_ARANGO} STATIC
Basics/StaticStrings.cpp
Basics/StringBuffer.cpp
Basics/StringHeap.cpp
Basics/StringRef.cpp
Basics/StringUtils.cpp
Basics/Thread.cpp
Basics/ThreadPool.cpp