Use llvm::Twine instead of llvm::StringRef in several places. (#58)

This commit is contained in:
Peter Johnson
2017-11-22 21:47:56 -08:00
committed by GitHub
parent f73db4a49b
commit 912b74151f
4 changed files with 22 additions and 15 deletions

View File

@@ -16,6 +16,7 @@
#include "llvm/SmallVector.h"
#include "llvm/StringMap.h"
#include "llvm/StringRef.h"
#include "llvm/Twine.h"
#include "support/raw_istream.h"
#include "support/raw_socket_istream.h"
#include "support/raw_socket_ostream.h"
@@ -27,14 +28,15 @@ namespace wpi {
// @param buf Buffer for output
// @param error Set to true if an error occurred
// @return Escaped string
llvm::StringRef UnescapeURI(llvm::StringRef str,
llvm::StringRef UnescapeURI(const llvm::Twine& str,
llvm::SmallVectorImpl<char>& buf, bool* error);
// Escape a string with %xx-encoding.
// @param buf Buffer for output
// @param spacePlus If true, encodes spaces to '+' rather than "%20"
// @return Escaped string
llvm::StringRef EscapeURI(llvm::StringRef str, llvm::SmallVectorImpl<char>& buf,
llvm::StringRef EscapeURI(const llvm::Twine& str,
llvm::SmallVectorImpl<char>& buf,
bool spacePlus = true);
// Parse a set of HTTP headers. Saves just the Content-Type and Content-Length
@@ -60,7 +62,7 @@ bool FindMultipartBoundary(wpi::raw_istream& is, llvm::StringRef boundary,
class HttpLocation {
public:
HttpLocation() = default;
HttpLocation(llvm::StringRef url_, bool* error, std::string* errorMsg);
HttpLocation(const llvm::Twine& url_, bool* error, std::string* errorMsg);
std::string url; // retain copy
std::string user; // unescaped

View File

@@ -16,6 +16,7 @@ namespace llvm {
template <typename T>
class SmallVectorImpl;
class StringRef;
class Twine;
}
namespace wpi {
@@ -94,7 +95,7 @@ class raw_mem_istream : public raw_istream {
class raw_fd_istream : public raw_istream {
public:
raw_fd_istream(llvm::StringRef filename, std::error_code& ec,
raw_fd_istream(const llvm::Twine& filename, std::error_code& ec,
std::size_t bufSize = 4096);
raw_fd_istream(int fd, bool shouldClose, std::size_t bufSize = 4096);
~raw_fd_istream() override;