summaryrefslogtreecommitdiff
path: root/src/register.cc
blob: 79ded4725694c0f0063cc1023284cda5335794a1 (plain)
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
#include "register.hh"

namespace Kakoune
{

const std::string Register::ms_empty;

Register& Register::operator=(const std::string& value)
{
    m_content.clear();
    m_content.push_back(value);
    return *this;
}

Register& Register::operator=(const memoryview<std::string>& values)
{
    m_content = std::vector<std::string>(values.begin(), values.end());
    return *this;
}

const std::string& Register::get() const
{
    if (m_content.size() != 0)
        return m_content.front();
    else
        return ms_empty;
}

const std::string& Register::get(size_t index) const
{
    if (m_content.size() > index)
        return m_content[index];
    else
        return ms_empty;
}

}