mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-30 14:30:53 -07:00 
			
		
		
		
	Fixes and improvements to serialization.
There were multiple issues with comment and newline lexing. Extended printing functions to support Strings with %S flag (captial 'S'). Allows for length detection. Also made it so that precision for strings is the string length.
This commit is contained in:
		| @@ -47,7 +47,8 @@ internal sw _print_string( char* text, sw max_len, _format_info* info, char cons | ||||
| 	} | ||||
|  | ||||
| 	if ( info && info->precision >= 0 ) | ||||
| 		len = str_len( str, info->precision ); | ||||
| 		// Made the design decision for this library that precision is the length of the string. | ||||
| 		len = info->precision; | ||||
| 	else | ||||
| 		len = str_len( str ); | ||||
|  | ||||
| @@ -410,6 +411,15 @@ neverinline sw str_fmt_va( char* text, sw max_len, char const* fmt, va_list va ) | ||||
| 				len = _print_string( text, remaining, &info, va_arg( va, char* ) ); | ||||
| 				break; | ||||
|  | ||||
| 			case 'S': | ||||
| 			{ | ||||
| 				String gen_str = String { va_arg( va, char*) }; | ||||
|  | ||||
| 				info.precision = gen_str.length(); | ||||
| 				len            = _print_string( text, remaining, &info, gen_str ); | ||||
| 			} | ||||
| 			break; | ||||
|  | ||||
| 			case 'r' : | ||||
| 				len = _print_repeated_char( text, remaining, &info, va_arg( va, int ) ); | ||||
| 				break; | ||||
|   | ||||
| @@ -226,6 +226,11 @@ struct String | ||||
| 		return header.Capacity - header.Length; | ||||
| 	} | ||||
|  | ||||
| 	char& back() | ||||
| 	{ | ||||
| 		return Data[ length() - 1 ]; | ||||
| 	} | ||||
|  | ||||
| 	sw capacity() const | ||||
| 	{ | ||||
| 		Header const& | ||||
|   | ||||
		Reference in New Issue
	
	Block a user