Debian Codegraph @

dwtools/Categories.cpp

raw symbols SCIP
1 /* Categories.cpp
2 *
3 * Copyright (C) 1993-2018 David Weenink, 2015,2017,2018 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /*
20 djmw 20020315 GPL header
21 djmw 20110304 Thing_new
22 */
23
24 #include "Categories.h"cxx . . $ `<file>/dwtools/Categories.h`/
25
26 void structCategoriescxx . . $ structCategories# :: v1_infocxx . . $ structCategories#v1_info(49f6e7a06ebc5aa8). () {
27 structDaatacxx . . $ structDaata# :: v1_infocxx . . $ structThing#v1_info(49f6e7a06ebc5aa8). ();
28 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Number of strings: ", ourcxx . . $ `melder/melder.h:42:9`! sizecxx . . $ CollectionOf#size.);
29 autoStringSetcxx . . $ autoStringSet# set = StringList_to_StringSetcxx . . $ StringList_to_StringSet(7909a6d728cc3eb9). (this);
30 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Number of unique categories: ", set->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab).sizecxx . . $ CollectionOf#size.);
31 }
32
33 void structCategoriescxx . . $ structCategories# :: v1_readTextcxx . . $ structCategories#v1_readText(97c85d3b778168ad). (MelderReadTextcxx . . $ MelderReadText# a_text, int /*formatVersion*/) {
34 integercxx . . $ integer# l_size = texgeti32cxx . . $ texgeti32(2ccfb320b77fcecd). (a_text);
35 if (l_size == 0)
36 (void) 0;
37 else if (l_size < 0)
38 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Size cannot be negative.");
39 else
40 ourcxx . . $ `melder/melder.h:42:9`! _growcxx . . $ CollectionOf#_grow(1624ee8275b10bda). (l_size);
41
42 for (integercxx . . $ integer# i = 1; i <= l_size; i ++) {
43 autoSimpleStringcxx . . $ autoSimpleString# itemi = Thing_newcxx . . $ `sys/Thing.h:514:9`! (SimpleString);
44 itemi ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). v1_readTextcxx . . $ structSimpleString#v1_readText(97c85d3b778168ad). (a_text, 0);
45 ourcxx . . $ `melder/melder.h:42:9`! addItemAtPosition_movecxx . . $ OrderedOf#addItemAtPosition_move(ca501a207ce7a6c1). (itemicxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), i);
46 }
47 }
48
49 void structCategoriescxx . . $ structCategories# :: v1_writeTextcxx . . $ structCategories#v1_writeText(1145552d769d7b5d). (MelderFilecxx . . $ MelderFile# file) {
50 texputi32cxx . . $ texputi32(7d66e869d177be0). (file, ourcxx . . $ `melder/melder.h:42:9`! sizecxx . . $ CollectionOf#size., U"size");
51 for (integercxx . . $ integer# i = 1; i <= ourcxx . . $ `melder/melder.h:42:9`! sizecxx . . $ CollectionOf#size.; i ++) {
52 SimpleStringcxx . . $ SimpleString# data = ourcxx . . $ `melder/melder.h:42:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i];
53 texputintrocxx . . $ texputintro(ca2e4f9dca357a80). (file, U"item [", Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (i), U"]:");
54 data -> structSimpleStringcxx . . $ structSimpleString# :: v1_writeTextcxx . . $ structSimpleString#v1_writeText(1145552d769d7b5d). (file);
55 texexdentcxx . . $ texexdent(1145552d769d7b5d). (file);
56 }
57 }
58
59 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Categories, StringList, 0);
60
61 autoCategoriescxx . . $ autoCategories# Categories_createcxx . . $ Categories_create(8007a1fe88fa0475). () {
62 try {
63 autoCategoriescxx . . $ autoCategories# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Categories);
64 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
65 } catch (MelderErrorcxx . . $ MelderError#) {
66 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Categories not created.");
67 }
68 }
69
70 autoCategoriescxx . . $ autoCategories# Categories_createWithSequentialNumberscxx . . $ Categories_createWithSequentialNumbers(885f39c7c4d34371). (integercxx . . $ integer# n) {
71 try {
72 autoCategoriescxx . . $ autoCategories# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Categories);
73 OrderedOfString_initWithSequentialNumberscxx . . $ OrderedOfString_initWithSequentialNumbers(58a263e574586e4d). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), n);
74 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
75 } catch (MelderErrorcxx . . $ MelderError#) {
76 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Sequential number Categories not created.");
77 }
78 }
79
80 autoCategoriescxx . . $ autoCategories# Categories_selectUniqueItemscxx . . $ Categories_selectUniqueItems(cf972beb033e2c24). (Categoriescxx . . $ Categories# me) {
81 try {
82 autoStringSetcxx . . $ autoStringSet# set = StringList_to_StringSetcxx . . $ StringList_to_StringSet(7909a6d728cc3eb9). (me);
83 autoCategoriescxx . . $ autoCategories# thee = Categories_createcxx . . $ Categories_create(8007a1fe88fa0475). ();
84 for (integercxx . . $ integer# i = 1; i <= set->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab).sizecxx . . $ CollectionOf#size.; i ++) {
85 autoSimpleStringcxx . . $ autoSimpleString# item = Data_copycxx . . $ Data_copy(97a542a26794c80e). (set->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab).atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]);
86 thycxx . . $ `melder/melder.h:45:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (itemcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
87 }
88 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
89 } catch (MelderErrorcxx . . $ MelderError#) {
90 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no unique categories created.");
91 }
92 }
93
94 void Categories_drawItemcxx . . $ Categories_drawItem(7e16a4411a5ada3f). (Categoriescxx . . $ Categories# me, Graphicscxx . . $ Graphics# g, integercxx . . $ integer# position, double xWC, double yWC) {
95 if (position < 1 || position > mycxx . . $ `melder/melder.h:44:9`! sizecxx . . $ CollectionOf#size.)
96 return;
97 SimpleStringcxx . . $ SimpleString# item = mycxx . . $ `melder/melder.h:44:9`! atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).position];
98 Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (g, xWC, yWC, item -> stringcxx . . $ structSimpleString#string..getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
99 }
100
101 /* TableOfReal_Rowlabels_to_Categories ??? */
102 autoCategoriescxx . . $ autoCategories# TableOfReal_to_CategoriesRowcxx . . $ TableOfReal_to_CategoriesRow(46cceb4d10da413d). (TableOfRealcxx . . $ TableOfReal# me) {
103 try {
104 autoCategoriescxx . . $ autoCategories# thee = Categories_createcxx . . $ Categories_create(8007a1fe88fa0475). ();
105 for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; i ++) {
106 if (mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i]) {
107 autoSimpleStringcxx . . $ autoSimpleString# s = SimpleString_createcxx . . $ SimpleString_create(d4d4ea089a1063c6). (mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
108 thycxx . . $ `melder/melder.h:45:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (scxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
109 }
110 }
111 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
112 } catch (MelderErrorcxx . . $ MelderError#) {
113 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": row labels not converted to Categories.");
114 }
115 }
116
117 autoCategoriescxx . . $ autoCategories# TableOfReal_to_CategoriesColumncxx . . $ TableOfReal_to_CategoriesColumn(46cceb4d10da413d). (TableOfRealcxx . . $ TableOfReal# me) {
118 try {
119 autoCategoriescxx . . $ autoCategories# thee = Categories_createcxx . . $ Categories_create(8007a1fe88fa0475). ();
120 for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; i ++) {
121 if (mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i]) {
122 autoSimpleStringcxx . . $ autoSimpleString# s = SimpleString_createcxx . . $ SimpleString_create(d4d4ea089a1063c6). (mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
123 thycxx . . $ `melder/melder.h:45:9`! addItem_movecxx . . $ CollectionOf#addItem_move(bcc0cff787be24fe). (scxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
124 }
125 }
126 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
127 } catch (MelderErrorcxx . . $ MelderError#) {
128 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": column labels not converted to Categories.");
129 }
130 }
131
132 /* End of file Categories.cpp */