Finale PDK Framework 0.77
Power Up Your Finale Music Software
Loading...
Searching...
No Matches
ff_stream.h
1/*
2 * File: ff_stream.h
3 * Author: Jari Williamsson
4 *
5 * Created on den 23 mars 2012, 21:14
6 *
7 * Contains the stream classes for the Finale PDK Framework.
8 *
9 */
10
11#ifndef FF_STREAM_H
12#define FF_STREAM_H
13
14#ifdef PDK_FRAMEWORK_STREAMS
15
16#include <stdio.h>
17
18// Structs removed from oldpdkstructs.h in F27 pdk
19#if FXT_VERSION > FINALEVERSION_26_3
20#if OPERATING_SYSTEM == WINDOWS
21#include "pragma_align_begin.h"
22class FinPathSpec2009
23{
24// 3/27/02 RES: Yeah, I know: should be private with accessors. But because this
25// file is shared with the PDK, I wanted the class to be self-contained here in
26// its declaration, and I didn't want to created new dependencies by cluttering
27// it with estrncpy()s and the like.
28public:
29 ECHAR path[ MAX_PATHNAME_LENGTH ];
30
31 FinPathSpec2009()
32 {
33 for ( int i = 0; i < sizeof(this->path); i++ )
34 this->path[i] = 0;
35 }
36 ~FinPathSpec2009() {}
37};
38#include "pragma_align_end.h"
39#endif // OPERATING_SYSTEM == WINDOWS
40
41// CFC 03/30/2016: Support for FinPathSpec2012 has been removed from versions of Finale after 2014.5.
42
43#if OPERATING_SYSTEM == WINDOWS
44#include "pragma_align_begin.h"
45class FinPathSpec2012
46{
47 // 3/27/02 RES: Yeah, I know: should be private with accessors. But because this
48 // file is shared with the PDK, I wanted the class to be self-contained here in
49 // its declaration, and I didn't want to created new dependencies by cluttering
50 // it with estrncpy()s and the like.
51public:
52 WCHAR path[ MAX_PATHNAME_LENGTH ];
53
54 FinPathSpec2012()
55 {
56 // 6/27/13 mdg: GCC complains about the use of DIM with this->path,
57 // so since we share with the PDK, use the dimension_of code directly.
58 // 3/14/02 RES: could use memset(), but didn't want to make this file
59 // dependent on any system files
60 for ( int i = 0; i < sizeof(this->path) / sizeof(this->path[0]); i++ )
61 this->path[i] = 0;
62 }
63 ~FinPathSpec2012() {}
64};
65#include "pragma_align_end.h"
66#endif // OPERATING_SYSTEM == WINDOWS
67#endif // FXT_VERSION > FINALEVERSION_26_3
68
69
72{
73public:
75};
76
77
80{
81#if (FXT_VERSION < FINALEVERSION_25 || OPERATING_SYSTEM == WINDOWS)
82 FinPathSpec2009 _folderspec2009;
83#if FXT_VERSION >= FINALEVERSION_2012
84 FinPathSpec2012 _folderspec2012;
85#endif
86#endif
87#if FXT_VERSION >= FINALEVERSION_2025
88 FinPathSpec25 _folderspec2025;
89#endif
90
91 FCString _folder;
92 FCString _filename;
93
94protected:
95#ifndef DOXYGEN_SHOULD_IGNORE_THIS
96 FILE* _pFile;
97 bool _MakeFullPath(FCString* pString);
98#endif /* #ifndef DOXYGEN_SHOULD_IGNORE_THIS */
99public:
102#if FXT_VERSION < FINALEVERSION_2012
103 FinPathSpec2009* pFolder,
104#elif FXT_VERSION < FINALEVERSION_25
105 FinPathSpec2012* pFolder,
106#else
107 FinPathSpec25* pFolder,
108#endif
109 FCString* pFileName) :
111 {
112 _folder.Clear();
113#if (FXT_VERSION < FINALEVERSION_25 || OPERATING_SYSTEM == WINDOWS)
114 switch (FCString::_GetFinPathVersion())
115 {
116 case FINALEVERSION_2009:
117 memcpy(&_folderspec2009, pFolder, sizeof(_folderspec2009));
118 break;
119#if FXT_VERSION >= FINALEVERSION_2012
120 case FINALEVERSION_2012:
121 memcpy(&_folderspec2012, pFolder, sizeof(_folderspec2012));
122 break;
123#endif
124#if FXT_VERSION >= FINALEVERSION_2025
125 case FINALEVERSION_2025:
126 memcpy(&_folderspec2025, pFolder, sizeof(_folderspec2025));
127 break;
128#endif
129 }
130#else
131 // For FinPathSpec25, use assign operator, not memcpy
132 _folderspec2025 = *pFolder;
133#endif
134 _filename.SetString(pFileName);
135 _pFile = NULL;
136 }
137
144 {
145 _folder.SetString(pFolder);
146#if FXT_VERSION < FINALEVERSION_25 || OPERATING_SYSTEM == WINDOWS
147 switch (FCString::_GetFinPathVersion())
148 {
149 case FINALEVERSION_2009:
150 memset(&_folderspec2009, 0, sizeof(_folderspec2009));
151 break;
152#if FXT_VERSION >= FINALEVERSION_2012
153 case FINALEVERSION_2012:
154 memset(&_folderspec2012, 0, sizeof(_folderspec2012));
155 break;
156#endif
157#if FXT_VERSION >= FINALEVERSION_2025
158 case FINALEVERSION_2025:
159 memset(&_folderspec2025, 0, sizeof(_folderspec2025));
160 break;
161#endif
162 }
163#else // Mac FXT_VERSION_25_BASE and greater
164 _folderspec2025.finPathSpecType = 0;
165 _folderspec2025.SetCFURLRef(NULL);
166#endif
167 _filename.SetString(pFileName);
168 _pFile = NULL;
169 }
170
173 {
174 if (_pFile) fclose(_pFile);
175 _pFile = NULL;
176 }
177
179 FILE* _GetFILE() { return _pFile; }
180
182 bool IsOpen() { return (_pFile != NULL); }
183
190 bool OpenFile(
191 WINCODE(const WCHAR* pszMode)
192 MACCODE(const char* pszMode)
193 );
194
196 virtual bool OpenRead() = 0;
197
199 virtual bool OpenWrite() = 0;
200
202 bool Close();
203
205 void GetFullPath(FCString* pString)
206 {
207 if (!_MakeFullPath(pString)) pString->Clear();
208 }
209};
210
211
218{
219public:
221#if FXT_VERSION < FINALEVERSION_2012
222 FCTextFileStream(FinPathSpec2009* pFolder, FCString* pFileName) :
223 FCFileStream(pFolder, pFileName) { }
224#elif FXT_VERSION < FINALEVERSION_25
225 FCTextFileStream(FinPathSpec2012* pFolder, FCString* pFileName) :
226 FCFileStream(pFolder, pFileName) { }
227#else
228 FCTextFileStream(FinPathSpec25* pFolder, FCString* pFileName) :
229 FCFileStream(pFolder, pFileName) { }
230#endif
231
235 FCTextFileStream(FCString* pFolder, FCString* pFileName) :
236 FCFileStream(pFolder, pFileName)
237 {
238 }
239
240 virtual bool OpenRead()
241 {
242 return this->OpenFile(
243 WINCODE(L"r")
244 MACCODE("r")
245 );
246 }
247
248 virtual bool OpenWrite()
249 {
250 return this->OpenFile(
251 WINCODE(L"w+")
252 MACCODE("w+")
253 );
254 }
255
266 virtual FCString* ReadString();
267
274
277 virtual bool WriteStrings(FCStrings *pStrings);
278
282 virtual bool WriteText(FCString *pString);
283
287 virtual bool WriteSettingsPairs(FCSettingsPairs* pPairs);
288};
289
292{
293public:
294 const char* ClassName() const override { return "FCTextFileUTF8Stream"; }
295
297#if FXT_VERSION < FINALEVERSION_2012
298 FCTextFileUTF8Stream(FinPathSpec2009* pFolder, FCString* pFileName) :
299 FCTextFileStream(pFolder, pFileName) { }
300#elif FXT_VERSION < FINALEVERSION_25
301 FCTextFileUTF8Stream(FinPathSpec2012* pFolder, FCString* pFileName) :
302 FCTextFileStream(pFolder, pFileName) { }
303#else
304 FCTextFileUTF8Stream(FinPathSpec25* pFolder, FCString* pFileName) :
305 FCTextFileStream(pFolder, pFileName) { }
306#endif
307
308
310 FCTextFileUTF8Stream(FCString* pFolder, FCString* pFileName) :
311 FCTextFileStream(pFolder, pFileName)
312 {
313 }
314
316 FCString* ReadString() override;
317
320 bool WriteStrings(FCStrings *pStrings) override;
321
325 bool WriteText(FCString *pString) override;
326};
327
328
336{
337 int _instrumentID;
338 int _parentinstrumentID;
339 int _defaultstaffpos;
340 int _generalMIDI;
341 int _groupID;
342 int _copies;
343 bool _copygroup;
344 FCString _name;
345public:
346 const char* ClassName() const override { return "FCPercussionNoteType"; }
347
349 {
350 _instrumentID = 0;
351 _parentinstrumentID = 0;
352 _defaultstaffpos = 0;
353 _generalMIDI = -1;
354 _groupID = 0;
355 _copies = 1;
356 _copygroup = false;
357 }
358
366 void FormatName(FCString* pString, int orderid, int grouporderid);
367
368#ifndef DOXYGEN_SHOULD_IGNORE_THIS
369 void _SetName(FCString* pString) { _name.SetString(pString); }
370
371 void _SetInstrumentID(int theID) { _instrumentID = theID; }
372 void _SetParentInstrumentID(int theID) { _parentinstrumentID = theID; }
373 void _SetDefaultStaffPos(int staffpos) { _defaultstaffpos = staffpos; }
374 void _SetGeneralMIDI(int gmnote) { _generalMIDI = gmnote; }
375 void _SetGroupID(int theID) { _groupID = theID; }
376 void _SetCopies(int count) { _copies = count; }
377 void _SetCopyGroup(bool state) { _copygroup = state; }
378#endif /* #ifndef DOXYGEN_SHOULD_IGNORE_THIS */
379
381 int GetInstrumentID() const { return _instrumentID; }
382
384 int GetParentInstrumentID() const { return _parentinstrumentID; }
385
387 int GetDefaultStaffPos() const { return _defaultstaffpos; }
388
393 int GetGeneralMIDI() const { return _generalMIDI; }
394
396 int GetGroupID() const { return _groupID; }
397
399 int GetCopies() const { return _copies; }
400
402 bool GetCopyGroup() const { return _copygroup; }
403
404
406 bool _IsValid()
407 {
408 if (_instrumentID == 0) return false;
409 if (_groupID == 0) return false;
410 if (_name.IsEmpty()) return false;
411 return true;
412 }
413};
414
422{
423 bool _loaded;
424public:
427 {
428 _loaded = false;
429 }
430
432 bool FileIsAvailable();
433
439 int LoadAll();
440
446 FCPercussionNoteType* FindNoteType(FLAG_16 percnotetype);
447
450
452 bool IsLoaded() { return _loaded; }
453};
454
455
456#endif
457
458#endif /* FF_STREAM_H */
459
Base class for the Finale Framework classes.
Definition ff_base.h:71
__FCBase()
The constructor.
Definition ff_base.h:278
Abstract base class for streams.
Definition ff_stream.h:72
Base class for all collection classes. A collection is a storage that can store multiple objects of s...
Definition ff_basecollection.h:26
__FCBase * GetItemAt(int index) const
Returns the object at the index position. Index is 0-based.
Definition finaleframework.cpp:13767
Generic file stream class.
Definition ff_stream.h:80
FILE * _GetFILE()
For internal use only!
Definition ff_stream.h:179
virtual bool OpenWrite()=0
Opens the file for writing.
bool IsOpen()
Returns true if the file isn't closed.
Definition ff_stream.h:182
FCFileStream(FCString *pFolder, FCString *pFileName)
Constructor - folder string version. (This was a C string version for folders earlier....
Definition ff_stream.h:143
virtual bool OpenRead()=0
Opens the file for reading.
void GetFullPath(FCString *pString)
Fills the full path of the file.
Definition ff_stream.h:205
bool Close()
Closes the file.
Definition finaleframework.cpp:37629
FCFileStream(FinPathSpec25 *pFolder, FCString *pFileName)
The constructor.
Definition ff_stream.h:101
virtual ~FCFileStream()
The destructor.
Definition ff_stream.h:172
bool OpenFile()
Opens the file for a specific mode.
Definition finaleframework.cpp:37607
Class that contains one of Finale's global percussion note type definition.
Definition ff_stream.h:336
int GetDefaultStaffPos() const
Returns the default staff position for the percussion notehead (as a starting point for the perussion...
Definition ff_stream.h:387
int GetInstrumentID() const
Returns the instrument ID.
Definition ff_stream.h:381
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_stream.h:346
int GetGeneralMIDI() const
Returns the general MIDI number for the note, if available.
Definition ff_stream.h:393
int GetCopies() const
Returns the number of groups that the instrument should be copied to.
Definition ff_stream.h:399
int GetGroupID() const
Returns the group ID to where the instrument belongs.
Definition ff_stream.h:396
bool _IsValid()
For internal use only.
Definition ff_stream.h:406
int GetParentInstrumentID() const
Returns the parent instrument ID, which is used if the instrument ID can't be mapped.
Definition ff_stream.h:384
void FormatName(FCString *pString, int orderid, int grouporderid)
Formats a FCString object to produce a printable name for a percussion instrument/sound.
Definition finaleframework.cpp:37867
bool GetCopyGroup() const
Returns true if the instrument should be copied into multiple groups.
Definition ff_stream.h:402
A collection of FCPercussionNoteType objects, created by loading and parsing Finale's PercNoteTypes....
Definition ff_stream.h:422
bool FileIsAvailable()
Returns true if Finale provides a path to the PercNoteTypes.txt file.
Definition finaleframework.cpp:37908
bool IsLoaded()
Returns true if the note types have been loaded successfully.
Definition ff_stream.h:452
FCPercussionNoteTypes()
The constructor.
Definition ff_stream.h:426
int LoadAll()
Loads and parses all the lines in Finale's PercNoteTypes.txt file. The result is a collection of FCPe...
Definition finaleframework.cpp:37915
FCPercussionNoteType * GetItemAt(int index) const
Overridden GetItemAt method.
Definition ff_stream.h:449
FCPercussionNoteType * FindNoteType(FLAG_16 percnotetype)
Finds the a specific note type. If the instrument ID isn't found, the parent instrument ID is searche...
Definition finaleframework.cpp:38031
Collection class for FCSettingsPair objects.
Definition ff_basecollection.h:946
Class that provides storage for text. This is to achieve platform-transparent text handling,...
Definition ff_base.h:1877
void SetString(const FCString *pString)
Copies a string.
Definition finaleframework.cpp:2398
void Clear()
Creates an empty string.
Definition ff_base.h:2391
bool IsEmpty() const
Returns true if the string is empty.
Definition ff_base.h:3179
Collection class for FCString class objects.
Definition ff_basecollection.h:1085
Class for text (byte) streams.
Definition ff_stream.h:218
virtual bool OpenRead()
Opens the file for reading.
Definition ff_stream.h:240
FCTextFileStream(FCString *pFolder, FCString *pFileName)
The constructor. NOTE: This has been changed to FCString in both arguments, since that would seem to ...
Definition ff_stream.h:235
FCStrings * ReadStrings()
Creates a FCStrings collection with all string lines. This might return NULL.
Definition finaleframework.cpp:37743
virtual FCString * ReadString()
Reads the next line from the stream and creates it as a string object. NULL on error.
Definition finaleframework.cpp:37710
virtual bool WriteSettingsPairs(FCSettingsPairs *pPairs)
Writes a collection of settings pairs (with carriage return between each pair). This is an abstract F...
Definition finaleframework.cpp:37782
virtual bool WriteStrings(FCStrings *pStrings)
Writes a collection of strings with a carriage return between the lines. C-string version.
Definition finaleframework.cpp:37762
virtual bool OpenWrite()
Opens the file for writing.
Definition ff_stream.h:248
virtual bool WriteText(FCString *pString)
Writes a text to the stream without any extra formatting. C-string version.
Definition finaleframework.cpp:37774
FCTextFileStream(FinPathSpec25 *pFolder, FCString *pFileName)
The FinPathSpec-based constructor.
Definition ff_stream.h:228
Class for UTF-8text streams.
Definition ff_stream.h:292
const char * ClassName() const override
Returns the name of the class, for diagnostic purposes. This method MUST be overwritten in each child...
Definition ff_stream.h:294
bool WriteText(FCString *pString) override
Writes a text to the stream without any extra formatting. UTF-8 version.
Definition finaleframework.cpp:37816
FCTextFileUTF8Stream(FinPathSpec25 *pFolder, FCString *pFileName)
The FinPathSpec-based constructor.
Definition ff_stream.h:304
FCTextFileUTF8Stream(FCString *pFolder, FCString *pFileName)
The constructor.
Definition ff_stream.h:310
FCString * ReadString() override
Overridden method to support UTF-8 text conversion.
Definition finaleframework.cpp:37824
bool WriteStrings(FCStrings *pStrings) override
Writes a collection of strings with a carriage return between the lines. UTF-8 version.
Definition finaleframework.cpp:37804