mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 05:52:59 +00:00 
			
		
		
		
	new utility functions: (de)serialize, as_cstring
This commit is contained in:
		| @@ -992,9 +992,7 @@ int read_geom_args() { | |||||||
|   else if(argis("-fwrite")) { |   else if(argis("-fwrite")) { | ||||||
|     shstream hs; |     shstream hs; | ||||||
|     hwrite_fpattern(hs, currfp); |     hwrite_fpattern(hs, currfp); | ||||||
|     string s; |     println(hlog, "current fieldpattern: ", as_cstring(hs.s)); | ||||||
|     for(char c: hs.s) s += format("\\x%02x", (unsigned char) c); |  | ||||||
|     println(hlog, "current fieldpattern: ", s); |  | ||||||
|     } |     } | ||||||
|   else if(argis("-csp")) { |   else if(argis("-csp")) { | ||||||
|     cheat(); |     cheat(); | ||||||
|   | |||||||
							
								
								
									
										24
									
								
								hprint.cpp
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								hprint.cpp
									
									
									
									
									
								
							| @@ -357,6 +357,30 @@ EX transmatrix kz(transmatrix h) { | |||||||
| EX string pick123() { return cts('1' + rand() % 3); } | EX string pick123() { return cts('1' + rand() % 3); } | ||||||
| EX string pick12() { return cts('1' + rand() % 2); } | EX string pick12() { return cts('1' + rand() % 2); } | ||||||
|  |  | ||||||
|  | #if HDR | ||||||
|  | template<class T> string serialize(const T& data) { | ||||||
|  |   shstream shs; | ||||||
|  |   hwrite(shs, data); | ||||||
|  |   return shs.s; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  | template<class T> T deserialize(const string& s) { | ||||||
|  |   shstream shs; | ||||||
|  |   shs.s = s; | ||||||
|  |   T data; | ||||||
|  |   hread(shs, data); | ||||||
|  |   return data; | ||||||
|  |   } | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | EX string as_cstring(string o) { | ||||||
|  |   string s = "string(\""; | ||||||
|  |   for(char c: o) | ||||||
|  |     s += format("\\x%02x", (unsigned char) c); | ||||||
|  |   s += format("\", %d)", isize(o)); | ||||||
|  |   return s; | ||||||
|  |   } | ||||||
|  |  | ||||||
| #if HDR | #if HDR | ||||||
| #if ISANDROID | #if ISANDROID | ||||||
| #define DEBB(r,x) | #define DEBB(r,x) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue