Debian Codegraph @

CodeLite/clStringView.cpp

raw
1 #include "clStringView.hpp"
2
3 #include <wx/wxcrt.h>
4
5 clStringView::clStringView() {}
6
7 clStringView::~clStringView() {}
8
9 wxString clStringView::MakeString() const
10 {
11 if(!m_pdata) {
12 return wxString();
13 } else {
14 return wxString(m_pdata, m_length);
15 }
16 }
17
18 clStringView::clStringView(const wxChar* p, size_t len)
19 {
20 m_pdata = p;
21 m_length = len;
22 }
23
24 bool clStringView::Advance(size_t count)
25 {
26 // sanity: if the requested count is more than the current length
27 // clear the string
28 if(count > m_length) {
29 return false;
30 }
31
32 m_pdata += count;
33 m_length -= count;
34 return true;
35 }
36
37 int clStringView::Find(const wxString& what) const
38 {
39 if(empty()) {
40 return wxNOT_FOUND;
41 }
42 const wxChar* match = ::wxStrstr(m_pdata, what);
43 if(match == nullptr) {
44 return wxNOT_FOUND;
45 }
46 return match - m_pdata;
47 }
48
49 void clStringView::Reset(const wxString& buffer)
50 {
51 m_pdata = buffer.c_str();
52 m_length = buffer.length();
53 }