[NFC][Py Reformat] Added more commits to .git-blame-ignore-revs
[llvm-project.git] / libc / src / __support / c_string.h
blobeaac4e7ad61d42f490be4d02127a573dcd54d6f4
1 //===-- Implementation of a struct to hold a string in menory -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC_SUPPORT_C_STRING_H
10 #define LLVM_LIBC_SRC_SUPPORT_C_STRING_H
12 #include "src/__support/CPP/string.h"
13 #include "src/__support/macros/attributes.h" // for LIBC_INLINE
15 namespace __llvm_libc {
17 // The CString class is a companion to the cpp::string class. Its use case is as
18 // a return value for a function that in C would return a char* and a flag for
19 // if that char* needs to be freed.
20 class CString {
21 cpp::string str;
23 public:
24 // These constructors can be implemented iff required.
25 CString() = delete;
26 CString(const CString &) = delete;
27 CString(CString &&) = delete;
29 LIBC_INLINE CString(cpp::string in_str) : str(in_str) {}
31 LIBC_INLINE operator const char *() const { return str.c_str(); }
34 } // namespace __llvm_libc
36 #endif // LLVM_LIBC_SRC_SUPPORT_C_STRING_H