Kea 3.3.3
user_file.h
Go to the documentation of this file.
1// Copyright (C) 2013-2026,2017 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6#ifndef _USER_FILE_H
7#define _USER_FILE_H
8
11
12#include <user_chk/user.h>
14
15#include <fstream>
16#include <string>
17
18#include <boost/shared_ptr.hpp>
19
20namespace user_chk {
21
25public:
26 UserFileError(const char* file, size_t line, const char* what) :
27 UserDataSourceError(file, line, what)
28 {}
29};
30
60class UserFile : public UserDataSource {
61public:
65 static const size_t USER_ENTRY_MAX_LEN = 4096;
66
73 UserFile(const std::string& fname);
74
78 virtual ~UserFile();
79
86 virtual void open();
87
97 virtual UserPtr readNextUser();
98
102 virtual void close();
103
107 virtual bool isOpen() const;
108
116 UserPtr makeUser(const std::string& user_string);
117
118private:
120 std::string fname_;
121
123 std::ifstream file_;
124
125};
126
128typedef boost::shared_ptr<UserFile> UserFilePtr;
129
130} // namespace user_chk
131
132#endif
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
UserDataSourceError(const char *file, size_t line, const char *what)
UserFileError(const char *file, size_t line, const char *what)
Definition user_file.h:26
static const size_t USER_ENTRY_MAX_LEN
Maximum length of a single user entry.
Definition user_file.h:65
virtual UserPtr readNextUser()
Fetches the next user from the file.
Definition user_file.cc:44
virtual void close()
Closes the underlying file.
Definition user_file.cc:142
UserFile(const std::string &fname)
Constructor.
Definition user_file.cc:19
UserPtr makeUser(const std::string &user_string)
Creates a new User instance from JSON text.
Definition user_file.cc:66
virtual bool isOpen() const
Returns true if the file is open.
Definition user_file.cc:137
virtual ~UserFile()
Destructor. / The destructor does call the close method.
Definition user_file.cc:25
virtual void open()
Opens the input file for reading.
Definition user_file.cc:30
Defines the logger used by the user check hooks library.
Definition user.cc:18
boost::shared_ptr< User > UserPtr
Defines a smart pointer to a User.
Definition user.h:241
boost::shared_ptr< UserFile > UserFilePtr
Defines a smart pointer to a UserFile.
Definition user_file.h:128
This file defines classes: UserId and User.
Defines the base class, UserDataSource.