Serialize and deserialize.
This commit is contained in:
		
					parent
					
						
							
								9142896237
							
						
					
				
			
			
				commit
				
					
						e762ab05c6
					
				
			
		
					 1 changed files with 25 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -2,6 +2,9 @@
 | 
			
		|||
#define BILLYSHEET_ADRESSE_HPP
 | 
			
		||||
 | 
			
		||||
#include <cstdint>
 | 
			
		||||
#include <nlohmann/json.hpp>
 | 
			
		||||
 | 
			
		||||
using json = nlohmann::json;
 | 
			
		||||
 | 
			
		||||
namespace character::characteristic {
 | 
			
		||||
	class Adresse final {
 | 
			
		||||
| 
						 | 
				
			
			@ -15,7 +18,29 @@ namespace character::characteristic {
 | 
			
		|||
		Adresse() noexcept = default;
 | 
			
		||||
 | 
			
		||||
		~Adresse() noexcept = default;
 | 
			
		||||
 | 
			
		||||
		[[nodiscard]] std::uint32_t get_base() const { return base; }
 | 
			
		||||
 | 
			
		||||
		[[nodiscard]] std::uint32_t get_carac() const { return carac; }
 | 
			
		||||
 | 
			
		||||
		[[nodiscard]] std::uint32_t get_materiel() const { return materiel; }
 | 
			
		||||
 | 
			
		||||
		[[nodiscard]] std::uint32_t get_additional() const { return additional; }
 | 
			
		||||
 | 
			
		||||
		friend void from_json(const json &j, Adresse &adresse) {
 | 
			
		||||
			const_cast<std::uint32_t&>(adresse.base) = j.at("base");
 | 
			
		||||
			adresse.carac = j.at("carac");
 | 
			
		||||
			adresse.materiel =j.at("materiel");
 | 
			
		||||
			adresse.additional =j.at("additional");
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	void to_json(json &j, const Adresse &adresse) {
 | 
			
		||||
		j.emplace("base", adresse.get_base());
 | 
			
		||||
		j.emplace("carac", adresse.get_carac());
 | 
			
		||||
		j.emplace("materiel", adresse.get_materiel());
 | 
			
		||||
		j.emplace("additional", adresse.get_additional());
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue