/ CPP_Modules / CPP_Module_05 / ex00 / 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/28 16:19:53 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  /* ************************************************************************** */
22  /*                                 Bureaucrat                                 */
23  /* ************************************************************************** */
24  class Bureaucrat
25  {
26  public:
27  	Bureaucrat();
28  	Bureaucrat(std::string const& name, int grade);
29  	Bureaucrat(Bureaucrat const& target);
30  	Bureaucrat&			operator=(Bureaucrat const& target);
31  	~Bureaucrat();
32  
33  public:
34  	std::string const&	getName() const;
35  	int					getGrade() const;
36  	void				setGrade(int grade);
37  
38  public:
39  	void				increaseGrade();
40  	void				decreaseGrade();
41  
42  private:
43  	std::string const	mName;
44  	int					mGrade;
45  
46  /* ************************************************************************** */
47  /*                     Bureaucrat::GradeTooHighException                      */
48  /* ************************************************************************** */
49  public:
50  	class GradeTooHighException : public std::exception
51  	{
52  	public:
53  		GradeTooHighException();
54  		GradeTooHighException(std::string const& msg);
55  		GradeTooHighException(GradeTooHighException const& target);
56  		GradeTooHighException&	operator=(GradeTooHighException const& target);
57  		virtual ~GradeTooHighException() throw();
58  
59  	public:
60  		std::string const&		getMessage() const;
61  
62  	public:
63  		virtual char const*		what() const throw();
64  
65  	private:
66  		std::string				mMessage;
67  	};
68  
69  /* ************************************************************************** */
70  /*                      Bureaucrat::GradeTooLowException                      */
71  /* ************************************************************************** */
72  public:
73  	class GradeTooLowException : public std::exception
74  	{
75  	public:
76  		GradeTooLowException();
77  		GradeTooLowException(std::string const& msg);
78  		GradeTooLowException(GradeTooLowException const& target);
79  		GradeTooLowException&	operator=(GradeTooLowException const& target);
80  		virtual ~GradeTooLowException() throw();
81  
82  	public:
83  		std::string const&		getMessage() const;
84  
85  	public:
86  		virtual char const*		what() const throw();
87  
88  	private:
89  		std::string				mMessage;
90  	};
91  };
92  
93  std::ostream&			operator<<(std::ostream& os, Bureaucrat const& target);
94  
95  #endif /* __BUREAUCRAT_HPP__ */