/ CPP_Modules / CPP_Module_05 / ex01 / Bureaucrat.hpp
Bureaucrat.hpp
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   Bureaucrat.hpp                                     :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: gychoi <gychoi@student.42seoul.kr>         +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2023/11/09 23:13:08 by gychoi            #+#    #+#             */
 9  /*   Updated: 2023/11/29 22:28:01 by gychoi           ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #pragma once
14  #ifndef __BUREAUCRAT_HPP__
15  #define __BUREAUCRAT_HPP__
16  
17  #include <iostream>
18  #include <stdexcept>
19  #include <string>
20  
21  class Form;
22  
23  /* ************************************************************************** */
24  /*                                 Bureaucrat                                 */
25  /* ************************************************************************** */
26  class Bureaucrat
27  {
28  public:
29  	Bureaucrat();
30  	Bureaucrat(std::string const& name, int grade);
31  	Bureaucrat(Bureaucrat const& target);
32  	Bureaucrat&			operator=(Bureaucrat const& target);
33  	~Bureaucrat();
34  
35  public:
36  	std::string const&	getName() const;
37  	int					getGrade() const;
38  	void				setGrade(int grade);
39  
40  public:
41  	void				increaseGrade();
42  	void				decreaseGrade();
43  	void				signForm(Form& form);
44  
45  
46  private:
47  	std::string const	mName;
48  	int					mGrade;
49  
50  /* ************************************************************************** */
51  /*                     Bureaucrat::GradeTooHighException                      */
52  /* ************************************************************************** */
53  public:
54  	class GradeTooHighException : public std::exception
55  	{
56  	public:
57  		GradeTooHighException();
58  		GradeTooHighException(std::string const& msg);
59  		GradeTooHighException(GradeTooHighException const& target);
60  		GradeTooHighException&	operator=(GradeTooHighException const& target);
61  		virtual ~GradeTooHighException() throw();
62  
63  	public:
64  		std::string const&		getMessage() const;
65  
66  	public:
67  		virtual char const*		what() const throw();
68  
69  	private:
70  		std::string				mMessage;
71  	};
72  
73  /* ************************************************************************** */
74  /*                      Bureaucrat::GradeTooLowException                      */
75  /* ************************************************************************** */
76  public:
77  	class GradeTooLowException : public std::exception
78  	{
79  	public:
80  		GradeTooLowException();
81  		GradeTooLowException(std::string const& msg);
82  		GradeTooLowException(GradeTooLowException const& target);
83  		GradeTooLowException&	operator=(GradeTooLowException const& target);
84  		virtual ~GradeTooLowException() throw();
85  
86  	public:
87  		std::string const&		getMessage() const;
88  
89  	public:
90  		virtual char const*		what() const throw();
91  
92  	private:
93  		std::string				mMessage;
94  	};
95  };
96  
97  std::ostream&			operator<<(std::ostream& os, Bureaucrat const& target);
98  
99  #endif /* __BUREAUCRAT_HPP__ */