From 079adea8ee84ecfa8efe01b4d6e21781c1446c4e Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Sun, 11 Feb 2018 14:08:05 -0800 Subject: [PATCH] NTString -> nt_string --- src/clang_cursor.cc | 2 +- src/clang_cursor.h | 4 ++-- src/indexer.h | 14 +++++++------- src/{ntstring.h => nt_string.h} | 14 +++++++------- src/serializer.cc | 4 ++-- src/serializer.h | 6 +++--- 6 files changed, 22 insertions(+), 22 deletions(-) rename src/{ntstring.h => nt_string.h} (78%) diff --git a/src/clang_cursor.cc b/src/clang_cursor.cc index 7435649b..84dcfeed 100644 --- a/src/clang_cursor.cc +++ b/src/clang_cursor.cc @@ -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); diff --git a/src/clang_cursor.h b/src/clang_cursor.h index ce63ea0b..09bd7c66 100644 --- a/src/clang_cursor.h +++ b/src/clang_cursor.h @@ -1,7 +1,7 @@ #pragma once #include "position.h" -#include "ntstring.h" +#include "nt_string.h" #include #include @@ -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; diff --git a/src/indexer.h b/src/indexer.h index 25757a45..7e6b189d 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -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 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 struct FuncDefDefinitionData { // General metadata. std::string detailed_name; - NTString hover; - NTString comments; + NtString hover; + NtString comments; Maybe spell; Maybe extent; @@ -368,8 +368,8 @@ template 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 spell; diff --git a/src/ntstring.h b/src/nt_string.h similarity index 78% rename from src/ntstring.h rename to src/nt_string.h index cb7aba58..1f3d8e7b 100644 --- a/src/ntstring.h +++ b/src/nt_string.h @@ -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 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(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(); } diff --git a/src/serializer.cc b/src/serializer.cc index c52bfdf8..6ea6e3e3 100644 --- a/src/serializer.cc +++ b/src/serializer.cc @@ -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 : ""); } diff --git a/src/serializer.h b/src/serializer.h index 7c494b5a..89c3626d 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -1,7 +1,7 @@ #pragma once #include "maybe.h" -#include "ntstring.h" +#include "nt_string.h" #include "port.h" #include @@ -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&);