mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 11:01:57 +00:00
NTString -> nt_string
This commit is contained in:
parent
593ecd8f53
commit
079adea8ee
@ -228,7 +228,7 @@ std::string ClangCursor::get_type_description() const {
|
||||
return ::ToString(clang_getTypeSpelling(type));
|
||||
}
|
||||
|
||||
NTString ClangCursor::get_comments() const {
|
||||
NtString ClangCursor::get_comments() const {
|
||||
if (!g_index_comments)
|
||||
return {};
|
||||
CXSourceRange range = clang_Cursor_getCommentRange(cx_cursor);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "position.h"
|
||||
#include "ntstring.h"
|
||||
#include "nt_string.h"
|
||||
|
||||
#include <clang-c/Index.h>
|
||||
#include <optional.h>
|
||||
@ -80,7 +80,7 @@ class ClangCursor {
|
||||
bool is_valid_kind() const;
|
||||
|
||||
std::string get_type_description() const;
|
||||
NTString get_comments() const;
|
||||
NtString get_comments() const;
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "file_contents.h"
|
||||
#include "language_server_api.h"
|
||||
#include "maybe.h"
|
||||
#include "ntstring.h"
|
||||
#include "nt_string.h"
|
||||
#include "performance.h"
|
||||
#include "position.h"
|
||||
#include "serializer.h"
|
||||
@ -160,8 +160,8 @@ template <typename F>
|
||||
struct TypeDefDefinitionData {
|
||||
// General metadata.
|
||||
std::string detailed_name;
|
||||
NTString hover;
|
||||
NTString comments;
|
||||
NtString hover;
|
||||
NtString comments;
|
||||
|
||||
// While a class/type can technically have a separate declaration/definition,
|
||||
// it doesn't really happen in practice. The declaration never contains
|
||||
@ -258,8 +258,8 @@ template <typename F>
|
||||
struct FuncDefDefinitionData {
|
||||
// General metadata.
|
||||
std::string detailed_name;
|
||||
NTString hover;
|
||||
NTString comments;
|
||||
NtString hover;
|
||||
NtString comments;
|
||||
Maybe<Use> spell;
|
||||
Maybe<Use> extent;
|
||||
|
||||
@ -368,8 +368,8 @@ template <typename F>
|
||||
struct VarDefDefinitionData {
|
||||
// General metadata.
|
||||
std::string detailed_name;
|
||||
NTString hover;
|
||||
NTString comments;
|
||||
NtString hover;
|
||||
NtString comments;
|
||||
// TODO: definitions should be a list of ranges, since there can be more
|
||||
// than one - when??
|
||||
Maybe<Use> spell;
|
||||
|
@ -12,15 +12,15 @@ class Writer;
|
||||
// Nullable null-terminated string, which is null if default constructed,
|
||||
// but non-null if assigned.
|
||||
// This is used in Query{Func,Type,Var}::def to reduce memory footprint.
|
||||
class NTString {
|
||||
class NtString {
|
||||
using size_type = std::string::size_type;
|
||||
std::unique_ptr<char[]> str;
|
||||
|
||||
public:
|
||||
NTString() = default;
|
||||
NTString(NTString&& o) = default;
|
||||
NTString(const NTString& o) { *this = o; }
|
||||
NTString(std::string_view sv) { *this = sv; }
|
||||
NtString() = default;
|
||||
NtString(NtString&& o) = default;
|
||||
NtString(const NtString& o) { *this = o; }
|
||||
NtString(std::string_view sv) { *this = sv; }
|
||||
|
||||
const char* c_str() const { return str.get(); }
|
||||
operator std::string_view() const {
|
||||
@ -35,10 +35,10 @@ class NTString {
|
||||
memcpy(str.get(), sv.data(), sv.size());
|
||||
str.get()[sv.size()] = '\0';
|
||||
}
|
||||
void operator=(const NTString& o) {
|
||||
void operator=(const NtString& o) {
|
||||
*this = static_cast<std::string_view>(o);
|
||||
}
|
||||
bool operator==(const NTString& o) const {
|
||||
bool operator==(const NtString& o) const {
|
||||
return str && o.str ? strcmp(c_str(), o.c_str()) == 0
|
||||
: c_str() == o.c_str();
|
||||
}
|
@ -125,12 +125,12 @@ void Reflect(Writer& visitor, std::string_view& data) {
|
||||
visitor.String(&data[0], (rapidjson::SizeType)data.size());
|
||||
}
|
||||
|
||||
void Reflect(Reader& visitor, NTString& value) {
|
||||
void Reflect(Reader& visitor, NtString& value) {
|
||||
if (!visitor.IsString())
|
||||
throw std::invalid_argument("std::string");
|
||||
value = visitor.GetString();
|
||||
}
|
||||
void Reflect(Writer& visitor, NTString& value) {
|
||||
void Reflect(Writer& visitor, NtString& value) {
|
||||
const char* s = value.c_str();
|
||||
visitor.String(s ? s : "");
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "maybe.h"
|
||||
#include "ntstring.h"
|
||||
#include "nt_string.h"
|
||||
#include "port.h"
|
||||
|
||||
#include <macro_map.h>
|
||||
@ -161,8 +161,8 @@ void Reflect(Writer& visitor, std::string& value);
|
||||
void Reflect(Reader& visitor, std::string_view& view);
|
||||
void Reflect(Writer& visitor, std::string_view& view);
|
||||
|
||||
void Reflect(Reader& visitor, NTString& value);
|
||||
void Reflect(Writer& visitor, NTString& value);
|
||||
void Reflect(Reader& visitor, NtString& value);
|
||||
void Reflect(Writer& visitor, NtString& value);
|
||||
|
||||
// std::monostate is used to represent JSON null
|
||||
void Reflect(Reader& visitor, std::monostate&);
|
||||
|
Loading…
Reference in New Issue
Block a user