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