mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:22:43 +00:00 
			
		
		
		
	 57dc179b1f
			
		
	
	
		57dc179b1f
		
	
	
	
	
		
			
			This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Assertions.h>
 | |
| #include <AK/DeprecatedString.h>
 | |
| 
 | |
| namespace Web::CSS {
 | |
| 
 | |
| // https://www.w3.org/TR/css-syntax-3/#urange-syntax
 | |
| class UnicodeRange {
 | |
| public:
 | |
|     UnicodeRange(u32 min_code_point, u32 max_code_point)
 | |
|         : m_min_code_point(min_code_point)
 | |
|         , m_max_code_point(max_code_point)
 | |
|     {
 | |
|         VERIFY(min_code_point <= max_code_point);
 | |
|     }
 | |
| 
 | |
|     u32 min_code_point() const { return m_min_code_point; }
 | |
|     u32 max_code_point() const { return m_max_code_point; }
 | |
| 
 | |
|     bool contains(u32 code_point) const
 | |
|     {
 | |
|         return m_min_code_point <= code_point && code_point <= m_max_code_point;
 | |
|     }
 | |
| 
 | |
|     DeprecatedString to_deprecated_string() const
 | |
|     {
 | |
|         if (m_min_code_point == m_max_code_point)
 | |
|             return DeprecatedString::formatted("U+{:x}", m_min_code_point);
 | |
|         return DeprecatedString::formatted("U+{:x}-{:x}", m_min_code_point, m_max_code_point);
 | |
|     }
 | |
| 
 | |
| private:
 | |
|     u32 m_min_code_point;
 | |
|     u32 m_max_code_point;
 | |
| };
 | |
| 
 | |
| }
 |