Commit Graph

73 Commits

Author SHA1 Message Date
Martchus f7941d442f Fix typo 2023-07-30 14:40:15 +02:00
Martchus 92345027fb Use generic `toInt()` function which relies less on compiler optimizations 2023-05-18 00:52:28 +02:00
Martchus 8ad28f857b Allow extending important classes without ABI break
This allows to make ABI breaks less often while still
being able to extend many aspects of the library.
2023-05-16 22:20:48 +02:00
Martchus 111d6190cb Avoid some of the warnings from MSVC 2023-05-07 21:45:15 +02:00
Martchus d80736743b Use `pubsetbuf` only with `libstdc++`
This usage of the function seems only to work as intended with that
standard lib. With `libc++` and the MSVC standard lib the call has no
effect.
2023-02-28 21:06:52 +01:00
Martchus 981db492e4 Avoid unqualified calls to `std::move` 2023-02-20 19:54:42 +01:00
Martchus 0cc9271a7f Revert "Omit default components when formatting date time"
* This hack is no longer required as it is now possible to preserve
  what date time parts are specified.
* This reverts commit 44fea6c8c2.
2022-08-13 15:43:28 +02:00
Martchus 4aff37b788 Support `CppUtilities::DateTimeExpression` in `TagValue` 2022-08-13 14:42:51 +02:00
Martchus 60233c2af2 Add missing documentation 2022-08-02 21:41:05 +02:00
Martchus ccf77959b4 Convert text values to a supported encoding if needed on the fly
* This makes it harder to use the library wrongly and does not lead to
  worse performance as character set conversions are only done as needed.
* That's actually already done by serializers for most tag formats. This
  change ensures serializers for Matroska and Vorbis tag fields do this as
  well.
* Update documentation accordingly.
2022-07-21 23:30:45 +02:00
Martchus c3c525c352 Scale rating automatically when serializing popularity/rating field
* Allow one to get a `Popularity` where `.rating` is always between 1 and 5
  via `TagValue::toScaledPopularity()` (or a "raw" scale by specifying the
  corresponding tag format)
* Allow one to assign a `Popularity` with `.scale = TagType::Unspecified`
  and `.rating` between 1 and 5 (or a "raw" scale by specifying the
  corresponding tag format). It will then be converted internally to
  the required scale (whatever the tag format internally uses)
    * Ensure all tag formats with popularity/rating field use
      `TagValue::toScaledPopularity()` internally when a `Popularity`
      object is assigned
* Ensure all tag formats with popularity/rating field store the rating as
  popularity object to preserve the scaling information
* Keep passing raw strings around working
    * `TagValue::toString()` still does *no* scaling
    * `TagValue::toScaledPopularity()` does *no* scaling for text values
      and instead just assigns the specified scale
* See https://github.com/Martchus/tagparser/issues/23
2022-07-20 23:23:51 +02:00
Martchus 98d28ede9f Add scale info to Popularity for furture extension
This would allow implementing a way to convert between different scales and
which in turn would allow the UI to provide an editor with a generic scale
(e.g. stars) instead of only allowing to edit raw values as string.

This also make it assume that a single number is meant to be the rating
(instead of the user). That should make editing the rating a bit more
straight forward (if one doesn't care about the user and play counter).
2022-06-20 21:27:42 +02:00
Martchus 449ad034de Add string-representation for all types in tagDataTypeString() 2022-06-19 17:39:32 +02:00
Martchus 08570aea32 Support unsigned integers in TagValue 2022-06-19 17:38:54 +02:00
Martchus 669b054a48 Implement parsing popularimeter ID3v2 frame 2022-06-19 16:29:29 +02:00
Martchus f52b2958df Add implicit conversion of popularity to integer to generalize usage of popularity
* Propose the usage of the popularity type in general for the rating field
  so GUIs can show an appropriate UI element
* Do not just propose the popularity type for ID3v2 tags so a uniform UI
  element can be shown accross tag formats; and API to convert from a
  uniform scale is still TODO
2022-06-19 14:32:45 +02:00
Martchus c41046bd24 Simplify TagValue's comparision code 2022-06-18 14:54:55 +02:00
Martchus aa4b8a8e47 Ensure to handle all conversion errors in TagValue's equality operator
For instance, if a DateTime of wrong size is assigned this would lead to a
conversion error which would otherwise be unhandled.
2022-06-18 14:40:53 +02:00
Martchus 46014def51 Add data type for ID3v2's Popularimeter field
See https://github.com/Martchus/tageditor/issues/84
2022-06-18 14:33:30 +02:00
Martchus 5d7b7488fa Fix TagValue::toWString() for TagDataType::DateTime 2022-06-16 00:29:05 +02:00
Martchus 2448bcd456 Fix TagValue::convertDescriptionEncoding() 2021-05-09 18:37:31 +02:00
Martchus 0a041f6ad2 Fix warnings 2021-03-20 21:26:25 +01:00
Martchus 64d98f5530 Use std::string_view where it makes sense 2021-01-30 21:53:06 +01:00
Martchus 6b469f1c26 Add Locale class to deal with differently specified languages/countries
Different media/tag formats specify languages and countries
differently. This change introduces a Locale class to keep track
of the format being used. So far there are no automatic conversions
implemented so it is entirely up to the user to pass valid values using
a format which matches the one required by the media/tag format.

This change also adds support for Matroska's IETF elements so at least the
raw value can be read, written and is preserved.
2020-12-16 17:48:08 +01:00
Martchus 007251c604 Improve documentation of TagValue 2020-12-05 20:52:19 +01:00
Martchus 9368b7a245 Add flags to TagValue, replacing dedicated field for read-only flag 2020-12-05 20:52:01 +01:00
Martchus 44fea6c8c2 Omit default components when formatting date time
It just looks nicer to have e.g. "2017" instead of "2017-01-01T00:00:00".
The ID3v2.4.0 standard and the Matroska standard explicitely allow this
format as well.
2020-04-26 21:45:20 +02:00
Martchus d26e594777 Deprecate 'Year' in favor of 'RecordDate' and 'ReleaseDate', fix handling in ID3v2
1. Convert TYER and related fields of old ID3v2 versions to the new TDRC
  field and only expose that via the generic accessors.
2. When writing an old ID3v2 tag, convert TDRC back to the old fields.
3. One can still manually unset the via 1. auto-populated TDRC to disable 2.
   and write the old fields directly. So the automatic handling does not
   reduce the flexibility of the library.
4. Deprecate 'Year'; it is replaced by the already existing 'RecordDate'
   which is now supposed to be used everywhere where 'Year' was used before
5. Introduce 'ReleaseDate' to support this field which is supported in
   ID3v2.4.0 and Matroska via the generic accessors.
6. Use ISO format when converting tag values of the type DateTime to/from
   string. This is closer to what's used in ID3v2 tags internally. (The
   library still allows the old format as fallback when parsing for
   compatibility.)
