--- parser3/src/include/pa_string.h 2016/10/26 16:40:49 1.220 +++ parser3/src/include/pa_string.h 2017/12/05 22:59:58 1.224 @@ -1,14 +1,14 @@ /** @file Parser: string class decl. - Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_STRING_H #define PA_STRING_H -#define IDENT_PA_STRING_H "$Id: pa_string.h,v 1.220 2016/10/26 16:40:49 moko Exp $" +#define IDENT_PA_STRING_H "$Id: pa_string.h,v 1.224 2017/12/05 22:59:58 moko Exp $" // includes #include "pa_types.h" @@ -16,7 +16,7 @@ extern "C" { // cord's author forgot to do that #define CORD_NO_IO -#include "cord.h" +#include "../lib/cord/include/cord.h" #ifdef CORD_CAT_OPTIMIZATION #define CORD_cat(x, y) CORD_cat_optimized(x, y) @@ -171,7 +171,7 @@ public: public: - const char* v() const; + const char* visualize() const; void dump() const; Languages(): langs(0) {} @@ -312,6 +312,7 @@ public: size_t length; C(): str(0), length(0) {} C(const char *astr, size_t asize): str(astr), length(asize) {} + explicit C(Body abody): str(abody.cstr()), length(abody.length()) {} }; struct Cm { @@ -319,6 +320,7 @@ public: size_t length; Cm(): str(0), length(0) {} Cm(char *astr, size_t asize): str(astr), length(asize) {} + explicit Cm(Body abody): str(abody.cstrm()), length(abody.length()) {} }; class Body { @@ -348,7 +350,6 @@ public: public: - const char* v() const; void dump() const; Body(): body(CORD_EMPTY) INIT_HASH_CODE(0) INIT_LENGTH(0) {} @@ -384,6 +385,7 @@ public: inline CORD get_cord() const { return body; } uint get_hash_code() const; + // never null const char* cstr() const { #ifdef STRING_LENGTH_CACHING string_length = length(); @@ -396,6 +398,7 @@ public: return CORD_to_const_char_star(body, length()); } + // never null char* cstrm() const { return CORD_to_char_star(body, length()); } #ifdef STRING_LENGTH_CACHING @@ -487,7 +490,6 @@ private: Body body; ///< all characters of string Languages langs; ///< string characters lang - const char* v() const; void dump() const; #define ASSERT_STRING_INVARIANT(string) \ assert((string).langs.invariant((string).body.length())) @@ -561,6 +563,8 @@ public: return langs.opt.lang; } + char* visualize_langs() const; + /// puts pieces to buf Cm serialize(size_t prolog_size) const; /// appends pieces from buf to self