Path: blob/main/contrib/llvm-project/libc/src/__support/c_string.h
213766 views
//===-- Implementation of a struct to hold a string in menory -------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_LIBC_SRC___SUPPORT_C_STRING_H9#define LLVM_LIBC_SRC___SUPPORT_C_STRING_H1011#include "src/__support/CPP/string.h"12#include "src/__support/macros/attributes.h" // for LIBC_INLINE13#include "src/__support/macros/config.h"1415namespace LIBC_NAMESPACE_DECL {1617// The CString class is a companion to the cpp::string class. Its use case is as18// a return value for a function that in C would return a char* and a flag for19// if that char* needs to be freed.20class CString {21cpp::string str;2223public:24// These constructors can be implemented iff required.25CString() = delete;26CString(const CString &) = delete;27CString(CString &&) = delete;2829LIBC_INLINE CString(cpp::string in_str) : str(in_str) {}3031LIBC_INLINE operator const char *() const { return str.c_str(); }32};3334} // namespace LIBC_NAMESPACE_DECL3536#endif // LLVM_LIBC_SRC___SUPPORT_C_STRING_H373839