| 
									
										
										
										
											2018-10-03 22:02:46 +08:00
										 |  |  |  | // Copyright (c) 2016-2018 Easy2D - Nomango
 | 
					
						
							|  |  |  |  | // 
 | 
					
						
							|  |  |  |  | // Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
					
						
							|  |  |  |  | // of this software and associated documentation files (the "Software"), to deal
 | 
					
						
							|  |  |  |  | // in the Software without restriction, including without limitation the rights
 | 
					
						
							|  |  |  |  | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
					
						
							|  |  |  |  | // copies of the Software, and to permit persons to whom the Software is
 | 
					
						
							|  |  |  |  | // furnished to do so, subject to the following conditions:
 | 
					
						
							|  |  |  |  | // 
 | 
					
						
							|  |  |  |  | // The above copyright notice and this permission notice shall be included in
 | 
					
						
							|  |  |  |  | // all copies or substantial portions of the Software.
 | 
					
						
							|  |  |  |  | // 
 | 
					
						
							|  |  |  |  | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
					
						
							|  |  |  |  | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
					
						
							|  |  |  |  | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
					
						
							|  |  |  |  | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
					
						
							|  |  |  |  | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
					
						
							|  |  |  |  | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
					
						
							|  |  |  |  | // THE SOFTWARE.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 21:39:26 +08:00
										 |  |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  |  | #include "helper.hpp"
 | 
					
						
							| 
									
										
										
										
											2018-03-01 00:19:09 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 00:21:59 +08:00
										 |  |  |  | namespace easy2d | 
					
						
							| 
									
										
										
										
											2018-03-01 00:19:09 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-08 21:39:26 +08:00
										 |  |  |  | 	// <20><>Դ
 | 
					
						
							|  |  |  |  | 	// 
 | 
					
						
							|  |  |  |  | 	// Usage:
 | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  |  | 	//     Resource <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Դ
 | 
					
						
							|  |  |  |  | 	//     <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͣ<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD><EFBFBD><EFBFBD> exe <20>еĶ<D0B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-11-12 23:32:50 +08:00
										 |  |  |  | 	//     <20><><EFBFBD><EFBFBD>, һ<><D2BB><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ L"WAVE", <20><><EFBFBD>Ʊ<EFBFBD>ʶ<EFBFBD><CAB6>Ϊ IDR_WAVE_1,
 | 
					
						
							|  |  |  |  | 	//     <20><>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ: Resource res(MAKEINTRESOURCE(IDR_WAVE_1), L"WAVE");
 | 
					
						
							|  |  |  |  | 	// 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 21:39:26 +08:00
										 |  |  |  | 	//     <20>˽<EFBFBD><CBBD><EFBFBD>Դ<EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>Ϣ: https://docs.microsoft.com/en-us/windows/desktop/menurc/resources
 | 
					
						
							|  |  |  |  | 	//
 | 
					
						
							|  |  |  |  | 	class Resource | 
					
						
							| 
									
										
										
										
											2018-11-08 00:21:59 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-11-08 21:39:26 +08:00
										 |  |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  |  | 		enum class Type { File, Binary }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 21:39:26 +08:00
										 |  |  |  | 		Resource( | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  |  | 			String file_name	/* <20>ļ<EFBFBD>·<EFBFBD><C2B7> */ | 
					
						
							| 
									
										
										
										
											2018-11-08 21:39:26 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-03-01 00:19:09 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  |  | 		Resource( | 
					
						
							|  |  |  |  | 			LPCWSTR file_name	/* <20>ļ<EFBFBD>·<EFBFBD><C2B7> */ | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		Resource( | 
					
						
							|  |  |  |  | 			LPCWSTR name,		/* <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD> */ | 
					
						
							|  |  |  |  | 			LPCWSTR type		/* <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD> */ | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		virtual ~Resource(); | 
					
						
							| 
									
										
										
										
											2018-03-01 00:19:09 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  |  | 		inline bool IsFile() const { return type_ == Type::File; } | 
					
						
							| 
									
										
										
										
											2018-03-01 00:19:09 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  |  | 		inline Type GetType() const { return type_; } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		inline String const& GetFileName() const { return file_name_; } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		bool Load( | 
					
						
							|  |  |  |  | 			LPVOID& buffer, | 
					
						
							|  |  |  |  | 			DWORD& buffer_size | 
					
						
							|  |  |  |  | 		) const; | 
					
						
							| 
									
										
										
										
											2018-03-01 00:19:09 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 21:39:26 +08:00
										 |  |  |  | 		size_t GetHashCode() const; | 
					
						
							| 
									
										
										
										
											2018-05-22 22:55:06 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 21:39:26 +08:00
										 |  |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  |  | 		Type type_; | 
					
						
							|  |  |  |  | 		union | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			struct | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				String	file_name_; | 
					
						
							|  |  |  |  | 			}; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 			struct | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				LPCWSTR	bin_name_; | 
					
						
							|  |  |  |  | 				LPCWSTR	bin_type_; | 
					
						
							|  |  |  |  | 			}; | 
					
						
							|  |  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2018-11-08 21:39:26 +08:00
										 |  |  |  | 	}; | 
					
						
							|  |  |  |  | } |