Debian Codegraph @

CodeLite/clStringView.hpp

raw
1 #ifndef CLSTRINGVIEW_HPP
2 #define CLSTRINGVIEW_HPP
3
4 #include <codelite_exports.h>
5 #include <wx/string.h>
6
7 class WXDLLIMPEXP_CL clStringView
8 {
9 const wxChar* m_pdata = nullptr;
10 size_t m_length = 0;
11
12 private:
13 // No copy
14 clStringView& operator=(const clStringView& other);
15 clStringView(const clStringView& other);
16
17 public:
18 ~clStringView();
19 clStringView();
20 clStringView(const wxString& buffer)
21 : clStringView(buffer.c_str(), buffer.length())
22 {
23 }
24 clStringView(const wxChar* p, size_t len);
25
26 /**
27 * @brief construct a string object from this view
28 */
29 wxString MakeString() const;
30
31 const wxChar* data() const { return m_pdata; }
32 size_t length() const { return m_length; }
33 wxChar operator[](size_t index) const { return m_pdata[index]; }
34 bool empty() const { return m_length == 0; }
35 /**
36 * @brief try to shift the buffer to the right by `count` chars
37 * @return true if the buffer length >= count, false otherwise
38 */
39 bool Advance(size_t count);
40 /**
41 * @brief find `what`. return the index or wxNOT_FOUND if no match is found
42 */
43 int Find(const wxString& what) const;
44
45 /**
46 * @brief reset the view with a new content
47 */
48 void Reset(const wxString& buffer);
49 };
50
51 #endif // CLSTRINGVIEW_HPP