Verovio
Source code documentation
vrv.h
1 // Name: vrv.h
3 // Author: Laurent Pugin
4 // Created: 2013
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_H__
9 #define __VRV_H__
10 
11 #include <cstdarg>
12 #include <cstdio>
13 #include <cstring>
14 #include <map>
15 #include <string>
16 #include <unordered_map>
17 #include <vector>
18 
19 #ifndef _WIN32
20 #include <sys/time.h>
21 #else
22 #include <time.h>
23 #endif
24 
25 #include "attdef.h"
26 #include "atttypes.h"
27 #include "toolkitdef.h"
28 #include "vrvdef.h"
29 
30 namespace vrv {
31 
32 class Object;
38 void LogDebug(const char *fmt, ...);
39 void LogError(const char *fmt, ...);
40 void LogInfo(const char *fmt, ...);
41 void LogWarning(const char *fmt, ...);
42 
46 extern std::vector<std::string> logBuffer;
47 bool LogBufferContains(const std::string &s);
48 void LogString(std::string message, LogLevel level);
49 
53 LogLevel StrToLogLevel(const std::string &level);
54 
58 bool ApproximatelyEqual(double firstVal, double secondVal);
59 
63 bool IsValidInteger(const std::string &value);
64 
68 bool IsValidDouble(const std::string &value);
69 
73 bool IsDigits(const std::string &value);
74 
78 std::string ExtractIDFragment(std::string refID);
79 
83 std::string ConcatenateIDs(const ListOfConstObjects &objects);
84 
88 std::string UTF32to8(const std::u32string &in);
89 
93 std::u32string UTF8to32(const std::string &in);
94 
98 std::string UTF16to8(const std::u16string &in);
99 
104 std::string StringFormat(const char *fmt, ...);
105 // This is the implementation callable with variable arguments
106 std::string StringFormatVariable(const char *format, va_list arg);
107 
112 std::string GetFileVersion(int vmaj, int vmin, int vrev);
113 
117 std::string GetFilename(std::string fullpath);
118 
122 std::string GetVersion();
123 
128 std::string BaseEncodeInt(uint32_t value, uint8_t base);
129 
133 std::string FromCamelCase(const std::string &s);
134 
138 std::string ToCamelCase(const std::string &s);
139 
143 inline data_DURATION DurationMin(data_DURATION dur1, data_DURATION dur2)
144 {
145  return std::min(dur1, dur2);
146 }
147 inline data_DURATION DurationMax(data_DURATION dur1, data_DURATION dur2)
148 {
149  return std::max(dur1, dur2);
150 }
151 
155 extern LogLevel logLevel;
156 extern bool loggingToBuffer;
157 
169 extern struct timeval start;
170 void LogElapsedTimeStart();
171 void LogElapsedTimeStop(const char *msg = "unspecified operation");
172 
173 //----------------------------------------------------------------------------
174 // Notation type checks
175 //----------------------------------------------------------------------------
176 
177 bool IsMensuralType(data_NOTATIONTYPE notationType);
178 bool IsNeumeType(data_NOTATIONTYPE notationType);
179 bool IsTabType(data_NOTATIONTYPE notationType);
180 
181 //----------------------------------------------------------------------------
182 // Base64 code borrowed
183 //----------------------------------------------------------------------------
184 
185 std::string Base64Encode(unsigned char const *bytesToEncode, unsigned int len);
186 std::vector<unsigned char> Base64Decode(std::string const &encodedString);
187 
188 } // namespace vrv
189 
190 #endif