Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
TraxSupportXML.h
1// trax track library
2// AD 2014
3//
4// "the resolution of all the fruitless searches"
5//
6// Peter Gabriel
7//
8//
9// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
10// Copyright (c) 2019 Marc-Michael Horstmann
11//
12// Permission is hereby granted to any person obtaining a copy of this software
13// and associated source code (the "Software"), to use, view, and study the
14// Software for personal or internal business purposes, subject to the following
15// conditions:
16//
17// 1. Redistribution, modification, sublicensing, or commercial use of the
18// Software is NOT permitted without prior written consent from the copyright
19// holder.
20//
21// 2. The Software is provided "AS IS", without warranty of any kind, express
22// or implied.
23//
24// 3. All copies of the Software must retain this license notice.
25//
26// For further information, please contact: horstmann.marc@trendverlag.de
27
28#pragma once
29
30#include "common/support/CommonSupportXML.h"
31#include "dim/support/DimSupportXML.h"
32#include "spat/support/SpatSupportXML.h"
33
34#include "trax/Track.h"
35
36namespace trax{
37
38 struct TrackLocation;
39 struct TrackLocationRef;
40 struct TrackRange;
41
42 namespace ptreesupport{
43
44 using spat::ptreesupport::operator<<;
45
48 dclspc void ReadConnection( const boost::property_tree::ptree& pt, Track::End& trackend ) noexcept;
49 dclspc void ReadTrackEnd( const boost::property_tree::ptree& pt, Track::End& trackend ) noexcept;
50 dclspc void ReadTrackLocation( const boost::property_tree::ptree& pt, TrackLocation& trackLocation ) noexcept;
51 dclspc void ReadTrackLocationRef( const boost::property_tree::ptree& pt, TrackLocationRef& trackLocationRef ) noexcept;
52 dclspc void ReadTrackRange( const boost::property_tree::ptree& pt, TrackRange& trackRange ) noexcept;
54
55
56 template<class Interface>
57 inline void WriteLocalizedTag(
58 boost::property_tree::ptree& pt,
59 const std::string& tagName,
60 const Interface& refInterface )
61 {
62 auto localizedNames = refInterface.ReferenceNames( tagName + "_" );
63 for( const auto& localizedName : localizedNames ){
64 std::string localizedString{ localizedName };
65 boost::property_tree::ptree ptLocalizedTag;
66 std::string languageName = localizedString.substr( tagName.size() + 1 );
67 if( languageName != "unknown" )
68 ptLocalizedTag.add( "<xmlattr>.language", localizedString.substr( tagName.size() + 1 ) );
69
70 ptLocalizedTag.put( "", refInterface.Reference(localizedString) );
71 pt.add_child( tagName, ptLocalizedTag );
72 }
73 }
74
75 template<class Interface>
76 inline void ReadLocalizedTag(
77 const boost::property_tree::ptree& pt,
78 const char* tagName,
79 Interface& refInterface,
80 const char* localeString )
81 {
82 auto optional = pt.get_optional<std::string>( "<xmlattr>.language" );
83 if( optional ){
84 refInterface.Reference( std::string{ tagName } + "_" + *optional, pt.data() );
85
86 if( refInterface.Reference( tagName ).empty() || localeString == *optional )
87 refInterface.Reference( tagName, pt.data() );
88 }
89 else{
90 refInterface.Reference( std::string{ tagName } + "_unknown", pt.data() );
91
92 if( refInterface.Reference( tagName ).empty() )
93 refInterface.Reference( tagName, pt.data() );
94 }
95 }
96
97
102 inline void move_child(
103 boost::property_tree::ptree& toParent,
104 const boost::property_tree::ptree::path_type& path,
105 boost::property_tree::ptree& value )
106 {
107 toParent.add_child( path, boost::property_tree::ptree{} ).swap( value );
108 }
109
110 } // namespace ptreesupport
111} // namespace trax
Home of the Track and TrackBuilder interfaces.
ptree operator support
Definition CommonSupportXML.h:42
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
A TrackLocation ist a location on a single track.
Definition TrackLocation.h:43
A track location, referencing the track by id.
Definition TrackLocation.h:102
An interval on a track, referenced by an id.
Definition TrackLocation.h:132