mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:52:44 +00:00 
			
		
		
		
	 6e19ab2bbc
			
		
	
	
		6e19ab2bbc
		
	
	
	
	
		
			
			We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
		
			
				
	
	
		
			49 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Cesar Torres <shortanemoia@protonmail.com>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/DeprecatedString.h>
 | |
| #include <AK/Optional.h>
 | |
| #include <AK/RefPtr.h>
 | |
| #include <AK/StringView.h>
 | |
| #include <AK/Vector.h>
 | |
| 
 | |
| // Extended M3U fields (de facto standard)
 | |
| struct M3UExtendedInfo {
 | |
|     Optional<u32> track_length_in_seconds;
 | |
|     Optional<DeprecatedString> track_display_title;
 | |
|     Optional<DeprecatedString> group_name;
 | |
|     Optional<DeprecatedString> album_title;
 | |
|     Optional<DeprecatedString> album_artist;
 | |
|     Optional<DeprecatedString> album_genre;
 | |
|     Optional<u64> file_size_in_bytes;
 | |
|     Optional<ReadonlyBytes> embedded_mp3;
 | |
|     Optional<DeprecatedString> cover_path;
 | |
| };
 | |
| 
 | |
| struct M3UEntry {
 | |
|     DeprecatedString path;
 | |
|     Optional<M3UExtendedInfo> extended_info;
 | |
| };
 | |
| 
 | |
| class M3UParser {
 | |
| public:
 | |
|     static NonnullOwnPtr<M3UParser> from_file(StringView path);
 | |
|     static NonnullOwnPtr<M3UParser> from_memory(DeprecatedString const& m3u_contents, bool utf8);
 | |
| 
 | |
|     NonnullOwnPtr<Vector<M3UEntry>> parse(bool include_extended_info);
 | |
| 
 | |
|     Optional<DeprecatedString>& get_playlist_title_metadata() { return m_parsed_playlist_title; }
 | |
| 
 | |
|     M3UParser();
 | |
| 
 | |
| private:
 | |
|     DeprecatedString m_m3u_raw_data;
 | |
|     DeprecatedString m_playlist_path;
 | |
|     bool m_use_utf8;
 | |
|     Optional<DeprecatedString> m_parsed_playlist_title;
 | |
| };
 |