| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  | #include "..\e2dtool.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  | void e2d::Data::saveInt(const String& key, int value, const String& field) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  | 	::WritePrivateProfileString((LPCWSTR)field, (LPCWSTR)key, (LPCWSTR)String::parse(value), (LPCWSTR)Path::getDataSavePath()); | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  | void e2d::Data::saveDouble(const String& key, double value, const String& field) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  | 	::WritePrivateProfileString((LPCWSTR)field, (LPCWSTR)key, (LPCWSTR)String::parse(value), (LPCWSTR)Path::getDataSavePath()); | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  | void e2d::Data::saveBool(const String& key, bool value, const String& field) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  | 	::WritePrivateProfileString((LPCWSTR)field, (LPCWSTR)key, (value ? L"1" : L"0"), (LPCWSTR)Path::getDataSavePath()); | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  | void e2d::Data::saveString(const String& key, const String& value, const String& field) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  | 	::WritePrivateProfileString((LPCWSTR)field, (LPCWSTR)key, (LPCWSTR)value, (LPCWSTR)Path::getDataSavePath()); | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  | int e2d::Data::getInt(const String& key, int defaultValue, const String& field) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  | 	return ::GetPrivateProfileInt((LPCWSTR)field, (LPCWSTR)key, defaultValue, (LPCWSTR)Path::getDataSavePath()); | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  | double e2d::Data::getDouble(const String& key, double defaultValue, const String& field) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | { | 
					
						
							|  |  |  | 	wchar_t temp[32] = { 0 }; | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  | 	::GetPrivateProfileString((LPCWSTR)field, (LPCWSTR)key, (LPCWSTR)String::parse(defaultValue), temp, 31, (LPCWSTR)Path::getDataSavePath()); | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | 	return std::stof(temp); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  | bool e2d::Data::getBool(const String& key, bool defaultValue, const String& field) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | { | 
					
						
							|  |  |  | 	int nDefaultValue = defaultValue ? 1 : 0; | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  | 	int nValue = ::GetPrivateProfileInt((LPCWSTR)field, (LPCWSTR)key, nDefaultValue, (LPCWSTR)Path::getDataSavePath()); | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | 	return nValue != 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  | e2d::String e2d::Data::getString(const String& key, const String& defaultValue, const String& field) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | { | 
					
						
							|  |  |  | 	wchar_t temp[256] = { 0 }; | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  | 	::GetPrivateProfileString((LPCWSTR)field, (LPCWSTR)key, (LPCWSTR)defaultValue, temp, 255, (LPCWSTR)Path::getDataSavePath()); | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  | 	return temp; | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  | } |