blob: b904d2320ba86f17ccd1700b0173ad2e03144d03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
\LeadsheetsExplLibrary{properties}{2014/08/10 song properties}
\cs_generate_variant:Nn \tl_if_eq:nnTF {x}
\seq_new:N \l__leadsheets_song_properties_seq
\prop_new:N \l__leadsheets_duplicate_properties_prop
\cs_new_protected:Npn \leadsheets_define_property:n #1
{
\prop_new:c {l__leadsheets_songs_#1_prop}
\seq_put_right:Nn \l__leadsheets_song_properties_seq {#1}
}
\cs_new_protected:Npn \leadsheets_set_property:nnn #1#2#3
{ \prop_gput:cnn {l__leadsheets_songs_#2_prop} {#1} {#3} }
\cs_generate_variant:Nn \leadsheets_set_property:nnn { nnx }
\cs_new:Npn \leadsheets_get_property:nn #1#2
{ \prop_item:cn {l__leadsheets_songs_#2_prop} {#1} }
\cs_generate_variant:Nn \leadsheets_get_property:nn { V }
\prg_new_conditional:Npnn \leadsheets_if_property:nn #1#2 {p,T,F,TF}
{
\prop_if_in:cnTF {l__leadsheets_songs_#2_prop} {#1}
{ \prg_return_true: }
{ \prg_return_false: }
}
\cs_generate_variant:Nn \leadsheets_if_property:nnTF { V }
\cs_generate_variant:Nn \leadsheets_if_property:nnT { V }
\cs_generate_variant:Nn \leadsheets_if_property_p:nn { V }
\prg_new_conditional:Npnn \leadsheets_if_measuring: {T,F,TF}
{
\bool_if:NTF \l__leadsheets_measuring_bool
{ \prg_return_true: }
{ \prg_return_false: }
}
\prg_new_protected_conditional:Npnn \leadsheets_if_properties_eq:nnn #1#2#3 {T,F,TF}
{
\tl_if_eq:xxTF
{ \leadsheets_get_property:nn {#1} {#2} }
{ \leadsheets_get_property:nn {#1} {#3} }
{ \prg_return_true: }
{ \prg_return_false: }
}
\cs_generate_variant:Nn \leadsheets_if_properties_eq:nnnTF { V }
\prg_new_protected_conditional:Npnn \leadsheets_if_property_eq:nnn #1#2#3 {T,F,TF}
{
\tl_if_eq:xnTF
{ \leadsheets_get_property:nn {#1} {#2} }
{ #3 }
{ \prg_return_true: }
{ \prg_return_false: }
}
\cs_generate_variant:Nn \leadsheets_if_property_eq:nnnTF { V }
\cs_new_protected:Npn \leadsheets_copy_property:nnn #1#2#3
{
\bool_if:nT
{
!\leadsheets_if_property_p:nn {#1} {#3}
&&
\leadsheets_if_property_p:nn {#1} {#2}
}
{
\leadsheets_set_property:nnx {#1} {#3}
{ \leadsheets_get_property:nn {#1} {#2} }
}
}
\cs_new_protected:Npn \leadsheets_duplicate_property:nn #1#2
{ \prop_put:Nnn \l__leadsheets_duplicate_properties_prop {#1} {#2} }
\cs_new_protected:Npn \leadsheets_set_duplicate_properties:n #1
{
\prop_map_inline:Nn \l__leadsheets_duplicate_properties_prop
{ \leadsheets_copy_property:nnn {#1} {##1} {##2} }
}
\cs_new_protected:Npn \leadsheets_print_property_list:nnnnnn #1#2#3#4#5#6
{
\seq_set_split:Nnx \l__leadsheets_tmpa_seq {~and~}
{ \leadsheets_get_property:nn {#1} {#2} }
\seq_clear:N \l__leadsheets_tmpb_seq
\seq_map_inline:Nn \l__leadsheets_tmpa_seq
{ \seq_put_right:Nn \l__leadsheets_tmpb_seq { #3 {##1} } }
\seq_use:Nnnn \l__leadsheets_tmpb_seq {#4} {#5} {#6}
}
\cs_generate_variant:Nn \leadsheets_print_property_list:nnnnnn { V }
\cs_new_protected:Npn \leadsheets_use_property_list:nnnn #1#2#3#4
{
\seq_set_split:Nnx \l__leadsheets_tmpa_seq {~and~}
{ \leadsheets_get_property:nn {#1} {#2} }
\seq_clear:N \l__leadsheets_tmpb_seq
\seq_map_inline:Nn \l__leadsheets_tmpa_seq
{ \seq_put_right:Nn \l__leadsheets_tmpb_seq { #3 {##1} } }
\seq_use:Nn \l__leadsheets_tmpb_seq {#4}
}
\cs_generate_variant:Nn \leadsheets_use_property_list:nnnn { V }
\cs_new:Npn \leadsheets_for_property_list:nn #1#2
{ \__leadsheets_for_property_list_aux:nww {#2} #1 ~and~ \q_stop }
\cs_generate_variant:Nn \leadsheets_for_property_list:nn { f }
\cs_new:Npn \__leadsheets_for_property_list_aux:nww #1#2 ~and~ #3 \q_stop
{
#1 { #2 }
\tl_if_blank:nF {#3}
{ \__leadsheets_for_property_list_aux:nww {#1} #3 \q_stop }
}
\DeclareExpandableDocumentCommand \songproperty {m}
{ \leadsheets_get_property:Vn \l_leadsheets_current_song_id_tl {#1} }
% #1: command that formats every entry in list
% #2: property
% #3: separator between two
% #4: separator between more than tow
% #5: separator between last two
\NewDocumentCommand \printsongpropertylist {O{\use:n}mmmm}
{
\leadsheets_print_property_list:Vnnnnn \l_leadsheets_current_song_id_tl
{#2} {#1} {#3} {#4} {#5}
}
% #1: command that formats every entry in list
% #2: property
% #3: separator
\NewDocumentCommand \usesongpropertylist {O{\use:n}mm}
{
\leadsheets_use_property_list:Vnnn \l_leadsheets_current_song_id_tl
{#2} {#1} {#3}
}
% #1: command that formats every entry in list
% #2: property
\DeclareExpandableDocumentCommand \forsongpropertylist {mm}
{
\leadsheets_for_property_list:fn
{ \leadsheets_get_property:Vn \l_leadsheets_current_song_id_tl {#1} }
{#2}
}
\DeclareExpandableDocumentCommand \ifsongproperty {m}
{ \leadsheets_if_property:VnTF \l_leadsheets_current_song_id_tl {#1} }
\DeclareExpandableDocumentCommand \ifsongmeasuring {}
{ \leadsheets_if_measuring:TF }
\NewDocumentCommand \ifsongpropertiesequal {mm}
{ \leadsheets_if_properties_eq:VnnTF \l_leadsheets_current_song_id_tl {#1} {#2} }
\NewDocumentCommand \ifsongpropertyequal {mm}
{ \leadsheets_if_property_eq:VnnTF \l_leadsheets_current_song_id_tl {#1} {#2} }
\NewDocumentCommand \definesongproperty {m}
{ \leadsheets_define_property:n {#1} }
\@onlypreamble\definesongproperty
\NewDocumentCommand \copysongproperty {mm}
{ \leadsheets_duplicate_property:nn {#1} {#2} }
\@onlypreamble\copysongproperty
\endinput
|