summaryrefslogtreecommitdiff
path: root/src/strings/mstring.cpp
blob: 2a1ca62b35e8f9ec495071811bf0a072492b6ac2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "mstring.hpp"
//    strings/mstring.cpp - Functions for mstring.hpp
//
//    Copyright © 2013 Ben Longbons <b.r.longbons@gmail.com>
//
//    This file is part of The Mana World (Athena server)
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

#include "xstring.hpp"

#include "../poison.hpp"

namespace strings
{
    MString::iterator MString::begin()
    {
        return _hack.begin();
    }
    MString::iterator MString::end()
    {
        return _hack.end();
    }
    MString::const_iterator MString::begin() const
    {
        return _hack.begin();
    }
    MString::const_iterator MString::end() const
    {
        return _hack.end();
    }
    MString::reverse_iterator MString::rbegin()
    {
        return reverse_iterator(end());
    }
    MString::reverse_iterator MString::rend()
    {
        return reverse_iterator(begin());
    }
    MString::const_reverse_iterator MString::rbegin() const
    {
        return const_reverse_iterator(end());
    }
    MString::const_reverse_iterator MString::rend() const
    {
        return const_reverse_iterator(begin());
    }

    size_t MString::size() const
    {
        return _hack.size();
    }
    MString::operator bool() const
    {
        return size();
    }
    bool MString::operator !() const
    {
        return !size();
    }

    MString& MString::operator += (MString rhs)
    {
        _hack.insert(_hack.end(), rhs.begin(), rhs.end());
        return *this;
    }
    MString& MString::operator += (char c)
    {
        _hack.push_back(c);
        return *this;
    }
    MString& MString::operator += (XString x)
    {
        _hack.insert(_hack.end(), x.begin(), x.end());
        return *this;
    }

    void MString::pop_back(size_t n)
    {
        while (n--)
            _hack.pop_back();
    }
    char& MString::front()
    {
        return _hack.front();
    }
    char& MString::back()
    {
        return _hack.back();
    }
} // namespace strings