aboutsummaryrefslogtreecommitdiff
path: root/include/User.hpp
blob: ab5872aab8767709063ec6b50470f6a46a66e4b5 (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
#pragma once

#include "Signature.hpp"
#include <string>
#include <stdexcept>

namespace odhtdb
{
    class UserNameTooLongException : public std::runtime_error
    {
    public:
        UserNameTooLongException(const std::string &userName) : 
            std::runtime_error(std::string("The username ") + userName + " is longer than 255 bytes")
        {

        }
    };

    class User
    {
    public:
        virtual ~User(){}
        
        const std::string& getName() const { return name; }
        virtual const Signature::PublicKey& getPublicKey() const = 0;
    protected:
        User(const std::string &_name) : name(_name)
        {
            if(name.size() > 255)
                throw UserNameTooLongException(name);
        }
    private:
        std::string name;
    };
}