2020-04-24 23:15:13 +02:00
Martchus fe67abcfeb Fix old namespaces being mentioned in the documentation 2019-09-04 18:47:54 +02:00
Martchus 2725bad686 Add options for TagValue comparison
* Support case-insensitive comparision
* Allow ignoring meta-data
2019-08-12 20:24:27 +02:00
Martchus 5ad00a083c Adapt to changes in c++utilities 2019-06-10 23:11:39 +02:00
Martchus 736b4caeeb Document handling different types and encodings 2019-06-01 23:20:01 +02:00
Martchus 5114a3ea08 Treat differently encoded values not necessarily as different
That an automatic conversion happens for different types but not
for different encodings was always a bit odd.

This makes writing tests easier and comparing values within the
tag editor does not rely on choosing a particular encoding.
2019-06-01 23:01:53 +02:00
Martchus a8e20c5ef4 Allow converting the description encoding 2019-06-01 22:57:01 +02:00
Martchus 8c88298fe8 Fix TagValue::operator== if 0 byte contained 2019-06-01 12:33:24 +02:00
Martchus 73adf26401 Fix conversion from PositionInSet to integer
Even though there was already a test verifying that it is
not possible.
2019-06-01 12:18:05 +02:00
Martchus 7efa7a0d5a Adapt to c++utilities v5 2019-05-04 16:04:21 +02:00
Martchus 296e5d11b6 Fix TagValue::toStandardGenreIndex() for empty genre index 2019-02-14 18:18:54 +01:00
Martchus 5140b76f08 Treat 255 as empty ID3v1 genre index 2019-02-13 18:56:03 +01:00
Martchus 3265e0bea4 Fix documentation which was still using the old namespace 2018-06-03 20:38:32 +02:00
Martchus 0a640c9f7f Fix warnings, mostly about implicit int conversions
This should fix all non-erros, leaving only warnings which
are indeed potential problems.

The following warnings should be safe to ignore:

* Conversions of various offsets from uint64 to
  std::streamoff/int64 are safe because such offsets have
  been obtained via tellg() and other functions
  returning std::streamoff in the first place.
* It also works vice-versa since tellg() should not
  return negative offsets with exceptions enabled.
* Conversions from char to unsigned char are also ok.
* Unused diag arguments can be ignored (those might be
  useful later).
* Annotate all intended fallthoughs.
2018-06-02 23:04:53 +02:00
Martchus f1656faa96 Fix TagValue::to{TimeSpan,DateTime}() for UTF-16 2018-06-02 19:23:07 +02:00
Martchus 09c1c6a232 Improve coding style in TagValue 2018-06-02 19:22:26 +02:00
Martchus fd1864c3df Make error messages in TagValue more specific 2018-06-02 19:21:15 +02:00
Martchus ca0b8e4d8c Improve coding style 2018-03-11 22:28:15 +01:00
Martchus 706c410edb Clear description encoding of TagValue 2018-03-11 22:27:55 +01:00
Martchus b35fc2ff0d Improve some structure layouts 2018-03-11 16:14:42 +01:00
Martchus a26b98dcd7 Improve TagValue
* Make more functions inline
* Fix use of std::size_t
2018-03-11 15:16:09 +01:00
Martchus c0336ed4bb Apply clang-format 2018-03-07 01:17:50 +01:00
Martchus 0e15c74103 Move everything into namespace TagParser 2018-03-06 23:09:15 +01:00