Merge pull request #20 from DanielSWolf/feature/refactoring

Various refactorings
This commit is contained in:
Daniel Wolf 2017-09-12 19:35:37 +02:00 committed by GitHub
commit 97a6c74c3c
69 changed files with 592 additions and 384 deletions

View File

@ -239,6 +239,8 @@ set_target_properties(utf8proc PROPERTIES FOLDER lib)
# Define Rhubarb libraries # Define Rhubarb libraries
include_directories("src")
# ... rhubarb-animation # ... rhubarb-animation
add_library(rhubarb-animation add_library(rhubarb-animation
src/animation/animationRules.cpp src/animation/animationRules.cpp
@ -261,7 +263,7 @@ add_library(rhubarb-animation
src/animation/tweening.cpp src/animation/tweening.cpp
src/animation/tweening.h src/animation/tweening.h
) )
target_include_directories(rhubarb-animation PUBLIC "src/animation") target_include_directories(rhubarb-animation PRIVATE "src/animation")
target_link_libraries(rhubarb-animation target_link_libraries(rhubarb-animation
rhubarb-core rhubarb-core
rhubarb-logging rhubarb-logging
@ -288,7 +290,7 @@ add_library(rhubarb-audio
src/audio/waveFileWriting.cpp src/audio/waveFileWriting.cpp
src/audio/waveFileWriting.h src/audio/waveFileWriting.h
) )
target_include_directories(rhubarb-audio PUBLIC "src/audio") target_include_directories(rhubarb-audio PRIVATE "src/audio")
target_link_libraries(rhubarb-audio target_link_libraries(rhubarb-audio
webRtc webRtc
rhubarb-logging rhubarb-logging
@ -306,7 +308,7 @@ add_library(rhubarb-core
src/core/Shape.cpp src/core/Shape.cpp
src/core/Shape.h src/core/Shape.h
) )
target_include_directories(rhubarb-core PUBLIC "src/core") target_include_directories(rhubarb-core PRIVATE "src/core")
target_link_libraries(rhubarb-core target_link_libraries(rhubarb-core
rhubarb-tools rhubarb-tools
) )
@ -323,7 +325,7 @@ add_library(rhubarb-exporters
src/exporters/XmlExporter.cpp src/exporters/XmlExporter.cpp
src/exporters/XmlExporter.h src/exporters/XmlExporter.h
) )
target_include_directories(rhubarb-exporters PUBLIC "src/exporters") target_include_directories(rhubarb-exporters PRIVATE "src/exporters")
target_link_libraries(rhubarb-exporters target_link_libraries(rhubarb-exporters
rhubarb-animation rhubarb-animation
rhubarb-core rhubarb-core
@ -335,7 +337,7 @@ add_library(rhubarb-lib
src/lib/rhubarbLib.cpp src/lib/rhubarbLib.cpp
src/lib/rhubarbLib.h src/lib/rhubarbLib.h
) )
target_include_directories(rhubarb-lib PUBLIC "src/lib") target_include_directories(rhubarb-lib PRIVATE "src/lib")
target_link_libraries(rhubarb-lib target_link_libraries(rhubarb-lib
rhubarb-animation rhubarb-animation
rhubarb-audio rhubarb-audio
@ -347,10 +349,20 @@ target_link_libraries(rhubarb-lib
# ... rhubarb-logging # ... rhubarb-logging
add_library(rhubarb-logging add_library(rhubarb-logging
src/logging/Entry.cpp
src/logging/Entry.h
src/logging/Formatter.h
src/logging/formatters.cpp
src/logging/formatters.h
src/logging/Level.cpp
src/logging/Level.h
src/logging/logging.cpp src/logging/logging.cpp
src/logging/logging.h src/logging/logging.h
src/logging/Sink.h
src/logging/sinks.cpp
src/logging/sinks.h
) )
target_include_directories(rhubarb-logging PUBLIC "src/logging") target_include_directories(rhubarb-logging PRIVATE "src/logging")
target_link_libraries(rhubarb-logging target_link_libraries(rhubarb-logging
rhubarb-tools rhubarb-tools
) )
@ -366,7 +378,7 @@ add_library(rhubarb-recognition
src/recognition/tokenization.cpp src/recognition/tokenization.cpp
src/recognition/tokenization.h src/recognition/tokenization.h
) )
target_include_directories(rhubarb-recognition PUBLIC "src/recognition") target_include_directories(rhubarb-recognition PRIVATE "src/recognition")
target_link_libraries(rhubarb-recognition target_link_libraries(rhubarb-recognition
flite flite
pocketSphinx pocketSphinx
@ -387,7 +399,7 @@ add_library(rhubarb-time
src/time/TimeRange.cpp src/time/TimeRange.cpp
src/time/TimeRange.h src/time/TimeRange.h
) )
target_include_directories(rhubarb-time PUBLIC "src/time") target_include_directories(rhubarb-time PRIVATE "src/time")
target_link_libraries(rhubarb-time target_link_libraries(rhubarb-time
cppFormat cppFormat
rhubarb-logging rhubarb-logging
@ -420,7 +432,7 @@ add_library(rhubarb-tools
src/tools/tools.h src/tools/tools.h
src/tools/tupleHash.h src/tools/tupleHash.h
) )
target_include_directories(rhubarb-tools PUBLIC "src/tools") target_include_directories(rhubarb-tools PRIVATE "src/tools")
target_link_libraries(rhubarb-tools target_link_libraries(rhubarb-tools
cppFormat cppFormat
whereami whereami
@ -430,11 +442,11 @@ target_link_libraries(rhubarb-tools
# Define Rhubarb executable # Define Rhubarb executable
add_executable(rhubarb add_executable(rhubarb
src/main.cpp src/rhubarb/main.cpp
src/ExportFormat.cpp src/rhubarb/ExportFormat.cpp
src/ExportFormat.h src/rhubarb/ExportFormat.h
) )
target_include_directories(rhubarb PUBLIC "src") target_include_directories(rhubarb PUBLIC "src/rhubarb")
target_link_libraries(rhubarb target_link_libraries(rhubarb
rhubarb-exporters rhubarb-exporters
rhubarb-lib rhubarb-lib

87
resharper.DotSettings Normal file
View File

@ -0,0 +1,87 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CTOR_INIT/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue">NONE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">ON_SINGLE_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ENUMERATION_STYLE/@EntryValue">CHOP_ALWAYS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020fields/@EntryIndexedValue">&lt;NamingElement Priority="10"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="class field" /&gt;&lt;type Name="struct field" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="_" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020methods/@EntryIndexedValue">&lt;NamingElement Priority="9"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="member function" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020public_0020fields/@EntryIndexedValue">&lt;NamingElement Priority="11"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="PUBLIC"&gt;&lt;type Name="class field" /&gt;&lt;type Name="struct field" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Classes_0020and_0020structs/@EntryIndexedValue">&lt;NamingElement Priority="1"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="__interface" /&gt;&lt;type Name="class" /&gt;&lt;type Name="struct" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Enum_0020members/@EntryIndexedValue">&lt;NamingElement Priority="13"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="enumerator" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Enums/@EntryIndexedValue">&lt;NamingElement Priority="2"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="enum" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Global_0020constants/@EntryIndexedValue">&lt;NamingElement Priority="15"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="True" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="global variable" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Global_0020functions/@EntryIndexedValue">&lt;NamingElement Priority="8"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="global function" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Global_0020variables/@EntryIndexedValue">&lt;NamingElement Priority="7"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="global variable" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Local_0020variables/@EntryIndexedValue">&lt;NamingElement Priority="6"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="local variable" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Namespaces/@EntryIndexedValue">&lt;NamingElement Priority="16"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="namespace" /&gt;&lt;type Name="namespace alias" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Other_0020constants/@EntryIndexedValue">&lt;NamingElement Priority="14"&gt;&lt;Descriptor Static="True" Constexpr="Indeterminate" Const="True" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="class field" /&gt;&lt;type Name="local variable" /&gt;&lt;type Name="struct field" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Parameters/@EntryIndexedValue">&lt;NamingElement Priority="5"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="parameter" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Template_0020parameters/@EntryIndexedValue">&lt;NamingElement Priority="4"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="template parameter" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Typedefs/@EntryIndexedValue">&lt;NamingElement Priority="17"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="type alias" /&gt;&lt;type Name="typedef" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Union_0020members/@EntryIndexedValue">&lt;NamingElement Priority="12"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="union member" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CppNaming/Rules/=Unions/@EntryIndexedValue">&lt;NamingElement Priority="3"&gt;&lt;Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"&gt;&lt;type Name="union" /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/NamingElement&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FCONSTANT/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FCLASS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FCONSTRUCTOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FGLOBAL_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLABEL/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLOCAL_005FCONSTRUCTOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLOCAL_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FOBJECT_005FPROPERTY_005FOF_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FPARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FCLASS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FENUM/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FENUM_005FMEMBER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FINTERFACE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMIXED_005FENUM/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMODULE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMODULE_005FEXPORTED/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMODULE_005FLOCAL/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FMEMBER_005FACCESSOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FSTATIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FTYPE_005FMETHOD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FMEMBER_005FACCESSOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FSTATIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FTYPE_005FMETHOD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FMEMBER_005FACCESSOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FSTATIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FTYPE_005FMETHOD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FTYPE_005FALIAS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FTYPE_005FPARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FHTML_005FCONTROL/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FTAG_005FNAME/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FTAG_005FPREFIX/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=NAMESPACE_005FALIAS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FRESOURCE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECpp_002ECodeStyle_002ESettingsUpgrade_002EFunctionReturnStyleSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECpp_002ECodeStyle_002ESettingsUpgrade_002ENamespaceIndentationSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>

View File

@ -1,6 +1,6 @@
#include "ShapeRule.h" #include "ShapeRule.h"
#include <boost/range/adaptor/transformed.hpp> #include <boost/range/adaptor/transformed.hpp>
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
using boost::optional; using boost::optional;
using boost::adaptors::transformed; using boost::adaptors::transformed;

View File

@ -1,9 +1,10 @@
#pragma once #pragma once
#include "Phone.h" #include "core/Phone.h"
#include "animationRules.h" #include "animationRules.h"
#include "BoundedTimeline.h" #include "time/BoundedTimeline.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
#include "time/TimeRange.h"
struct ShapeRule { struct ShapeRule {
ShapeSet shapeSet; ShapeSet shapeSet;

View File

@ -1,8 +1,8 @@
#include "animationRules.h" #include "animationRules.h"
#include <boost/algorithm/clamp.hpp> #include <boost/algorithm/clamp.hpp>
#include "shapeShorthands.h" #include "shapeShorthands.h"
#include "array.h" #include "tools/array.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
using std::chrono::duration_cast; using std::chrono::duration_cast;
using boost::algorithm::clamp; using boost::algorithm::clamp;

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <set> #include <set>
#include "Shape.h" #include "core/Shape.h"
#include "Timeline.h" #include "time/Timeline.h"
#include "Phone.h" #include "core/Phone.h"
// Returns the basic shape (A-F) that most closely resembles the specified shape. // Returns the basic shape (A-F) that most closely resembles the specified shape.
Shape getBasicShape(Shape shape); Shape getBasicShape(Shape shape);

View File

@ -1,5 +1,5 @@
#include "mouthAnimation.h" #include "mouthAnimation.h"
#include "timedLogging.h" #include "time/timedLogging.h"
#include "ShapeRule.h" #include "ShapeRule.h"
#include "roughAnimation.h" #include "roughAnimation.h"
#include "pauseAnimation.h" #include "pauseAnimation.h"

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include "Phone.h" #include "core/Phone.h"
#include "Shape.h" #include "core/Shape.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
#include "targetShapeSet.h" #include "targetShapeSet.h"
JoiningContinuousTimeline<Shape> animate(const BoundedTimeline<Phone>& phones, const ShapeSet& targetShapeSet); JoiningContinuousTimeline<Shape> animate(const BoundedTimeline<Phone>& phones, const ShapeSet& targetShapeSet);

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "Shape.h" #include "core/Shape.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
// Takes an existing animation and modifies the pauses (X shapes) to look better. // Takes an existing animation and modifies the pauses (X shapes) to look better.
JoiningContinuousTimeline<Shape> animatePauses(const JoiningContinuousTimeline<Shape>& animation); JoiningContinuousTimeline<Shape> animatePauses(const JoiningContinuousTimeline<Shape>& animation);

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "Shape.h" #include "core/Shape.h"
constexpr Shape A = Shape::A; constexpr Shape A = Shape::A;
constexpr Shape B = Shape::B; constexpr Shape B = Shape::B;

View File

@ -1,7 +1,7 @@
#include "staticSegments.h" #include "staticSegments.h"
#include <vector> #include <vector>
#include <numeric> #include <numeric>
#include "nextCombination.h" #include "tools/nextCombination.h"
using std::vector; using std::vector;
using boost::optional; using boost::optional;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "Shape.h" #include "core/Shape.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
#include "ShapeRule.h" #include "ShapeRule.h"
#include <functional> #include <functional>

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "Shape.h" #include "core/Shape.h"
#include "ShapeRule.h" #include "ShapeRule.h"
// Returns the closest shape to the specified one that occurs in the target shape set. // Returns the closest shape to the specified one that occurs in the target shape set.

View File

@ -1,5 +1,5 @@
#include "timingOptimization.h" #include "timingOptimization.h"
#include "timedLogging.h" #include "time/timedLogging.h"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <map> #include <map>
#include <algorithm> #include <algorithm>

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "Shape.h" #include "core/Shape.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
// Changes the timing of an existing animation to reduce jitter and to make sure all shapes register visually. // Changes the timing of an existing animation to reduce jitter and to make sure all shapes register visually.
// In some cases, shapes may be omitted. // In some cases, shapes may be omitted.

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "Shape.h" #include "core/Shape.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
// Takes an existing animation and inserts inbetween shapes for smoother results. // Takes an existing animation and inserts inbetween shapes for smoother results.
JoiningContinuousTimeline<Shape> insertTweens(const JoiningContinuousTimeline<Shape>& animation); JoiningContinuousTimeline<Shape> insertTweens(const JoiningContinuousTimeline<Shape>& animation);

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include "TimeRange.h" #include "time/TimeRange.h"
#include <functional> #include <functional>
#include "Lazy.h" #include "tools/Lazy.h"
class AudioClip; class AudioClip;
class SampleIterator; class SampleIterator;

View File

@ -2,7 +2,7 @@
#include <string.h> #include <string.h>
#include "WaveFileReader.h" #include "WaveFileReader.h"
#include "ioTools.h" #include "ioTools.h"
#include "platformTools.h" #include "tools/platformTools.h"
using std::runtime_error; using std::runtime_error;
using fmt::format; using fmt::format;

View File

@ -3,7 +3,7 @@
#include <vector> #include <vector>
#include <functional> #include <functional>
#include "AudioClip.h" #include "AudioClip.h"
#include "ProgressBar.h" #include "tools/ProgressBar.h"
void process16bitAudioClip(const AudioClip& audioClip, std::function<void(const std::vector<int16_t>&)> processBuffer, size_t bufferCapacity, ProgressSink& progressSink); void process16bitAudioClip(const AudioClip& audioClip, std::function<void(const std::vector<int16_t>&)> processBuffer, size_t bufferCapacity, ProgressSink& progressSink);
void process16bitAudioClip(const AudioClip& audioClip, std::function<void(const std::vector<int16_t>&)> processBuffer, ProgressSink& progressSink); void process16bitAudioClip(const AudioClip& audioClip, std::function<void(const std::vector<int16_t>&)> processBuffer, ProgressSink& progressSink);

View File

@ -1,15 +1,15 @@
#include "voiceActivityDetection.h" #include "voiceActivityDetection.h"
#include "DcOffset.h" #include "DcOffset.h"
#include "SampleRateConverter.h" #include "SampleRateConverter.h"
#include "logging.h" #include "logging/logging.h"
#include "pairs.h" #include "tools/pairs.h"
#include <boost/range/adaptor/transformed.hpp> #include <boost/range/adaptor/transformed.hpp>
#include <webrtc/common_audio/vad/include/webrtc_vad.h> #include <webrtc/common_audio/vad/include/webrtc_vad.h>
#include "processing.h" #include "processing.h"
#include <gsl_util.h> #include <gsl_util.h>
#include "parallel.h" #include "tools/parallel.h"
#include "AudioSegment.h" #include "AudioSegment.h"
#include "stringTools.h" #include "tools/stringTools.h"
using std::vector; using std::vector;
using boost::adaptors::transformed; using boost::adaptors::transformed;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "AudioClip.h" #include "AudioClip.h"
#include <BoundedTimeline.h> #include "time/BoundedTimeline.h"
#include <ProgressBar.h> #include "tools/ProgressBar.h"
JoiningBoundedTimeline<void> detectVoiceActivity(const AudioClip& audioClip, int maxThreadCount, ProgressSink& progressSink); JoiningBoundedTimeline<void> detectVoiceActivity(const AudioClip& audioClip, int maxThreadCount, ProgressSink& progressSink);

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "EnumConverter.h" #include "tools/EnumConverter.h"
// Defines a subset of the Arpabet // Defines a subset of the Arpabet
enum class Phone { enum class Phone {

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "EnumConverter.h" #include "tools/EnumConverter.h"
#include <set> #include <set>
// The classic Hanna-Barbera mouth shapes A-F plus the common supplements G-H // The classic Hanna-Barbera mouth shapes A-F plus the common supplements G-H

View File

@ -1,11 +1,26 @@
#pragma once #pragma once
#include <Shape.h> #include "core/Shape.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
class ExporterInput {
public:
ExporterInput(
const boost::filesystem::path& inputFilePath,
const JoiningContinuousTimeline<Shape>& animation,
const ShapeSet& targetShapeSet) :
inputFilePath(inputFilePath),
animation(animation),
targetShapeSet(targetShapeSet) {}
boost::filesystem::path inputFilePath;
JoiningContinuousTimeline<Shape> animation;
ShapeSet targetShapeSet;
};
class Exporter { class Exporter {
public: public:
virtual ~Exporter() {} virtual ~Exporter() {}
virtual void exportAnimation(const boost::filesystem::path& inputFilePath, const JoiningContinuousTimeline<Shape>& animation, const ShapeSet& targetShapeSet, std::ostream& outputStream) = 0; virtual void exportAnimation(const ExporterInput& input, std::ostream& outputStream) = 0;
}; };

View File

@ -1,50 +1,20 @@
#include "JsonExporter.h" #include "JsonExporter.h"
#include "exporterTools.h" #include "exporterTools.h"
#include <utf8.h> #include "tools/stringTools.h"
using std::string; using std::string;
string escapeJsonString(const string& s) { void JsonExporter::exportAnimation(const ExporterInput& input, std::ostream& outputStream) {
// JavaScript uses UTF-16 internally. As a result, character escaping in JSON strings is UTF-16-based.
// Convert string to UTF-16
std::u16string utf16String;
utf8::utf8to16(s.begin(), s.end(), std::back_inserter(utf16String));
string result;
for (char16_t c : utf16String) {
switch (c) {
case '"': result += "\\\""; break;
case '\\': result += "\\\\"; break;
case '\b': result += "\\b"; break;
case '\f': result += "\\f"; break;
case '\n': result += "\\n"; break;
case '\r': result += "\\r"; break;
case '\t': result += "\\t"; break;
default:
{
bool needsEscaping = c < '\x20' || c >= 0x80;
if (needsEscaping) {
result += fmt::format("\\u{0:04x}", c);
} else {
result += static_cast<char>(c);
}
}
}
}
return result;
}
void JsonExporter::exportAnimation(const boost::filesystem::path& inputFilePath, const JoiningContinuousTimeline<Shape>& animation, const ShapeSet& targetShapeSet, std::ostream& outputStream) {
// Export as JSON. // Export as JSON.
// I'm not using a library because the code is short enough without one and it lets me control the formatting. // I'm not using a library because the code is short enough without one and it lets me control the formatting.
outputStream << "{\n"; outputStream << "{\n";
outputStream << " \"metadata\": {\n"; outputStream << " \"metadata\": {\n";
outputStream << " \"soundFile\": \"" << escapeJsonString(inputFilePath.string()) << "\",\n"; outputStream << " \"soundFile\": \"" << escapeJsonString(input.inputFilePath.string()) << "\",\n";
outputStream << " \"duration\": " << formatDuration(animation.getRange().getDuration()) << "\n"; outputStream << " \"duration\": " << formatDuration(input.animation.getRange().getDuration()) << "\n";
outputStream << " },\n"; outputStream << " },\n";
outputStream << " \"mouthCues\": [\n"; outputStream << " \"mouthCues\": [\n";
bool isFirst = true; bool isFirst = true;
for (auto& timedShape : dummyShapeIfEmpty(animation, targetShapeSet)) { for (auto& timedShape : dummyShapeIfEmpty(input.animation, input.targetShapeSet)) {
if (!isFirst) outputStream << ",\n"; if (!isFirst) outputStream << ",\n";
isFirst = false; isFirst = false;
outputStream << " { \"start\": " << formatDuration(timedShape.getStart()) outputStream << " { \"start\": " << formatDuration(timedShape.getStart())

View File

@ -4,5 +4,5 @@
class JsonExporter : public Exporter { class JsonExporter : public Exporter {
public: public:
void exportAnimation(const boost::filesystem::path& inputFilePath, const JoiningContinuousTimeline<Shape>& animation, const ShapeSet& targetShapeSet, std::ostream& outputStream) override; void exportAnimation(const ExporterInput& input, std::ostream& outputStream) override;
}; };

View File

@ -1,14 +1,16 @@
#include "TsvExporter.h" #include "TsvExporter.h"
#include "targetShapeSet.h" #include "animation/targetShapeSet.h"
void TsvExporter::exportAnimation(const boost::filesystem::path& inputFilePath, const JoiningContinuousTimeline<Shape>& animation, const ShapeSet& targetShapeSet, std::ostream& outputStream) {
UNUSED(inputFilePath);
void TsvExporter::exportAnimation(const ExporterInput& input, std::ostream& outputStream) {
// Output shapes with start times // Output shapes with start times
for (auto& timedShape : animation) { for (auto& timedShape : input.animation) {
outputStream << formatDuration(timedShape.getStart()) << "\t" << timedShape.getValue() << "\n"; outputStream << formatDuration(timedShape.getStart()) << "\t" << timedShape.getValue() << "\n";
} }
// Output closed mouth with end time // Output closed mouth with end time
outputStream << formatDuration(animation.getRange().getEnd()) << "\t" << convertToTargetShapeSet(Shape::X, targetShapeSet) << "\n"; outputStream
<< formatDuration(input.animation.getRange().getEnd())
<< "\t"
<< convertToTargetShapeSet(Shape::X, input.targetShapeSet)
<< "\n";
} }

View File

@ -4,6 +4,6 @@
class TsvExporter : public Exporter { class TsvExporter : public Exporter {
public: public:
void exportAnimation(const boost::filesystem::path& inputFilePath, const JoiningContinuousTimeline<Shape>& animation, const ShapeSet& targetShapeSet, std::ostream& outputStream) override; void exportAnimation(const ExporterInput& input, std::ostream& outputStream) override;
}; };

View File

@ -7,22 +7,22 @@
using std::string; using std::string;
using boost::property_tree::ptree; using boost::property_tree::ptree;
void XmlExporter::exportAnimation(const boost::filesystem::path& inputFilePath, const JoiningContinuousTimeline<Shape>& animation, const ShapeSet& targetShapeSet, std::ostream& outputStream) { void XmlExporter::exportAnimation(const ExporterInput& input, std::ostream& outputStream) {
ptree tree; ptree tree;
// Add metadata // Add metadata
tree.put("rhubarbResult.metadata.soundFile", inputFilePath.string()); tree.put("rhubarbResult.metadata.soundFile", input.inputFilePath.string());
tree.put("rhubarbResult.metadata.duration", formatDuration(animation.getRange().getDuration())); tree.put("rhubarbResult.metadata.duration", formatDuration(input.animation.getRange().getDuration()));
// Add mouth cues // Add mouth cues
for (auto& timedShape : dummyShapeIfEmpty(animation, targetShapeSet)) { for (auto& timedShape : dummyShapeIfEmpty(input.animation, input.targetShapeSet)) {
ptree& mouthCueElement = tree.add("rhubarbResult.mouthCues.mouthCue", timedShape.getValue()); ptree& mouthCueElement = tree.add("rhubarbResult.mouthCues.mouthCue", timedShape.getValue());
mouthCueElement.put("<xmlattr>.start", formatDuration(timedShape.getStart())); mouthCueElement.put("<xmlattr>.start", formatDuration(timedShape.getStart()));
mouthCueElement.put("<xmlattr>.end", formatDuration(timedShape.getEnd())); mouthCueElement.put("<xmlattr>.end", formatDuration(timedShape.getEnd()));
} }
#ifndef BOOST_VERSION //present in version.hpp #ifndef BOOST_VERSION //present in version.hpp
#error "Could not detect Boost version." #error "Could not detect Boost version."
#endif #endif
#if BOOST_VERSION < 105600 // Support legacy syntax #if BOOST_VERSION < 105600 // Support legacy syntax

View File

@ -4,5 +4,5 @@
class XmlExporter : public Exporter { class XmlExporter : public Exporter {
public: public:
void exportAnimation(const boost::filesystem::path& inputFilePath, const JoiningContinuousTimeline<Shape>& animation, const ShapeSet& targetShapeSet, std::ostream& outputStream) override; void exportAnimation(const ExporterInput& input, std::ostream& outputStream) override;
}; };

View File

@ -1,5 +1,5 @@
#include "exporterTools.h" #include "exporterTools.h"
#include "targetShapeSet.h" #include "animation/targetShapeSet.h"
// Makes sure there is at least one mouth shape // Makes sure there is at least one mouth shape
std::vector<Timed<Shape>> dummyShapeIfEmpty(const JoiningTimeline<Shape>& animation, const ShapeSet& targetShapeSet) { std::vector<Timed<Shape>> dummyShapeIfEmpty(const JoiningTimeline<Shape>& animation, const ShapeSet& targetShapeSet) {

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "Shape.h" #include "core/Shape.h"
#include "Timeline.h" #include "time/Timeline.h"
// Makes sure there is at least one mouth shape // Makes sure there is at least one mouth shape
std::vector<Timed<Shape>> dummyShapeIfEmpty(const JoiningTimeline<Shape>& animation, const ShapeSet& targetShapeSet); std::vector<Timed<Shape>> dummyShapeIfEmpty(const JoiningTimeline<Shape>& animation, const ShapeSet& targetShapeSet);

View File

@ -1,9 +1,9 @@
#include "rhubarbLib.h" #include "rhubarbLib.h"
#include "Phone.h" #include "core/Phone.h"
#include "phoneRecognition.h" #include "recognition/phoneRecognition.h"
#include "textFiles.h" #include "tools/textFiles.h"
#include "mouthAnimation.h" #include "animation/mouthAnimation.h"
#include "WaveFileReader.h" #include "audio/WaveFileReader.h"
using boost::optional; using boost::optional;
using std::string; using std::string;

View File

@ -1,11 +1,11 @@
#pragma once #pragma once
#include "Shape.h" #include "core/Shape.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
#include "AudioClip.h" #include "audio/AudioClip.h"
#include "ProgressBar.h" #include "tools/ProgressBar.h"
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include "targetShapeSet.h" #include "animation/targetShapeSet.h"
JoiningContinuousTimeline<Shape> animateAudioClip( JoiningContinuousTimeline<Shape> animateAudioClip(
const AudioClip& audioClip, const AudioClip& audioClip,

38
src/logging/Entry.cpp Normal file
View File

@ -0,0 +1,38 @@
#include "Entry.h"
#include <thread>
#include <mutex>
#include <unordered_map>
using std::lock_guard;
using std::unordered_map;
using std::string;
namespace logging {
// Returns an int representing the current thread.
// This used to be a simple thread_local variable, but Xcode doesn't support that yet
int getThreadCounter() {
using thread_id = std::thread::id;
static std::mutex counterMutex;
lock_guard<std::mutex> lock(counterMutex);
static unordered_map<thread_id, int> threadCounters;
static int lastThreadId = 0;
thread_id threadId = std::this_thread::get_id();
if (threadCounters.find(threadId) == threadCounters.end()) {
threadCounters.insert({threadId, ++lastThreadId});
}
return threadCounters.find(threadId)->second;
}
Entry::Entry(Level level, const string& message) :
level(level),
message(message)
{
time(&timestamp);
this->threadCounter = getThreadCounter();
}
}

16
src/logging/Entry.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include "Level.h"
namespace logging {
struct Entry {
Entry(Level level, const std::string& message);
time_t timestamp;
int threadCounter;
Level level;
std::string message;
};
}

14
src/logging/Formatter.h Normal file
View File

@ -0,0 +1,14 @@
#pragma once
#include <string>
#include "Entry.h"
namespace logging {
class Formatter {
public:
virtual ~Formatter() = default;
virtual std::string format(const Entry& entry) = 0;
};
}

35
src/logging/Level.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "Level.h"
using std::string;
namespace logging {
LevelConverter& LevelConverter::get() {
static LevelConverter converter;
return converter;
}
string LevelConverter::getTypeName() {
return "Level";
}
EnumConverter<Level>::member_data LevelConverter::getMemberData() {
return member_data{
{Level::Trace, "Trace"},
{Level::Debug, "Debug"},
{Level::Info, "Info"},
{Level::Warn, "Warn"},
{Level::Error, "Error"},
{Level::Fatal, "Fatal"}
};
}
std::ostream& operator<<(std::ostream& stream, Level value) {
return LevelConverter::get().write(stream, value);
}
std::istream& operator >> (std::istream& stream, Level& value) {
return LevelConverter::get().read(stream, value);
}
}

29
src/logging/Level.h Normal file
View File

@ -0,0 +1,29 @@
#pragma once
#include "tools/EnumConverter.h"
namespace logging {
enum class Level {
Trace,
Debug,
Info,
Warn,
Error,
Fatal,
EndSentinel
};
class LevelConverter : public EnumConverter<Level> {
public:
static LevelConverter& get();
protected:
std::string getTypeName() override;
member_data getMemberData() override;
};
std::ostream& operator<<(std::ostream& stream, Level value);
std::istream& operator >> (std::istream& stream, Level& value);
}

13
src/logging/Sink.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include "Entry.h"
namespace logging {
class Sink {
public:
virtual ~Sink() = default;
virtual void receive(const Entry& entry) = 0;
};
}

View File

@ -0,0 +1,18 @@
#include "formatters.h"
#include <format.h>
#include "Entry.h"
#include "tools/tools.h"
using std::string;
namespace logging {
string SimpleConsoleFormatter::format(const Entry& entry) {
return fmt::format("[{0}] {1}", entry.level, entry.message);
}
string SimpleFileFormatter::format(const Entry& entry) {
return fmt::format("[{0}] {1} {2}", formatTime(entry.timestamp, "%F %H:%M:%S"), entry.threadCounter, consoleFormatter.format(entry));
}
}

19
src/logging/formatters.h Normal file
View File

@ -0,0 +1,19 @@
#pragma once
#include "Formatter.h"
namespace logging {
class SimpleConsoleFormatter : public Formatter {
public:
std::string format(const Entry& entry) override;
};
class SimpleFileFormatter : public Formatter {
public:
std::string format(const Entry& entry) override;
private:
SimpleConsoleFormatter consoleFormatter;
};
}

View File

@ -1,130 +1,13 @@
#include "logging.h" #include "logging.h"
#include <tools.h> #include "tools/tools.h"
#include <iostream> #include <mutex>
#include <atomic> #include "Entry.h"
#include <thread>
#include <unordered_map>
using namespace logging; using namespace logging;
using std::string; using std::string;
using std::vector; using std::vector;
using std::shared_ptr; using std::shared_ptr;
using std::lock_guard; using std::lock_guard;
using std::unordered_map;
LevelConverter& LevelConverter::get() {
static LevelConverter converter;
return converter;
}
string LevelConverter::getTypeName() {
return "Level";
}
EnumConverter<Level>::member_data LevelConverter::getMemberData() {
return member_data {
{ Level::Trace, "Trace" },
{ Level::Debug, "Debug" },
{ Level::Info, "Info" },
{ Level::Warn, "Warn" },
{ Level::Error, "Error" },
{ Level::Fatal, "Fatal" }
};
}
std::ostream& logging::operator<<(std::ostream& stream, Level value) {
return LevelConverter::get().write(stream, value);
}
std::istream& logging::operator>>(std::istream& stream, Level& value) {
return LevelConverter::get().read(stream, value);
}
// Returns an int representing the current thread.
// This used to be a simple thread_local variable, but Xcode doesn't support that yet
int getThreadCounter() {
using thread_id = std::thread::id;
static std::mutex counterMutex;
lock_guard<std::mutex> lock(counterMutex);
static unordered_map<thread_id, int> threadCounters;
static int lastThreadId = 0;
thread_id threadId = std::this_thread::get_id();
if (threadCounters.find(threadId) == threadCounters.end()) {
threadCounters.insert({threadId, ++lastThreadId});
}
return threadCounters.find(threadId)->second;
}
Entry::Entry(Level level, const string& message) :
level(level),
message(message)
{
time(&timestamp);
this->threadCounter = getThreadCounter();
}
string SimpleConsoleFormatter::format(const Entry& entry) {
return fmt::format("[{0}] {1}", entry.level, entry.message);
}
string SimpleFileFormatter::format(const Entry& entry) {
return fmt::format("[{0}] {1} {2}", formatTime(entry.timestamp, "%F %H:%M:%S"), entry.threadCounter, consoleFormatter.format(entry));
}
LevelFilter::LevelFilter(shared_ptr<Sink> innerSink, Level minLevel) :
innerSink(innerSink),
minLevel(minLevel)
{}
void LevelFilter::receive(const Entry& entry) {
if (entry.level >= minLevel) {
innerSink->receive(entry);
}
}
StreamSink::StreamSink(shared_ptr<std::ostream> stream, shared_ptr<Formatter> formatter) :
stream(stream),
formatter(formatter)
{}
void StreamSink::receive(const Entry& entry) {
string line = formatter->format(entry);
*stream << line << std::endl;
}
StdErrSink::StdErrSink(shared_ptr<Formatter> formatter) :
StreamSink(std::shared_ptr<std::ostream>(&std::cerr, [](void*) {}), formatter)
{}
PausableSink::PausableSink(shared_ptr<Sink> innerSink) :
innerSink(innerSink)
{}
void PausableSink::receive(const Entry& entry) {
lock_guard<std::mutex> lock(mutex);
if (isPaused) {
buffer.push_back(entry);
} else {
innerSink->receive(entry);
}
}
void PausableSink::pause() {
lock_guard<std::mutex> lock(mutex);
isPaused = true;
}
void PausableSink::resume() {
lock_guard<std::mutex> lock(mutex);
isPaused = false;
for (const Entry& entry : buffer) {
innerSink->receive(entry);
}
buffer.clear();
}
std::mutex& getLogMutex() { std::mutex& getLogMutex() {
static std::mutex mutex; static std::mutex mutex;

View File

@ -1,103 +1,11 @@
#pragma once #pragma once
#include <vector> #include "tools/EnumConverter.h"
#include <mutex> #include "Sink.h"
#include "tools.h" #include "Level.h"
#include "EnumConverter.h"
namespace logging { namespace logging {
enum class Level {
Trace,
Debug,
Info,
Warn,
Error,
Fatal,
EndSentinel
};
class LevelConverter : public EnumConverter<Level> {
public:
static LevelConverter& get();
protected:
std::string getTypeName() override;
member_data getMemberData() override;
};
std::ostream& operator<<(std::ostream& stream, Level value);
std::istream& operator>>(std::istream& stream, Level& value);
struct Entry {
Entry(Level level, const std::string& message);
time_t timestamp;
int threadCounter;
Level level;
std::string message;
};
class Formatter {
public:
virtual ~Formatter() = default;
virtual std::string format(const Entry& entry) = 0;
};
class SimpleConsoleFormatter : public Formatter {
public:
std::string format(const Entry& entry) override;
};
class SimpleFileFormatter : public Formatter {
public:
std::string format(const Entry& entry) override;
private:
SimpleConsoleFormatter consoleFormatter;
};
class Sink {
public:
virtual ~Sink() = default;
virtual void receive(const Entry& entry) = 0;
};
class LevelFilter : public Sink {
public:
LevelFilter(std::shared_ptr<Sink> innerSink, Level minLevel);
void receive(const Entry& entry) override;
private:
std::shared_ptr<Sink> innerSink;
Level minLevel;
};
class StreamSink : public Sink {
public:
StreamSink(std::shared_ptr<std::ostream> stream, std::shared_ptr<Formatter> formatter);
void receive(const Entry& entry) override;
private:
std::shared_ptr<std::ostream> stream;
std::shared_ptr<Formatter> formatter;
};
class StdErrSink : public StreamSink {
public:
explicit StdErrSink(std::shared_ptr<Formatter> formatter);
};
class PausableSink : public Sink {
public:
explicit PausableSink(std::shared_ptr<Sink> innerSink);
void receive(const Entry& entry) override;
void pause();
void resume();
private:
std::shared_ptr<Sink> innerSink;
std::vector<Entry> buffer;
std::mutex mutex;
bool isPaused = false;
};
void addSink(std::shared_ptr<Sink> sink); void addSink(std::shared_ptr<Sink> sink);
void log(Level level, const std::string& message); void log(Level level, const std::string& message);

64
src/logging/sinks.cpp Normal file
View File

@ -0,0 +1,64 @@
#include "sinks.h"
#include <iostream>
#include "Entry.h"
using std::string;
using std::lock_guard;
using std::shared_ptr;
namespace logging {
LevelFilter::LevelFilter(shared_ptr<Sink> innerSink, Level minLevel) :
innerSink(innerSink),
minLevel(minLevel)
{}
void LevelFilter::receive(const Entry& entry) {
if (entry.level >= minLevel) {
innerSink->receive(entry);
}
}
StreamSink::StreamSink(shared_ptr<std::ostream> stream, shared_ptr<Formatter> formatter) :
stream(stream),
formatter(formatter)
{}
void StreamSink::receive(const Entry& entry) {
string line = formatter->format(entry);
*stream << line << std::endl;
}
StdErrSink::StdErrSink(shared_ptr<Formatter> formatter) :
StreamSink(std::shared_ptr<std::ostream>(&std::cerr, [](void*) {}), formatter)
{}
PausableSink::PausableSink(shared_ptr<Sink> innerSink) :
innerSink(innerSink)
{}
void PausableSink::receive(const Entry& entry) {
lock_guard<std::mutex> lock(mutex);
if (isPaused) {
buffer.push_back(entry);
} else {
innerSink->receive(entry);
}
}
void PausableSink::pause() {
lock_guard<std::mutex> lock(mutex);
isPaused = true;
}
void PausableSink::resume() {
lock_guard<std::mutex> lock(mutex);
isPaused = false;
for (const Entry& entry : buffer) {
innerSink->receive(entry);
}
buffer.clear();
}
}

48
src/logging/sinks.h Normal file
View File

@ -0,0 +1,48 @@
#pragma once
#include "Sink.h"
#include <memory>
#include "Formatter.h"
#include <vector>
#include <mutex>
namespace logging {
enum class Level;
class LevelFilter : public Sink {
public:
LevelFilter(std::shared_ptr<Sink> innerSink, Level minLevel);
void receive(const Entry& entry) override;
private:
std::shared_ptr<Sink> innerSink;
Level minLevel;
};
class StreamSink : public Sink {
public:
StreamSink(std::shared_ptr<std::ostream> stream, std::shared_ptr<Formatter> formatter);
void receive(const Entry& entry) override;
private:
std::shared_ptr<std::ostream> stream;
std::shared_ptr<Formatter> formatter;
};
class StdErrSink : public StreamSink {
public:
explicit StdErrSink(std::shared_ptr<Formatter> formatter);
};
class PausableSink : public Sink {
public:
explicit PausableSink(std::shared_ptr<Sink> innerSink);
void receive(const Entry& entry) override;
void pause();
void resume();
private:
std::shared_ptr<Sink> innerSink;
std::vector<Entry> buffer;
std::mutex mutex;
bool isPaused = false;
};
}

View File

@ -1,7 +1,7 @@
#include <g2p.h> #include <g2p.h>
#include <regex> #include <regex>
#include "stringTools.h" #include "tools/stringTools.h"
#include "logging.h" #include "logging/logging.h"
using std::vector; using std::vector;
using std::wstring; using std::wstring;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include "Phone.h" #include "core/Phone.h"
std::vector<Phone> wordToPhones(const std::string& word); std::vector<Phone> wordToPhones(const std::string& word);

View File

@ -4,9 +4,9 @@
#include <regex> #include <regex>
#include <map> #include <map>
#include <tuple> #include <tuple>
#include "platformTools.h" #include "tools/platformTools.h"
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include "appInfo.h" #include "core/appInfo.h"
#include <cmath> #include <cmath>
#include <gsl_util.h> #include <gsl_util.h>

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include "tools.h" #include "tools/tools.h"
extern "C" { extern "C" {
#include <pocketsphinx.h> #include <pocketsphinx.h>

View File

@ -1,26 +1,26 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include "phoneRecognition.h" #include "phoneRecognition.h"
#include "SampleRateConverter.h" #include "audio/SampleRateConverter.h"
#include "platformTools.h" #include "tools/platformTools.h"
#include "tools.h" #include "tools/tools.h"
#include <format.h> #include <format.h>
#include <s3types.h> #include <s3types.h>
#include <regex> #include <regex>
#include <gsl_util.h> #include <gsl_util.h>
#include <logging.h> #include "logging/logging.h"
#include "DcOffset.h" #include "audio/DcOffset.h"
#include "Timeline.h" #include "time/Timeline.h"
#include "voiceActivityDetection.h" #include "audio/voiceActivityDetection.h"
#include "AudioSegment.h" #include "audio/AudioSegment.h"
#include "languageModels.h" #include "languageModels.h"
#include "tokenization.h" #include "tokenization.h"
#include "g2p.h" #include "g2p.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
#include "processing.h" #include "audio/processing.h"
#include "parallel.h" #include "tools/parallel.h"
#include <boost/version.hpp> #include <boost/version.hpp>
#include "ObjectPool.h" #include "tools/ObjectPool.h"
#include "timedLogging.h" #include "time/timedLogging.h"
extern "C" { extern "C" {
#include <pocketsphinx.h> #include <pocketsphinx.h>

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include "AudioClip.h" #include "audio/AudioClip.h"
#include "Phone.h" #include "core/Phone.h"
#include "ProgressBar.h" #include "tools/ProgressBar.h"
#include "BoundedTimeline.h" #include "time/BoundedTimeline.h"
BoundedTimeline<Phone> recognizePhones( BoundedTimeline<Phone> recognizePhones(
const AudioClip& audioClip, const AudioClip& audioClip,

View File

@ -1,6 +1,6 @@
#include "tokenization.h" #include "tokenization.h"
#include "tools.h" #include "tools/tools.h"
#include "stringTools.h" #include "tools/stringTools.h"
#include <regex> #include <regex>
extern "C" { extern "C" {

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "EnumConverter.h" #include "tools/EnumConverter.h"
enum class ExportFormat { enum class ExportFormat {
Tsv, Tsv,

View File

@ -1,30 +1,32 @@
#include <iostream> #include <iostream>
#include <format.h> #include <format.h>
#include <tclap/CmdLine.h> #include <tclap/CmdLine.h>
#include "appInfo.h" #include "core/appInfo.h"
#include "NiceCmdLineOutput.h" #include "tools/NiceCmdLineOutput.h"
#include "ProgressBar.h" #include "tools/ProgressBar.h"
#include "logging.h" #include "logging/logging.h"
#include "logging/sinks.h"
#include "logging/formatters.h"
#include <gsl_util.h> #include <gsl_util.h>
#include "Exporter.h" #include "exporters/Exporter.h"
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#include "stringTools.h" #include "tools/stringTools.h"
#include <boost/range/adaptor/transformed.hpp> #include <boost/range/adaptor/transformed.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include "parallel.h" #include "tools/parallel.h"
#include "exceptions.h" #include "tools/exceptions.h"
#include "textFiles.h" #include "tools/textFiles.h"
#include "rhubarbLib.h" #include "lib/rhubarbLib.h"
#include "ExportFormat.h" #include "ExportFormat.h"
#include "TsvExporter.h" #include "exporters/TsvExporter.h"
#include "XmlExporter.h" #include "exporters/XmlExporter.h"
#include "JsonExporter.h" #include "exporters/JsonExporter.h"
#include <boost/iostreams/stream.hpp> #include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/null.hpp> #include <boost/iostreams/device/null.hpp>
#include "targetShapeSet.h" #include "animation/targetShapeSet.h"
#include <boost/utility/in_place_factory.hpp> #include <boost/utility/in_place_factory.hpp>
#include "platformTools.h" #include "tools/platformTools.h"
using std::exception; using std::exception;
using std::string; using std::string;
@ -184,7 +186,8 @@ int main(int platformArgc, char *platformArgv[]) {
outputFile = boost::in_place(outputFileName.getValue()); outputFile = boost::in_place(outputFileName.getValue());
outputFile->exceptions(std::ifstream::failbit | std::ifstream::badbit); outputFile->exceptions(std::ifstream::failbit | std::ifstream::badbit);
} }
exporter->exportAnimation(inputFilePath, animation, targetShapeSet, outputFile ? *outputFile : std::cout); ExporterInput exporterInput = ExporterInput(inputFilePath, animation, targetShapeSet);
exporter->exportAnimation(exporterInput, outputFile ? *outputFile : std::cout);
logging::info("Exiting application normally."); logging::info("Exiting application normally.");
} catch (...) { } catch (...) {

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <TimeRange.h> #include "time/TimeRange.h"
#include <iostream> #include <iostream>
template<typename TValue> template<typename TValue>

View File

@ -3,7 +3,7 @@
#include <set> #include <set>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <type_traits> #include <type_traits>
#include "tools.h" #include "tools/tools.h"
enum class FindMode { enum class FindMode {
SampleLeft, SampleLeft,

View File

@ -3,7 +3,7 @@
#include "centiseconds.h" #include "centiseconds.h"
#include "TimeRange.h" #include "TimeRange.h"
#include "Timed.h" #include "Timed.h"
#include "logging.h" #include "logging/logging.h"
template<typename TValue> template<typename TValue>
void logTimedEvent(const std::string& eventName, const Timed<TValue> timedValue) { void logTimedEvent(const std::string& eventName, const Timed<TValue> timedValue) {

View File

@ -3,6 +3,7 @@
#include <utf8.h> #include <utf8.h>
#include <utf8proc.h> #include <utf8proc.h>
#include <regex> #include <regex>
#include <format.h>
using std::string; using std::string;
using std::wstring; using std::wstring;
@ -157,3 +158,33 @@ string normalizeUnicode(const string s, NormalizationOptions options) {
free(result); free(result);
return resultString; return resultString;
} }
string escapeJsonString(const string& s) {
// JavaScript uses UTF-16 internally. As a result, character escaping in JSON strings is UTF-16-based.
// Convert string to UTF-16
std::u16string utf16String;
utf8::utf8to16(s.begin(), s.end(), std::back_inserter(utf16String));
string result;
for (char16_t c : utf16String) {
switch (c) {
case '"': result += "\\\""; break;
case '\\': result += "\\\\"; break;
case '\b': result += "\\b"; break;
case '\f': result += "\\f"; break;
case '\n': result += "\\n"; break;
case '\r': result += "\\r"; break;
case '\t': result += "\\t"; break;
default:
{
bool needsEscaping = c < '\x20' || c >= 0x80;
if (needsEscaping) {
result += fmt::format("\\u{0:04x}", c);
} else {
result += static_cast<char>(c);
}
}
}
}
return result;
}

View File

@ -48,3 +48,5 @@ std::string join(T range, const std::string separator) {
} }
return result; return result;
} }
std::string escapeJsonString(const std::string& s);

View File

@ -1,5 +1,5 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "BoundedTimeline.h" #include "time/BoundedTimeline.h"
using namespace testing; using namespace testing;
using std::vector; using std::vector;

View File

@ -1,5 +1,5 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "ContinuousTimeline.h" #include "time/ContinuousTimeline.h"
using namespace testing; using namespace testing;
using std::vector; using std::vector;

View File

@ -1,5 +1,5 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "Lazy.h" #include "tools/Lazy.h"
using namespace testing; using namespace testing;
using std::make_unique; using std::make_unique;

View File

@ -1,5 +1,5 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "Timeline.h" #include "time/Timeline.h"
#include <limits> #include <limits>
#include <functional> #include <functional>

View File

@ -1,5 +1,5 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "g2p.h" #include "recognition/g2p.h"
using namespace testing; using namespace testing;
using std::vector; using std::vector;

View File

@ -1,5 +1,5 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "pairs.h" #include "tools/pairs.h"
using namespace testing; using namespace testing;
using std::vector; using std::vector;

View File

@ -1,5 +1,5 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "stringTools.h" #include "tools/stringTools.h"
using namespace testing; using namespace testing;
using std::string; using std::string;

View File

@ -1,5 +1,5 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "tokenization.h" #include "recognition/tokenization.h"
#include <regex> #include <regex>
#include <unordered_set> #include <unordered_set>
#include <utf8.h> #include <utf8.h>