Commit Graph

72 Commits

Author SHA1 Message Date
Martchus ef0ab3d8c3 Avoid GCC's stringop-truncation warning
Not copying the termination character here is wanted. Just use
`std::memcpy` to avoid it as the special behavior of `std::strncpy` is not
needed here anyways.
2023-10-31 19:36:12 +01:00
Martchus 92345027fb Use generic `toInt()` function which relies less on compiler optimizations 2023-05-18 00:52:28 +02:00
Martchus 6fb16d72eb Avoid unqualified call to `std::strncpy()` 2023-05-07 21:45:47 +02:00
Martchus 2ae83a2301 Remove unused include 2022-07-21 23:24:08 +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 0e3ccf8baa Support play counter ID3v2 frame 2022-06-19 17:40:01 +02:00
Martchus 5205d08258 Improve coding style of a few functions in `id3v2frame.cpp`
* Declare functions only used in the compile unit as static
* Use `std` namespace explicitly
* Use `auto` where it makes sense
2022-06-19 16:32:42 +02:00
Martchus 669b054a48 Implement parsing popularimeter ID3v2 frame 2022-06-19 16:29:29 +02:00
Jonas Kvinge ea23d71e8a Fix spelling and typos 2021-07-02 11:12:39 +02:00
Martchus 65d52b2d57 Improve customization point for clearing tag field
* Allow customizing clearing only the value
* Use same naming scheme as in other places
* Avoid having to add an empty reset() function in subclasses
2021-01-30 19:10:16 +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 e7ce9e7ced Improve documentation 2020-11-05 19:52:09 +01:00
Martchus 6c8f237087 Show warning when reading/writing ID3v2 frames not matching the tag version 2020-04-22 19:48:27 +02:00
Martchus 0af4044a50 Remove deprecated functions of Id3v2Frame 2019-06-16 17:43:58 +02:00
Martchus 5ad00a083c Adapt to changes in c++utilities 2019-06-10 23:11:39 +02:00
Martchus a4665456d6 Fix warnings in Id3v2Frame 2019-06-01 22:26:16 +02:00
Martchus 69c72909e8 Fix some Doxygen warnings 2019-06-01 15:07:48 +02:00
Martchus c17db5f2f6 Apply cmake-format and clang-format 2019-05-04 21:03:09 +02:00
Martchus 7efa7a0d5a Adapt to c++utilities v5 2019-05-04 16:04:21 +02:00
Martchus dbce74444a Deprecate unused methods in Id3v2Frame 2019-02-13 21:44:19 +01:00
Martchus e93a7c53b3 Fix warnings in ID3v2Frame 2019-02-13 21:43:56 +01:00
Martchus 3d3bc94e39 Prevent warning "Cannot make an empty frame" 2019-02-13 20:19:46 +01:00
Martchus f1382bd286 Make message about empty frames only a warning
Empty frames don't cause any trouble in general. They only
*might* indicate that something went wrong.
2018-11-15 22:09:10 +01:00
Martchus a775ee61a2 Remove debug messages that the padding has been reached
This is true for most MP3 files and therefore not really helpful.
2018-11-15 22:07:07 +01:00
Martchus 8d89954cd3 Remove frameIdString() 2018-07-12 12:34:38 +02:00
Martchus 1a97d91b27 Preserve multiple strings in ID3v2 text frames 2018-07-12 12:34:38 +02:00
Martchus f27dbd8934 Update documentation 2018-07-09 12:42:14 +02:00
Martchus d64084ec78 Refactor formatting list of values 2018-07-01 22:11:34 +02:00
Martchus 943123afa1 Warn about ID3v2 text frame with multiple strings
First step to support multiple strings within ID3v2 text
frame.

See
* https://github.com/Martchus/tagparser/issues/10
* https://github.com/Martchus/tageditor/issues/38
2018-07-01 02:04:29 +02:00
Martchus 3265e0bea4 Fix documentation which was still using the old namespace 2018-06-03 20:38:32 +02:00
Martchus a065412d98 Add support for disk position in ID3v2.0 2018-06-02 23:08:38 +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 404e4f751f Improve comments and accessing the value in Id3v2FrameMaker 2018-06-02 19:34:07 +02:00
Martchus 710b7b420a Prevent writing float/e-notation to Id3v2 duration field 2018-06-02 19:31:39 +02:00
Martchus 878b3a3c4e Make diag msg on conversion error in Id3v2FrameMaker more specific 2018-06-02 19:29:43 +02:00
Martchus 047e9f7fd0 ID3v2: Warn if specified string is no valid position 2018-05-31 00:23:01 +02:00
Martchus ca0b8e4d8c Improve coding style 2018-03-11 22:28:15 +01:00
Martchus 59024a66a0 Don't clear field before parsing by default 2018-03-11 22:27:12 +01:00
Martchus b35fc2ff0d Improve some structure layouts 2018-03-11 16:14:42 +01:00
Martchus 0215b89057 Improve Id3v2Frame 2018-03-11 16:03:22 +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
Martchus 36511fcc13 Add progress feedback and diagnostics replacing status provider 2018-03-06 22:44:01 +01:00
Martchus 7a02e8a325 Uniform/simplify typedefs in templates
* Begin type names with capital letter
* Remove typedefs for implementation type
* Remove useless/obsolete comments
* Simplify relevant code
2018-03-06 22:44:01 +01:00
Martchus 6a62ef7fc2 Fix typo 2018-01-29 16:33:55 +01:00
Martchus f65b90885a Improve coding style 2017-10-09 21:49:04 +02:00
Martchus 6b705d5652 Mind encoding when converting TagValue to pos 2017-06-03 21:00:26 +02:00
Martchus 0d39a70b5f Improve making picture/comment frames 2017-05-29 14:05:15 +02:00
Martchus 8f5f61c85e Fix finding termination in ID3v2 description
This check is only to prevent writing bad frame
when given description contains termination
2017-05-21 00:09:09 +02:00