1 //===- llvm/ADT/SmallString.h - 'Normally small' strings --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the SmallString class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ADT_SMALLSTRING_H
15 #define LLVM_ADT_SMALLSTRING_H
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/DataTypes.h"
24 /// SmallString - A SmallString is just a SmallVector with methods and accessors
25 /// that make it work better as a string (e.g. operator+ etc).
26 template<unsigned InternalLen>
27 class SmallString : public SmallVector<char, InternalLen> {
29 // Default ctor - Initialize to empty.
32 // Initialize with a range.
33 template<typename ItTy>
34 SmallString(ItTy S, ItTy E) : SmallVector<char, InternalLen>(S, E) {}
37 SmallString(const SmallString &RHS) : SmallVector<char, InternalLen>(RHS) {}
41 StringRef str() const { return StringRef(this->begin(), this->size()); }
44 const SmallString &operator=(const char *RHS) {
49 SmallString &operator+=(const char *RHS) {
50 this->append(RHS, RHS+strlen(RHS));
53 SmallString &operator+=(char C) {