Files
swift-mirror/include/swift/Basic/PrimitiveParsing.h
Ben Barham 9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00

49 lines
1.6 KiB
C++

//===--- PrimitiveParsing.h - Primitive parsing routines --------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
///
/// \file
/// Primitive parsing routines useful in various places in the compiler.
///
//===----------------------------------------------------------------------===//
#ifndef SWIFT_BASIC_PRIMITIVEPARSING_H
#define SWIFT_BASIC_PRIMITIVEPARSING_H
#include "llvm/ADT/StringRef.h"
#include "swift/Basic/LLVM.h"
namespace swift {
unsigned measureNewline(const char *BufferPtr, const char *BufferEnd);
static inline unsigned measureNewline(StringRef S) {
return measureNewline(S.data(), S.data() + S.size());
}
static inline bool startsWithNewline(StringRef S) {
return S.starts_with("\n") || S.starts_with("\r\n");
}
/// Breaks a given string to lines and trims leading whitespace from them.
void trimLeadingWhitespaceFromLines(StringRef Text, unsigned WhitespaceToTrim,
SmallVectorImpl<StringRef> &Lines);
static inline void splitIntoLines(StringRef Text,
SmallVectorImpl<StringRef> &Lines) {
trimLeadingWhitespaceFromLines(Text, 0, Lines);
}
} // end namespace swift
#endif // SWIFT_BASIC_PRIMITIVEPARSING_H