Merge doep branch to trunk.

This commit is contained in:
Daniel Önnerby 2008-07-19 11:54:45 +00:00
parent ce5cd4206b
commit 817fdad434
145 changed files with 31134 additions and 7831 deletions

View File

@ -2,8 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mC2", "src\cube\cube.vcproj", "{1CA67D31-E7D4-4377-93F2-FD15BF95D21F}"
ProjectSection(ProjectDependencies) = postProject
{E618F29F-BF28-441A-B039-9E10A631D881} = {E618F29F-BF28-441A-B039-9E10A631D881}
{B2165720-B4B2-4F4B-9634-8C390C3CB4DB} = {B2165720-B4B2-4F4B-9634-8C390C3CB4DB}
{E618F29F-BF28-441A-B039-9E10A631D881} = {E618F29F-BF28-441A-B039-9E10A631D881}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "win32cpp", "src\win32cpp\win32cpp.vcproj", "{E618F29F-BF28-441A-B039-9E10A631D881}"
@ -14,9 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "src\core\core.vcpro
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "taglib_plugin", "src\contrib\taglib_plugin\taglib_plugin.vcproj", "{7CD00EC4-D090-48BE-9388-FA4857AC332C}"
ProjectSection(ProjectDependencies) = postProject
{1CA67D31-E7D4-4377-93F2-FD15BF95D21F} = {1CA67D31-E7D4-4377-93F2-FD15BF95D21F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "3rdparty", "src\3rdparty\3rdparty.vcproj", "{B2165720-B4B2-4F4B-8888-8C390C3CB4DB}"
EndProject
@ -39,6 +36,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "square", "src\square\player
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "waveout", "src\contrib\waveout\waveout.vcproj", "{4F10C17A-8AF7-4FAC-A4E2-087AE6E8F9D8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "daemon", "src\daemon\daemon.vcproj", "{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}"
ProjectSection(ProjectDependencies) = postProject
{B2165720-B4B2-4F4B-9634-8C390C3CB4DB} = {B2165720-B4B2-4F4B-9634-8C390C3CB4DB}
{B2165720-B4B2-4F4B-8888-8C390C3CB4DB} = {B2165720-B4B2-4F4B-8888-8C390C3CB4DB}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -93,6 +96,10 @@ Global
{4F10C17A-8AF7-4FAC-A4E2-087AE6E8F9D8}.Debug|Win32.Build.0 = Debug|Win32
{4F10C17A-8AF7-4FAC-A4E2-087AE6E8F9D8}.Release|Win32.ActiveCfg = Release|Win32
{4F10C17A-8AF7-4FAC-A4E2-087AE6E8F9D8}.Release|Win32.Build.0 = Release|Win32
{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}.Debug|Win32.ActiveCfg = Debug|Win32
{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}.Debug|Win32.Build.0 = Debug|Win32
{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}.Release|Win32.ActiveCfg = Release|Win32
{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -39,8 +39,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="./include/;./include/sqlite/"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;SQLITE_THREADSAFE"
AdditionalIncludeDirectories="./include/;./include/sqlite/;./include/expat"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;SQLITE_THREADSAFE;COMPILED_FROM_DSP;XML_STATIC"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
@ -104,8 +104,8 @@
Optimization="2"
InlineFunctionExpansion="0"
FavorSizeOrSpeed="0"
AdditionalIncludeDirectories="./include/;./include/sqlite/"
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;SQLITE_THREADSAFE"
AdditionalIncludeDirectories="./include/;./include/sqlite/;./include/expat"
PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_DEPRECATE;SQLITE_THREADSAFE;COMPILED_FROM_DSP;XML_STATIC"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
PrecompiledHeaderThrough="pch.hpp"
@ -183,6 +183,82 @@
>
</File>
</Filter>
<Filter
Name="expat"
>
<File
RelativePath=".\include\expat\ascii.h"
>
</File>
<File
RelativePath=".\include\expat\asciitab.h"
>
</File>
<File
RelativePath=".\include\expat\expat.h"
>
</File>
<File
RelativePath=".\include\expat\expat_external.h"
>
</File>
<File
RelativePath=".\include\expat\iasciitab.h"
>
</File>
<File
RelativePath=".\include\expat\internal.h"
>
</File>
<File
RelativePath=".\include\expat\latin1tab.h"
>
</File>
<File
RelativePath=".\include\expat\nametab.h"
>
</File>
<File
RelativePath=".\include\expat\utf8tab.h"
>
</File>
<File
RelativePath=".\include\expat\winconfig.h"
>
</File>
<File
RelativePath=".\src\expat\xmlparse.c"
>
</File>
<File
RelativePath=".\src\expat\xmlrole.c"
>
</File>
<File
RelativePath=".\include\expat\xmlrole.h"
>
</File>
<File
RelativePath=".\src\expat\xmltok.c"
>
</File>
<File
RelativePath=".\include\expat\xmltok.h"
>
</File>
<File
RelativePath=".\src\expat\xmltok_impl.c"
>
</File>
<File
RelativePath=".\include\expat\xmltok_impl.h"
>
</File>
<File
RelativePath=".\src\expat\xmltok_ns.c"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>

View File

@ -0,0 +1,32 @@
#ifndef AMIGACONFIG_H
#define AMIGACONFIG_H
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
#define BYTEORDER 4321
/* Define to 1 if you have the `bcopy' function. */
#define HAVE_BCOPY 1
/* Define to 1 if you have the <check.h> header file. */
#undef HAVE_CHECK_H
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* whether byteorder is bigendian */
#define WORDS_BIGENDIAN
/* Define to specify how much context to retain around the current parse
point. */
#define XML_CONTEXT_BYTES 1024
/* Define to make parameter entity parsing functionality available. */
#define XML_DTD
/* Define to make XML Namespaces functionality available. */
#define XML_NS
#endif /* AMIGACONFIG_H */

92
src/3rdparty/include/expat/ascii.h vendored Normal file
View File

@ -0,0 +1,92 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
#define ASCII_A 0x41
#define ASCII_B 0x42
#define ASCII_C 0x43
#define ASCII_D 0x44
#define ASCII_E 0x45
#define ASCII_F 0x46
#define ASCII_G 0x47
#define ASCII_H 0x48
#define ASCII_I 0x49
#define ASCII_J 0x4A
#define ASCII_K 0x4B
#define ASCII_L 0x4C
#define ASCII_M 0x4D
#define ASCII_N 0x4E
#define ASCII_O 0x4F
#define ASCII_P 0x50
#define ASCII_Q 0x51
#define ASCII_R 0x52
#define ASCII_S 0x53
#define ASCII_T 0x54
#define ASCII_U 0x55
#define ASCII_V 0x56
#define ASCII_W 0x57
#define ASCII_X 0x58
#define ASCII_Y 0x59
#define ASCII_Z 0x5A
#define ASCII_a 0x61
#define ASCII_b 0x62
#define ASCII_c 0x63
#define ASCII_d 0x64
#define ASCII_e 0x65
#define ASCII_f 0x66
#define ASCII_g 0x67
#define ASCII_h 0x68
#define ASCII_i 0x69
#define ASCII_j 0x6A
#define ASCII_k 0x6B
#define ASCII_l 0x6C
#define ASCII_m 0x6D
#define ASCII_n 0x6E
#define ASCII_o 0x6F
#define ASCII_p 0x70
#define ASCII_q 0x71
#define ASCII_r 0x72
#define ASCII_s 0x73
#define ASCII_t 0x74
#define ASCII_u 0x75
#define ASCII_v 0x76
#define ASCII_w 0x77
#define ASCII_x 0x78
#define ASCII_y 0x79
#define ASCII_z 0x7A
#define ASCII_0 0x30
#define ASCII_1 0x31
#define ASCII_2 0x32
#define ASCII_3 0x33
#define ASCII_4 0x34
#define ASCII_5 0x35
#define ASCII_6 0x36
#define ASCII_7 0x37
#define ASCII_8 0x38
#define ASCII_9 0x39
#define ASCII_TAB 0x09
#define ASCII_SPACE 0x20
#define ASCII_EXCL 0x21
#define ASCII_QUOT 0x22
#define ASCII_AMP 0x26
#define ASCII_APOS 0x27
#define ASCII_MINUS 0x2D
#define ASCII_PERIOD 0x2E
#define ASCII_COLON 0x3A
#define ASCII_SEMI 0x3B
#define ASCII_LT 0x3C
#define ASCII_EQUALS 0x3D
#define ASCII_GT 0x3E
#define ASCII_LSQB 0x5B
#define ASCII_RSQB 0x5D
#define ASCII_UNDERSCORE 0x5F
#define ASCII_LPAREN 0x28
#define ASCII_RPAREN 0x29
#define ASCII_FF 0x0C
#define ASCII_SLASH 0x2F
#define ASCII_HASH 0x23
#define ASCII_PIPE 0x7C
#define ASCII_COMMA 0x2C

36
src/3rdparty/include/expat/asciitab.h vendored Normal file
View File

@ -0,0 +1,36 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,

1014
src/3rdparty/include/expat/expat.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
#ifndef Expat_External_INCLUDED
#define Expat_External_INCLUDED 1
/* External API definitions */
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
#define XML_USE_MSC_EXTENSIONS 1
#endif
/* Expat tries very hard to make the API boundary very specifically
defined. There are two macros defined to control this boundary;
each of these can be defined before including this header to
achieve some different behavior, but doing so it not recommended or
tested frequently.
XMLCALL - The calling convention to use for all calls across the
"library boundary." This will default to cdecl, and
try really hard to tell the compiler that's what we
want.
XMLIMPORT - Whatever magic is needed to note that a function is
to be imported from a dynamically loaded library
(.dll, .so, or .sl, depending on your platform).
The XMLCALL macro was added in Expat 1.95.7. The only one which is
expected to be directly useful in client code is XMLCALL.
Note that on at least some Unix versions, the Expat library must be
compiled with the cdecl calling convention as the default since
system headers may assume the cdecl convention.
*/
#ifndef XMLCALL
#if defined(_MSC_VER)
#define XMLCALL __cdecl
#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
#define XMLCALL __attribute__((cdecl))
#else
/* For any platform which uses this definition and supports more than
one calling convention, we need to extend this definition to
declare the convention used on that platform, if it's possible to
do so.
If this is the case for your platform, please file a bug report
with information on how to identify your platform via the C
pre-processor and how to specify the same calling convention as the
platform's malloc() implementation.
*/
#define XMLCALL
#endif
#endif /* not defined XMLCALL */
#if !defined(XML_STATIC) && !defined(XMLIMPORT)
#ifndef XML_BUILDING_EXPAT
/* using Expat from an application */
#ifdef XML_USE_MSC_EXTENSIONS
#define XMLIMPORT __declspec(dllimport)
#endif
#endif
#endif /* not defined XML_STATIC */
/* If we didn't define it above, define it away: */
#ifndef XMLIMPORT
#define XMLIMPORT
#endif
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
#ifdef __cplusplus
extern "C" {
#endif
#ifdef XML_UNICODE_WCHAR_T
#define XML_UNICODE
#endif
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
#ifdef XML_UNICODE_WCHAR_T
typedef wchar_t XML_Char;
typedef wchar_t XML_LChar;
#else
typedef unsigned short XML_Char;
typedef char XML_LChar;
#endif /* XML_UNICODE_WCHAR_T */
#else /* Information is UTF-8 encoded. */
typedef char XML_Char;
typedef char XML_LChar;
#endif /* XML_UNICODE */
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
typedef __int64 XML_Index;
typedef unsigned __int64 XML_Size;
#else
typedef long long XML_Index;
typedef unsigned long long XML_Size;
#endif
#else
typedef long XML_Index;
typedef unsigned long XML_Size;
#endif /* XML_LARGE_SIZE */
#ifdef __cplusplus
}
#endif
#endif /* not Expat_External_INCLUDED */

37
src/3rdparty/include/expat/iasciitab.h vendored Normal file
View File

@ -0,0 +1,37 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,

73
src/3rdparty/include/expat/internal.h vendored Normal file
View File

@ -0,0 +1,73 @@
/* internal.h
Internal definitions used by Expat. This is not needed to compile
client code.
The following calling convention macros are defined for frequently
called functions:
FASTCALL - Used for those internal functions that have a simple
body and a low number of arguments and local variables.
PTRCALL - Used for functions called though function pointers.
PTRFASTCALL - Like PTRCALL, but for low number of arguments.
inline - Used for selected internal functions for which inlining
may improve performance on some platforms.
Note: Use of these macros is based on judgement, not hard rules,
and therefore subject to change.
*/
#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__)
/* We'll use this version by default only where we know it helps.
regparm() generates warnings on Solaris boxes. See SF bug #692878.
Instability reported with egcs on a RedHat Linux 7.3.
Let's comment out:
#define FASTCALL __attribute__((stdcall, regparm(3)))
and let's try this:
*/
#define FASTCALL __attribute__((regparm(3)))
#define PTRFASTCALL __attribute__((regparm(3)))
#endif
/* Using __fastcall seems to have an unexpected negative effect under
MS VC++, especially for function pointers, so we won't use it for
now on that platform. It may be reconsidered for a future release
if it can be made more effective.
Likely reason: __fastcall on Windows is like stdcall, therefore
the compiler cannot perform stack optimizations for call clusters.
*/
/* Make sure all of these are defined if they aren't already. */
#ifndef FASTCALL
#define FASTCALL
#endif
#ifndef PTRCALL
#define PTRCALL
#endif
#ifndef PTRFASTCALL
#define PTRFASTCALL
#endif
#ifndef XML_MIN_SIZE
#if !defined(__cplusplus) && !defined(inline)
#ifdef __GNUC__
#define inline __inline
#endif /* __GNUC__ */
#endif
#endif /* XML_MIN_SIZE */
#ifdef __cplusplus
#define inline inline
#else
#ifndef inline
#define inline
#endif
#endif

36
src/3rdparty/include/expat/latin1tab.h vendored Normal file
View File

@ -0,0 +1,36 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,

53
src/3rdparty/include/expat/macconfig.h vendored Normal file
View File

@ -0,0 +1,53 @@
/*================================================================
** Copyright 2000, Clark Cooper
** All rights reserved.
**
** This is free software. You are permitted to copy, distribute, or modify
** it under the terms of the MIT/X license (contained in the COPYING file
** with this distribution.)
**
*/
#ifndef MACCONFIG_H
#define MACCONFIG_H
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
#define BYTEORDER 4321
/* Define to 1 if you have the `bcopy' function. */
#undef HAVE_BCOPY
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* whether byteorder is bigendian */
#define WORDS_BIGENDIAN
/* Define to specify how much context to retain around the current parse
point. */
#undef XML_CONTEXT_BYTES
/* Define to make parameter entity parsing functionality available. */
#define XML_DTD
/* Define to make XML Namespaces functionality available. */
#define XML_NS
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `long' if <sys/types.h> does not define. */
#define off_t long
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
#endif /* ifndef MACCONFIG_H */

150
src/3rdparty/include/expat/nametab.h vendored Normal file
View File

@ -0,0 +1,150 @@
static const unsigned namingBitmap[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
0x40000000, 0xF580C900, 0x00000007, 0x02010800,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
0x00000000, 0x00004C40, 0x00000000, 0x00000000,
0x00000007, 0x00000000, 0x00000000, 0x00000000,
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
};
static const unsigned char nmstrtPages[] = {
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char namePages[] = {
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

37
src/3rdparty/include/expat/utf8tab.h vendored Normal file
View File

@ -0,0 +1,37 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,

View File

@ -0,0 +1,47 @@
/* expat_config.h for use with Open Watcom 1.5 and above. */
#ifndef WATCOMCONFIG_H
#define WATCOMCONFIG_H
#ifdef __NT__
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#endif
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
#define BYTEORDER 1234
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "expat-bugs@mail.libexpat.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "expat"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "expat 2.0.0"
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.0.0"
/* Define to specify how much context to retain around the current parse
point. */
#define XML_CONTEXT_BYTES 1024
/* Define to make parameter entity parsing functionality available. */
#define XML_DTD 1
/* Define to make XML Namespaces functionality available. */
#define XML_NS 1
#endif

30
src/3rdparty/include/expat/winconfig.h vendored Normal file
View File

@ -0,0 +1,30 @@
/*================================================================
** Copyright 2000, Clark Cooper
** All rights reserved.
**
** This is free software. You are permitted to copy, distribute, or modify
** it under the terms of the MIT/X license (contained in the COPYING file
** with this distribution.)
*/
#ifndef WINCONFIG_H
#define WINCONFIG_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <memory.h>
#include <string.h>
#define XML_NS 1
#define XML_DTD 1
#define XML_CONTEXT_BYTES 1024
/* we will assume all Windows platforms are little endian */
#define BYTEORDER 1234
/* Windows has memmove() available. */
#define HAVE_MEMMOVE
#endif /* ndef WINCONFIG_H */

114
src/3rdparty/include/expat/xmlrole.h vendored Normal file
View File

@ -0,0 +1,114 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
#ifndef XmlRole_INCLUDED
#define XmlRole_INCLUDED 1
#ifdef __VMS
/* 0 1 2 3 0 1 2 3
1234567890123456789012345678901 1234567890123456789012345678901 */
#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
#endif
#include "xmltok.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
XML_ROLE_ERROR = -1,
XML_ROLE_NONE = 0,
XML_ROLE_XML_DECL,
XML_ROLE_INSTANCE_START,
XML_ROLE_DOCTYPE_NONE,
XML_ROLE_DOCTYPE_NAME,
XML_ROLE_DOCTYPE_SYSTEM_ID,
XML_ROLE_DOCTYPE_PUBLIC_ID,
XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
XML_ROLE_DOCTYPE_CLOSE,
XML_ROLE_GENERAL_ENTITY_NAME,
XML_ROLE_PARAM_ENTITY_NAME,
XML_ROLE_ENTITY_NONE,
XML_ROLE_ENTITY_VALUE,
XML_ROLE_ENTITY_SYSTEM_ID,
XML_ROLE_ENTITY_PUBLIC_ID,
XML_ROLE_ENTITY_COMPLETE,
XML_ROLE_ENTITY_NOTATION_NAME,
XML_ROLE_NOTATION_NONE,
XML_ROLE_NOTATION_NAME,
XML_ROLE_NOTATION_SYSTEM_ID,
XML_ROLE_NOTATION_NO_SYSTEM_ID,
XML_ROLE_NOTATION_PUBLIC_ID,
XML_ROLE_ATTRIBUTE_NAME,
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
XML_ROLE_ATTRIBUTE_TYPE_ID,
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
XML_ROLE_ATTLIST_NONE,
XML_ROLE_ATTLIST_ELEMENT_NAME,
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
XML_ROLE_ELEMENT_NONE,
XML_ROLE_ELEMENT_NAME,
XML_ROLE_CONTENT_ANY,
XML_ROLE_CONTENT_EMPTY,
XML_ROLE_CONTENT_PCDATA,
XML_ROLE_GROUP_OPEN,
XML_ROLE_GROUP_CLOSE,
XML_ROLE_GROUP_CLOSE_REP,
XML_ROLE_GROUP_CLOSE_OPT,
XML_ROLE_GROUP_CLOSE_PLUS,
XML_ROLE_GROUP_CHOICE,
XML_ROLE_GROUP_SEQUENCE,
XML_ROLE_CONTENT_ELEMENT,
XML_ROLE_CONTENT_ELEMENT_REP,
XML_ROLE_CONTENT_ELEMENT_OPT,
XML_ROLE_CONTENT_ELEMENT_PLUS,
XML_ROLE_PI,
XML_ROLE_COMMENT,
#ifdef XML_DTD
XML_ROLE_TEXT_DECL,
XML_ROLE_IGNORE_SECT,
XML_ROLE_INNER_PARAM_ENTITY_REF,
#endif /* XML_DTD */
XML_ROLE_PARAM_ENTITY_REF
};
typedef struct prolog_state {
int (PTRCALL *handler) (struct prolog_state *state,
int tok,
const char *ptr,
const char *end,
const ENCODING *enc);
unsigned level;
int role_none;
#ifdef XML_DTD
unsigned includeLevel;
int documentEntity;
int inEntityValue;
#endif /* XML_DTD */
} PROLOG_STATE;
void XmlPrologStateInit(PROLOG_STATE *);
#ifdef XML_DTD
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
#endif /* XML_DTD */
#define XmlTokenRole(state, tok, ptr, end, enc) \
(((state)->handler)(state, tok, ptr, end, enc))
#ifdef __cplusplus
}
#endif
#endif /* not XmlRole_INCLUDED */

316
src/3rdparty/include/expat/xmltok.h vendored Normal file
View File

@ -0,0 +1,316 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
#ifndef XmlTok_INCLUDED
#define XmlTok_INCLUDED 1
#ifdef __cplusplus
extern "C" {
#endif
/* The following token may be returned by XmlContentTok */
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be
start of illegal ]]> sequence */
/* The following tokens may be returned by both XmlPrologTok and
XmlContentTok.
*/
#define XML_TOK_NONE -4 /* The string to be scanned is empty */
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
might be part of CRLF sequence */
#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
#define XML_TOK_PARTIAL -1 /* only part of a token */
#define XML_TOK_INVALID 0
/* The following tokens are returned by XmlContentTok; some are also
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
*/
#define XML_TOK_START_TAG_WITH_ATTS 1
#define XML_TOK_START_TAG_NO_ATTS 2
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
#define XML_TOK_END_TAG 5
#define XML_TOK_DATA_CHARS 6
#define XML_TOK_DATA_NEWLINE 7
#define XML_TOK_CDATA_SECT_OPEN 8
#define XML_TOK_ENTITY_REF 9
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
/* The following tokens may be returned by both XmlPrologTok and
XmlContentTok.
*/
#define XML_TOK_PI 11 /* processing instruction */
#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
#define XML_TOK_COMMENT 13
#define XML_TOK_BOM 14 /* Byte order mark */
/* The following tokens are returned only by XmlPrologTok */
#define XML_TOK_PROLOG_S 15
#define XML_TOK_DECL_OPEN 16 /* <!foo */
#define XML_TOK_DECL_CLOSE 17 /* > */
#define XML_TOK_NAME 18
#define XML_TOK_NMTOKEN 19
#define XML_TOK_POUND_NAME 20 /* #name */
#define XML_TOK_OR 21 /* | */
#define XML_TOK_PERCENT 22
#define XML_TOK_OPEN_PAREN 23
#define XML_TOK_CLOSE_PAREN 24
#define XML_TOK_OPEN_BRACKET 25
#define XML_TOK_CLOSE_BRACKET 26
#define XML_TOK_LITERAL 27
#define XML_TOK_PARAM_ENTITY_REF 28
#define XML_TOK_INSTANCE_START 29
/* The following occur only in element type declarations */
#define XML_TOK_NAME_QUESTION 30 /* name? */
#define XML_TOK_NAME_ASTERISK 31 /* name* */
#define XML_TOK_NAME_PLUS 32 /* name+ */
#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
#define XML_TOK_COMMA 38
/* The following token is returned only by XmlAttributeValueTok */
#define XML_TOK_ATTRIBUTE_VALUE_S 39
/* The following token is returned only by XmlCdataSectionTok */
#define XML_TOK_CDATA_SECT_CLOSE 40
/* With namespace processing this is returned by XmlPrologTok for a
name with a colon.
*/
#define XML_TOK_PREFIXED_NAME 41
#ifdef XML_DTD
#define XML_TOK_IGNORE_SECT 42
#endif /* XML_DTD */
#ifdef XML_DTD
#define XML_N_STATES 4
#else /* not XML_DTD */
#define XML_N_STATES 3
#endif /* not XML_DTD */
#define XML_PROLOG_STATE 0
#define XML_CONTENT_STATE 1
#define XML_CDATA_SECTION_STATE 2
#ifdef XML_DTD
#define XML_IGNORE_SECTION_STATE 3
#endif /* XML_DTD */
#define XML_N_LITERAL_TYPES 2
#define XML_ATTRIBUTE_VALUE_LITERAL 0
#define XML_ENTITY_VALUE_LITERAL 1
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
#define XML_UTF8_ENCODE_MAX 4
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
#define XML_UTF16_ENCODE_MAX 2
typedef struct position {
/* first line and first column are 0 not 1 */
XML_Size lineNumber;
XML_Size columnNumber;
} POSITION;
typedef struct {
const char *name;
const char *valuePtr;
const char *valueEnd;
char normalized;
} ATTRIBUTE;
struct encoding;
typedef struct encoding ENCODING;
typedef int (PTRCALL *SCANNER)(const ENCODING *,
const char *,
const char *,
const char **);
struct encoding {
SCANNER scanners[XML_N_STATES];
SCANNER literalScanners[XML_N_LITERAL_TYPES];
int (PTRCALL *sameName)(const ENCODING *,
const char *,
const char *);
int (PTRCALL *nameMatchesAscii)(const ENCODING *,
const char *,
const char *,
const char *);
int (PTRFASTCALL *nameLength)(const ENCODING *, const char *);
const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
int (PTRCALL *getAtts)(const ENCODING *enc,
const char *ptr,
int attsMax,
ATTRIBUTE *atts);
int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
int (PTRCALL *predefinedEntityName)(const ENCODING *,
const char *,
const char *);
void (PTRCALL *updatePosition)(const ENCODING *,
const char *ptr,
const char *end,
POSITION *);
int (PTRCALL *isPublicId)(const ENCODING *enc,
const char *ptr,
const char *end,
const char **badPtr);
void (PTRCALL *utf8Convert)(const ENCODING *enc,
const char **fromP,
const char *fromLim,
char **toP,
const char *toLim);
void (PTRCALL *utf16Convert)(const ENCODING *enc,
const char **fromP,
const char *fromLim,
unsigned short **toP,
const unsigned short *toLim);
int minBytesPerChar;
char isUtf8;
char isUtf16;
};
/* Scan the string starting at ptr until the end of the next complete
token, but do not scan past eptr. Return an integer giving the
type of token.
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
Return XML_TOK_PARTIAL when the string does not contain a complete
token; nextTokPtr will not be set.
Return XML_TOK_INVALID when the string does not start a valid
token; nextTokPtr will be set to point to the character which made
the token invalid.
Otherwise the string starts with a valid token; nextTokPtr will be
set to point to the character following the end of that token.
Each data character counts as a single token, but adjacent data
characters may be returned together. Similarly for characters in
the prolog outside literals, comments and processing instructions.
*/
#define XmlTok(enc, state, ptr, end, nextTokPtr) \
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
#define XmlContentTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
#ifdef XML_DTD
#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
#endif /* XML_DTD */
/* This is used for performing a 2nd-level tokenization on the content
of a literal that has already been returned by XmlTok.
*/
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
#define XmlNameLength(enc, ptr) \
(((enc)->nameLength)(enc, ptr))
#define XmlSkipS(enc, ptr) \
(((enc)->skipS)(enc, ptr))
#define XmlGetAttributes(enc, ptr, attsMax, atts) \
(((enc)->getAtts)(enc, ptr, attsMax, atts))
#define XmlCharRefNumber(enc, ptr) \
(((enc)->charRefNumber)(enc, ptr))
#define XmlPredefinedEntityName(enc, ptr, end) \
(((enc)->predefinedEntityName)(enc, ptr, end))
#define XmlUpdatePosition(enc, ptr, end, pos) \
(((enc)->updatePosition)(enc, ptr, end, pos))
#define XmlIsPublicId(enc, ptr, end, badPtr) \
(((enc)->isPublicId)(enc, ptr, end, badPtr))
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
typedef struct {
ENCODING initEnc;
const ENCODING **encPtr;
} INIT_ENCODING;
int XmlParseXmlDecl(int isGeneralTextEntity,
const ENCODING *enc,
const char *ptr,
const char *end,
const char **badPtr,
const char **versionPtr,
const char **versionEndPtr,
const char **encodingNamePtr,
const ENCODING **namedEncodingPtr,
int *standalonePtr);
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING *XmlGetUtf8InternalEncoding(void);
const ENCODING *XmlGetUtf16InternalEncoding(void);
int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
int XmlSizeOfUnknownEncoding(void);
typedef int (XMLCALL *CONVERTER) (void *userData, const char *p);
ENCODING *
XmlInitUnknownEncoding(void *mem,
int *table,
CONVERTER convert,
void *userData);
int XmlParseXmlDeclNS(int isGeneralTextEntity,
const ENCODING *enc,
const char *ptr,
const char *end,
const char **badPtr,
const char **versionPtr,
const char **versionEndPtr,
const char **encodingNamePtr,
const ENCODING **namedEncodingPtr,
int *standalonePtr);
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
ENCODING *
XmlInitUnknownEncodingNS(void *mem,
int *table,
CONVERTER convert,
void *userData);
#ifdef __cplusplus
}
#endif
#endif /* not XmlTok_INCLUDED */

View File

@ -0,0 +1,46 @@
/*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
enum {
BT_NONXML,
BT_MALFORM,
BT_LT,
BT_AMP,
BT_RSQB,
BT_LEAD2,
BT_LEAD3,
BT_LEAD4,
BT_TRAIL,
BT_CR,
BT_LF,
BT_GT,
BT_QUOT,
BT_APOS,
BT_EQUALS,
BT_QUEST,
BT_EXCL,
BT_SOL,
BT_SEMI,
BT_NUM,
BT_LSQB,
BT_S,
BT_NMSTRT,
BT_COLON,
BT_HEX,
BT_DIGIT,
BT_NAME,
BT_MINUS,
BT_OTHER, /* known not to be a name or name start character */
BT_NONASCII, /* might be a name or name start character */
BT_PERCNT,
BT_LPAR,
BT_RPAR,
BT_AST,
BT_PLUS,
BT_COMMA,
BT_VERBAR
};
#include <stddef.h>

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
** as extensions by SQLite should #include this file instead of
** sqlite3.h.
**
** @(#) $Id: sqlite3ext.h,v 1.21 2008/03/19 21:45:51 drh Exp $
** @(#) $Id: sqlite3ext.h,v 1.24 2008/06/30 15:09:29 danielk1977 Exp $
*/
#ifndef _SQLITE3EXT_H_
#define _SQLITE3EXT_H_
@ -78,7 +78,7 @@ struct sqlite3_api_routines {
int (*complete)(const char*sql);
int (*complete16)(const void*sql);
int (*create_collation)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
int (*create_collation16)(sqlite3*,const char*,int,void*,int(*)(void*,int,const void*,int,const void*));
int (*create_collation16)(sqlite3*,const void*,int,void*,int(*)(void*,int,const void*,int,const void*));
int (*create_function)(sqlite3*,const char*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
int (*create_function16)(sqlite3*,const void*,int,int,void*,void (*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void (*xFinal)(sqlite3_context*));
int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
@ -188,6 +188,11 @@ struct sqlite3_api_routines {
int (*test_control)(int, ...);
void (*randomness)(int,void*);
sqlite3 *(*context_db_handle)(sqlite3_context*);
int (*extended_result_codes)(sqlite3*,int);
int (*limit)(sqlite3*,int,int);
sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
const char *(*sql)(sqlite3_stmt*);
int (*status)(int,int*,int*,int);
};
/*
@ -354,9 +359,14 @@ struct sqlite3_api_routines {
#define sqlite3_test_control sqlite3_api->test_control
#define sqlite3_randomness sqlite3_api->randomness
#define sqlite3_context_db_handle sqlite3_api->context_db_handle
#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
#define sqlite3_limit sqlite3_api->limit
#define sqlite3_next_stmt sqlite3_api->next_stmt
#define sqlite3_sql sqlite3_api->sql
#define sqlite3_status sqlite3_api->status
#endif /* SQLITE_CORE */
#define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api;
#define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api = 0;
#define SQLITE_EXTENSION_INIT2(v) sqlite3_api = v;
#endif /* _SQLITE3EXT_H_ */

Binary file not shown.

Binary file not shown.

6287
src/3rdparty/src/expat/xmlparse.c vendored Normal file

File diff suppressed because it is too large Load Diff

1336
src/3rdparty/src/expat/xmlrole.c vendored Normal file

File diff suppressed because it is too large Load Diff

1651
src/3rdparty/src/expat/xmltok.c vendored Normal file

File diff suppressed because it is too large Load Diff

1783
src/3rdparty/src/expat/xmltok_impl.c vendored Normal file

File diff suppressed because it is too large Load Diff

115
src/3rdparty/src/expat/xmltok_ns.c vendored Normal file
View File

@ -0,0 +1,115 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
/* This file is included! */
#ifdef XML_TOK_NS_C
const ENCODING *
NS(XmlGetUtf8InternalEncoding)(void)
{
return &ns(internal_utf8_encoding).enc;
}
const ENCODING *
NS(XmlGetUtf16InternalEncoding)(void)
{
#if BYTEORDER == 1234
return &ns(internal_little2_encoding).enc;
#elif BYTEORDER == 4321
return &ns(internal_big2_encoding).enc;
#else
const short n = 1;
return (*(const char *)&n
? &ns(internal_little2_encoding).enc
: &ns(internal_big2_encoding).enc);
#endif
}
static const ENCODING * const NS(encodings)[] = {
&ns(latin1_encoding).enc,
&ns(ascii_encoding).enc,
&ns(utf8_encoding).enc,
&ns(big2_encoding).enc,
&ns(big2_encoding).enc,
&ns(little2_encoding).enc,
&ns(utf8_encoding).enc /* NO_ENC */
};
static int PTRCALL
NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr)
{
return initScan(NS(encodings), (const INIT_ENCODING *)enc,
XML_PROLOG_STATE, ptr, end, nextTokPtr);
}
static int PTRCALL
NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr)
{
return initScan(NS(encodings), (const INIT_ENCODING *)enc,
XML_CONTENT_STATE, ptr, end, nextTokPtr);
}
int
NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
const char *name)
{
int i = getEncodingIndex(name);
if (i == UNKNOWN_ENC)
return 0;
SET_INIT_ENC_INDEX(p, i);
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
p->initEnc.updatePosition = initUpdatePosition;
p->encPtr = encPtr;
*encPtr = &(p->initEnc);
return 1;
}
static const ENCODING *
NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
{
#define ENCODING_MAX 128
char buf[ENCODING_MAX];
char *p = buf;
int i;
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
if (ptr != end)
return 0;
*p = 0;
if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
return enc;
i = getEncodingIndex(buf);
if (i == UNKNOWN_ENC)
return 0;
return NS(encodings)[i];
}
int
NS(XmlParseXmlDecl)(int isGeneralTextEntity,
const ENCODING *enc,
const char *ptr,
const char *end,
const char **badPtr,
const char **versionPtr,
const char **versionEndPtr,
const char **encodingName,
const ENCODING **encoding,
int *standalone)
{
return doParseXmlDecl(NS(findEncoding),
isGeneralTextEntity,
enc,
ptr,
end,
badPtr,
versionPtr,
versionEndPtr,
encodingName,
encoding,
standalone);
}
#endif /* XML_TOK_NS_C */

File diff suppressed because it is too large Load Diff

View File

@ -95,7 +95,7 @@ bool TagReaderTaglib::CanReadTag(const utfchar *extension){
}
bool TagReaderTaglib::ReadTag(musik::core::Track *track){
bool TagReaderTaglib::ReadTag(musik::core::ITrack *track){
const utfchar *extension = track->GetValue("extension");
@ -122,7 +122,7 @@ bool TagReaderTaglib::ReadTag(musik::core::Track *track){
return false;
}
bool TagReaderTaglib::GetOGGTag(musik::core::Track *track){
bool TagReaderTaglib::GetOGGTag(musik::core::ITrack *track){
/*
TagLib::Ogg::File file(track->GetValue("path"));
*/
@ -130,7 +130,7 @@ bool TagReaderTaglib::GetOGGTag(musik::core::Track *track){
}
bool TagReaderTaglib::GetGenericTag(musik::core::Track *track){
bool TagReaderTaglib::GetGenericTag(musik::core::ITrack *track){
TagLib::FileRef oFile(track->GetValue("path"));
if(!oFile.isNull()){
TagLib::Tag *tag = oFile.tag();
@ -171,7 +171,7 @@ bool TagReaderTaglib::GetGenericTag(musik::core::Track *track){
}
bool TagReaderTaglib::GetID3v2Tag(musik::core::Track *track){
bool TagReaderTaglib::GetID3v2Tag(musik::core::ITrack *track){
#ifdef UTF_WIDECHAR
TagLib::ID3v2::FrameFactory::instance()->setDefaultTextEncoding(TagLib::String::UTF16);
#else
@ -336,24 +336,24 @@ bool TagReaderTaglib::GetID3v2Tag(musik::core::Track *track){
return false;
}
void TagReaderTaglib::SetTagValue(const char* key,const TagLib::String tagString,musik::core::Track *track){
void TagReaderTaglib::SetTagValue(const char* key,const TagLib::String tagString,musik::core::ITrack *track){
using namespace musik::core;
std::wstring value(tagString.begin(),tagString.end());
track->SetValue(key,value.c_str());
}
void TagReaderTaglib::SetTagValue(const char* key,const wchar_t* string,musik::core::Track *track){
void TagReaderTaglib::SetTagValue(const char* key,const wchar_t* string,musik::core::ITrack *track){
using namespace musik::core;
track->SetValue(key,string);
}
void TagReaderTaglib::SetTagValue(const char* key,const int tagInt,musik::core::Track *track){
void TagReaderTaglib::SetTagValue(const char* key,const int tagInt,musik::core::ITrack *track){
std::wstring temp = boost::str(boost::wformat(_T("%1%"))%tagInt);
track->SetValue(key,temp.c_str());
}
void TagReaderTaglib::SetTagValues(const char* key,const TagLib::ID3v2::FrameList &frame,musik::core::Track *track){
void TagReaderTaglib::SetTagValues(const char* key,const TagLib::ID3v2::FrameList &frame,musik::core::ITrack *track){
using namespace musik::core;
if(!frame.isEmpty()){
for(TagLib::ID3v2::FrameList::ConstIterator value=frame.begin();value!=frame.end();++value){
@ -367,7 +367,7 @@ void TagReaderTaglib::SetTagValues(const char* key,const TagLib::ID3v2::FrameLis
}
/*
bool TagReaderTaglib::getStandardTags(musik::core::Track &track,TagLib::Tag *oTag,TagLib::AudioProperties *oAudioProperties){
bool TagReaderTaglib::getStandardTags(musik::core::ITrack &track,TagLib::Tag *oTag,TagLib::AudioProperties *oAudioProperties){
oMedia->setArtist(oTag->artist().toCString(false));
oMedia->setAlbum(oTag->album().toCString(false));
oMedia->setGenre(oTag->genre().toCString(false));
@ -383,7 +383,7 @@ bool TagReaderTaglib::getStandardTags(musik::core::Track &track,TagLib::Tag *oTa
return true;
}
*/
void TagReaderTaglib::SetSlashSeparatedValues(const char* key,TagLib::String &tagString,musik::core::Track *track){
void TagReaderTaglib::SetSlashSeparatedValues(const char* key,TagLib::String &tagString,musik::core::ITrack *track){
if( !tagString.isEmpty() ){
std::wstring value(tagString.begin(),tagString.end());
std::vector<std::wstring> splitValues;
@ -396,7 +396,7 @@ void TagReaderTaglib::SetSlashSeparatedValues(const char* key,TagLib::String &ta
}
}
void TagReaderTaglib::SetSlashSeparatedValues(const char* key,const TagLib::ID3v2::FrameList &frame,musik::core::Track *track){
void TagReaderTaglib::SetSlashSeparatedValues(const char* key,const TagLib::ID3v2::FrameList &frame,musik::core::ITrack *track){
using namespace musik::core;
if(!frame.isEmpty()){
for(TagLib::ID3v2::FrameList::ConstIterator frameValue=frame.begin();frameValue!=frame.end();++frameValue){
@ -416,7 +416,7 @@ void TagReaderTaglib::SetSlashSeparatedValues(const char* key,const TagLib::ID3v
}
}
void TagReaderTaglib::SetAudioProperties(TagLib::AudioProperties *audioProperties,musik::core::Track *track){
void TagReaderTaglib::SetAudioProperties(TagLib::AudioProperties *audioProperties,musik::core::ITrack *track){
if(audioProperties){
std::wstring duration = boost::str(boost::wformat(_T("%1%"))%audioProperties->length());
this->SetTagValue("duration",duration,track);

View File

@ -56,23 +56,23 @@ class TagReaderTaglib : public musik::core::Plugin::IMetaDataReader {
public:
TagReaderTaglib(void);
virtual ~TagReaderTaglib(void);
bool ReadTag(musik::core::Track *track);
bool ReadTag(musik::core::ITrack *track);
virtual bool CanReadTag(const utfchar *extension);
virtual void Destroy();
private:
// bool getStandardTags(musik::core::Track &track,TagLib::Tag *oTag,TagLib::AudioProperties *oAudioProperties);
// bool getStandardTags(musik::core::ITrack &track,TagLib::Tag *oTag,TagLib::AudioProperties *oAudioProperties);
void SetTagValue(const char* key,const wchar_t* string,musik::core::Track *track);
void SetTagValue(const char* key,const TagLib::String tagString,musik::core::Track *track);
void SetTagValue(const char* key,const int tagInt,musik::core::Track *track);
void SetTagValues(const char* key,const TagLib::ID3v2::FrameList &frame,musik::core::Track *track);
void SetAudioProperties(TagLib::AudioProperties *audioProperties,musik::core::Track *track);
void SetTagValue(const char* key,const wchar_t* string,musik::core::ITrack *track);
void SetTagValue(const char* key,const TagLib::String tagString,musik::core::ITrack *track);
void SetTagValue(const char* key,const int tagInt,musik::core::ITrack *track);
void SetTagValues(const char* key,const TagLib::ID3v2::FrameList &frame,musik::core::ITrack *track);
void SetAudioProperties(TagLib::AudioProperties *audioProperties,musik::core::ITrack *track);
void SetSlashSeparatedValues(const char* key,const TagLib::ID3v2::FrameList &frame,musik::core::Track *track);
void SetSlashSeparatedValues(const char* key,TagLib::String &tagString,musik::core::Track *track);
void SetSlashSeparatedValues(const char* key,const TagLib::ID3v2::FrameList &frame,musik::core::ITrack *track);
void SetSlashSeparatedValues(const char* key,TagLib::String &tagString,musik::core::ITrack *track);
bool GetID3v2Tag(musik::core::Track *track);
bool GetGenericTag(musik::core::Track *track);
bool GetOGGTag(musik::core::Track *track);
bool GetID3v2Tag(musik::core::ITrack *track);
bool GetGenericTag(musik::core::ITrack *track);
bool GetOGGTag(musik::core::ITrack *track);
};

View File

@ -62,7 +62,6 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="../../../bin/$(ConfigurationName)/mC2.lib"
OutputFile="$(OutDir)\$(ProjectName).dll"
LinkIncremental="2"
AdditionalLibraryDirectories="../../3rdparty/lib"
@ -144,7 +143,6 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="../../../bin/$(ConfigurationName)/mC2.lib"
OutputFile="$(OutDir)\$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories="../../3rdparty/lib"

53
src/core/ITrack.h Normal file
View File

@ -0,0 +1,53 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{
//////////////////////////////////////////////////////////////////////////////
class ITrack {
public:
virtual const utfchar* GetValue(const char* metakey) const = 0;
virtual void SetValue(const char* metakey,const utfchar* value) = 0;
virtual void SetThumbnail(const char *data,unsigned int size) = 0;
};
//////////////////////////////////////////////////////////////////////////////
} } // musik::core

View File

@ -59,7 +59,7 @@ Indexer::Indexer(void)
Indexer::~Indexer(void){
if(this->oThread){
this->Exit(true);
this->Exit();
this->oThread->join();
delete this->oThread;
this->oThread = NULL;
@ -233,7 +233,7 @@ void Indexer::Synchronize(){
}
// Cleaning up
if(!this->Restarted() && !this->Exit()){
if(!this->Restarted() && !this->Exited()){
this->SyncDelete(aPathIds);
}
@ -243,7 +243,7 @@ void Indexer::Synchronize(){
this->iProgress = 0.0;
this->iStatus = 4;
}
if(!this->Restarted() && !this->Exit()){
if(!this->Restarted() && !this->Exited()){
this->SyncCleanup();
}
@ -254,7 +254,7 @@ void Indexer::Synchronize(){
this->iStatus = 5;
}
if(!this->Restarted() && !this->Exit()){
if(!this->Restarted() && !this->Exited()){
this->SyncOptimize();
}
@ -275,7 +275,7 @@ void Indexer::Synchronize(){
///Folder to count files in.
//////////////////////////////////////////
void Indexer::CountFiles(utfstring &sFolder){
if(!this->Exit() && !this->Restarted()){
if(!this->Exited() && !this->Restarted()){
boost::filesystem::utfpath oPath(sFolder);
try{
boost::filesystem::utfdirectory_iterator oEndFile;
@ -314,7 +314,7 @@ void Indexer::CountFiles(utfstring &sFolder){
//////////////////////////////////////////
void Indexer::SyncDirectory(utfstring &sFolder,DBINT iParentFolderId,DBINT iPathId){
if(this->Exit() || this->Restarted()){
if(this->Exited() || this->Restarted()){
return;
}
@ -363,7 +363,7 @@ void Indexer::SyncDirectory(utfstring &sFolder,DBINT iParentFolderId,DBINT iPath
try{ // boost::filesystem may throw
boost::filesystem::utfdirectory_iterator oEndFile;
for(boost::filesystem::utfdirectory_iterator oFile(oPath);oFile!=oEndFile && !this->Exit() && !this->Restarted();++oFile){
for(boost::filesystem::utfdirectory_iterator oFile(oPath);oFile!=oEndFile && !this->Exited() && !this->Restarted();++oFile){
if(is_directory(oFile->status())){
@ -431,7 +431,7 @@ void Indexer::ThreadLoop(){
bool firstTime(true);
while(!this->Exit()){
while(!this->Exited()){
// Get preferences
Preferences prefs("Indexer");
@ -531,7 +531,7 @@ void Indexer::SyncDelete(std::vector<DBINT> aPaths){
stmt.BindInt(0,aPaths[i]);
while( stmt.Step()==db::ReturnCode::Row && !this->Exit() && !this->Restarted() ){
while( stmt.Step()==db::ReturnCode::Row && !this->Exited() && !this->Restarted() ){
// Check to see if file still exists
bool bRemove(true);
@ -580,7 +580,7 @@ void Indexer::SyncDelete(std::vector<DBINT> aPaths){
for(int i(0);i<aPaths.size();++i){
stmt.BindInt(0,aPaths[i]);
while( stmt.Step()==db::ReturnCode::Row && !this->Exit() && !this->Restarted() ){
while( stmt.Step()==db::ReturnCode::Row && !this->Exited() && !this->Restarted() ){
// Check to see if file still exists
{
boost::mutex::scoped_lock oLock(this->oProgressMutex);

View File

@ -48,7 +48,7 @@ Library::Base::Base(void) : identifier(UTF("local")), queueCallbackStarted(false
}
Library::Base::~Base(void){
this->Exit(true);
this->Exit();
this->threads.join_all();
}
@ -94,7 +94,7 @@ utfstring Library::Base::GetLibraryDirectory(){
//////////////////////////////////////////
utfstring Library::Base::GetDBPath(){
utfstring sPath = this->GetLibraryDirectory();
sPath.append(UTF("local_musik.db"));
sPath.append(UTF("musik.db"));
return sPath;
}
@ -406,15 +406,15 @@ void Library::Base::CancelCurrentQuery(){
}
bool Library::Base::Exit(void){
bool Library::Base::Exited(){
boost::mutex::scoped_lock lock(this->libraryMutex);
return this->exit;
}
void Library::Base::Exit(bool exit){
void Library::Base::Exit(){
{
boost::mutex::scoped_lock lock(this->libraryMutex);
this->exit = exit;
this->exit = true;
}
this->waitCondition.notify_all();
}
@ -464,3 +464,135 @@ musik::core::Indexer *Library::Base::Indexer(){
return NULL;
}
//////////////////////////////////////////
///\brief
///Create all tables, indexes, etc in the database.
///
///This will assume that the database has been initialized.
//////////////////////////////////////////
void Library::Base::CreateDatabase(db::Connection &db){
// Create the tracks-table
db.Execute("CREATE TABLE IF NOT EXISTS tracks ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"track INTEGER DEFAULT 0,"
"bpm REAL DEFAULT 0,"
"duration INTEGER DEFAULT 0,"
"filesize INTEGER DEFAULT 0,"
"year INTEGER DEFAULT 0,"
"visual_genre_id INTEGER DEFAULT 0,"
"visual_artist_id INTEGER DEFAULT 0,"
"album_id INTEGER DEFAULT 0,"
"folder_id INTEGER DEFAULT 0,"
"title TEXT default '',"
"filename TEXT default '',"
"filetime INTEGER DEFAULT 0,"
"thumbnail_id INTEGER DEFAULT 0,"
"sort_order1 INTEGER)");
// Create the genres-table
db.Execute("CREATE TABLE IF NOT EXISTS genres ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default '',"
"aggregated INTEGER DEFAULT 0,"
"sort_order INTEGER DEFAULT 0)");
db.Execute("CREATE TABLE IF NOT EXISTS track_genres ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"track_id INTEGER DEFAULT 0,"
"genre_id INTEGER DEFAULT 0)");
// Create the artists-table
db.Execute("CREATE TABLE IF NOT EXISTS artists ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default '',"
"aggregated INTEGER DEFAULT 0,"
"sort_order INTEGER DEFAULT 0)");
db.Execute("CREATE TABLE IF NOT EXISTS track_artists ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"track_id INTEGER DEFAULT 0,"
"artist_id INTEGER DEFAULT 0)");
// Create the meta-tables
db.Execute("CREATE TABLE IF NOT EXISTS meta_keys ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT)");
db.Execute("CREATE TABLE IF NOT EXISTS meta_values ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"meta_key_id INTEGER DEFAULT 0,"
"sort_order INTEGER DEFAULT 0,"
"content TEXT)");
db.Execute("CREATE TABLE IF NOT EXISTS track_meta ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"track_id INTEGER DEFAULT 0,"
"meta_value_id INTEGER DEFAULT 0)");
// Create the albums-table
db.Execute("CREATE TABLE IF NOT EXISTS albums ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default '',"
"thumbnail_id INTEGER default 0,"
"sort_order INTEGER DEFAULT 0)");
// Create the paths-table
db.Execute("CREATE TABLE IF NOT EXISTS paths ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"path TEXT default ''"
")");
// Create the folders-table
db.Execute("CREATE TABLE IF NOT EXISTS folders ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default '',"
"fullpath TEXT default '',"
"parent_id INTEGER DEFAULT 0,"
"path_id INTEGER DEFAULT 0"
")");
// Create the folders-table
db.Execute("CREATE TABLE IF NOT EXISTS thumbnails ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"filename TEXT default '',"
"filesize INTEGER DEFAULT 0,"
"checksum INTEGER DEFAULT 0"
")");
// Create the playlists-table
db.Execute("CREATE TABLE IF NOT EXISTS playlists ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default ''"
")");
// Create the playlists-table
db.Execute("CREATE TABLE IF NOT EXISTS playlist_tracks ("
"track_id INTEGER DEFAULT 0,"
"playlist_id INTEGER DEFAULT 0,"
"sort_order INTEGER DEFAULT 0"
")");
// INDEXES
db.Execute("CREATE UNIQUE INDEX IF NOT EXISTS folders_index ON folders (name,parent_id,path_id)");
db.Execute("CREATE UNIQUE INDEX IF NOT EXISTS paths_index ON paths (path)");
db.Execute("CREATE INDEX IF NOT EXISTS genre_index ON genres (sort_order)");
db.Execute("CREATE INDEX IF NOT EXISTS artist_index ON artists (sort_order)");
db.Execute("CREATE INDEX IF NOT EXISTS album_index ON albums (sort_order)");
db.Execute("CREATE INDEX IF NOT EXISTS track_index1 ON tracks (album_id,sort_order1)");
db.Execute("CREATE INDEX IF NOT EXISTS track_index7 ON tracks (folder_id)");
db.Execute("CREATE INDEX IF NOT EXISTS thumbnail_index ON thumbnails (filesize)");
db.Execute("CREATE INDEX IF NOT EXISTS trackgenre_index1 ON track_genres (track_id,genre_id)");
db.Execute("CREATE INDEX IF NOT EXISTS trackgenre_index2 ON track_genres (genre_id,track_id)");
db.Execute("CREATE INDEX IF NOT EXISTS trackartist_index1 ON track_artists (track_id,artist_id)");
db.Execute("CREATE INDEX IF NOT EXISTS trackartist_index2 ON track_artists (artist_id,track_id)");
db.Execute("CREATE INDEX IF NOT EXISTS trackmeta_index1 ON track_meta (track_id,meta_value_id)");
db.Execute("CREATE INDEX IF NOT EXISTS trackmeta_index2 ON track_meta (meta_value_id,track_id)");
db.Execute("CREATE INDEX IF NOT EXISTS metakey_index1 ON meta_keys (name)");
db.Execute("CREATE INDEX IF NOT EXISTS metavalues_index1 ON meta_values (meta_key_id)");
db.Execute("CREATE INDEX IF NOT EXISTS playlist_index ON playlist_tracks (playlist_id,sort_order)");
db.Execute("ANALYZE");
}

View File

@ -37,6 +37,7 @@
#pragma once
#include <core/config.h>
#include <core/db/Connection.h>
#include <boost/thread/thread.hpp>
#include <boost/thread/condition.hpp>
@ -118,15 +119,18 @@ namespace musik{ namespace core{
virtual musik::core::Indexer *Indexer();
bool Exit(void);
bool Exited();
static bool IsStaticMetaKey(std::string &metakey);
static bool IsSpecialMTOMetaKey(std::string &metakey);
static bool IsSpecialMTMMetaKey(std::string &metakey);
static void CreateDatabase(db::Connection &db);
protected:
// Methods:
void Exit(bool exit);
virtual void Exit();
Query::Ptr GetNextQuery();
@ -184,6 +188,7 @@ namespace musik{ namespace core{
protected:
typedef std::list<Query::Ptr> QueryList;
// Variables:
//////////////////////////////////////////
@ -199,14 +204,14 @@ namespace musik{ namespace core{
///\brief
///queue (std::list) for incoming queries.
//////////////////////////////////////////
std::list<Query::Ptr> incomingQueries;
QueryList incomingQueries;
//////////////////////////////////////////
///\brief
///queue (std::list) for finished queries that havn't
///been run through the callbacks yet.
//////////////////////////////////////////
std::list<Query::Ptr> outgoingQueries;
QueryList outgoingQueries;
//////////////////////////////////////////
///\brief

View File

@ -57,7 +57,7 @@ Library::LocalDB::LocalDB(void){
}
Library::LocalDB::~LocalDB(void){
this->Exit(true);
this->Exit();
this->threads.join_all();
}
@ -101,144 +101,11 @@ bool Library::LocalDB::Startup(){
}
//////////////////////////////////////////
///\brief
///Create all tables, indexes, etc in the database.
///
///This will assume that the database has been initialized.
//////////////////////////////////////////
void Library::LocalDB::CreateDatabase(){
// Create the tracks-table
this->db.Execute("CREATE TABLE IF NOT EXISTS tracks ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"track INTEGER DEFAULT 0,"
"bpm REAL DEFAULT 0,"
"duration INTEGER DEFAULT 0,"
"filesize INTEGER DEFAULT 0,"
"year INTEGER DEFAULT 0,"
"visual_genre_id INTEGER DEFAULT 0,"
"visual_artist_id INTEGER DEFAULT 0,"
"album_id INTEGER DEFAULT 0,"
"folder_id INTEGER DEFAULT 0,"
"title TEXT default '',"
"filename TEXT default '',"
"filetime INTEGER DEFAULT 0,"
"thumbnail_id INTEGER DEFAULT 0,"
"sort_order1 INTEGER)");
// Create the genres-table
this->db.Execute("CREATE TABLE IF NOT EXISTS genres ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default '',"
"aggregated INTEGER DEFAULT 0,"
"sort_order INTEGER DEFAULT 0)");
this->db.Execute("CREATE TABLE IF NOT EXISTS track_genres ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"track_id INTEGER DEFAULT 0,"
"genre_id INTEGER DEFAULT 0)");
// Create the artists-table
this->db.Execute("CREATE TABLE IF NOT EXISTS artists ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default '',"
"aggregated INTEGER DEFAULT 0,"
"sort_order INTEGER DEFAULT 0)");
this->db.Execute("CREATE TABLE IF NOT EXISTS track_artists ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"track_id INTEGER DEFAULT 0,"
"artist_id INTEGER DEFAULT 0)");
// Create the meta-tables
this->db.Execute("CREATE TABLE IF NOT EXISTS meta_keys ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT)");
this->db.Execute("CREATE TABLE IF NOT EXISTS meta_values ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"meta_key_id INTEGER DEFAULT 0,"
"sort_order INTEGER DEFAULT 0,"
"content TEXT)");
this->db.Execute("CREATE TABLE IF NOT EXISTS track_meta ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"track_id INTEGER DEFAULT 0,"
"meta_value_id INTEGER DEFAULT 0)");
// Create the albums-table
this->db.Execute("CREATE TABLE IF NOT EXISTS albums ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default '',"
"thumbnail_id INTEGER default 0,"
"sort_order INTEGER DEFAULT 0)");
// Create the paths-table
this->db.Execute("CREATE TABLE IF NOT EXISTS paths ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"path TEXT default ''"
")");
// Create the folders-table
this->db.Execute("CREATE TABLE IF NOT EXISTS folders ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default '',"
"fullpath TEXT default '',"
"parent_id INTEGER DEFAULT 0,"
"path_id INTEGER DEFAULT 0"
")");
// Create the folders-table
this->db.Execute("CREATE TABLE IF NOT EXISTS thumbnails ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"filename TEXT default '',"
"filesize INTEGER DEFAULT 0,"
"checksum INTEGER DEFAULT 0"
")");
// Create the playlists-table
this->db.Execute("CREATE TABLE IF NOT EXISTS playlists ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT default ''"
")");
// Create the playlists-table
this->db.Execute("CREATE TABLE IF NOT EXISTS playlist_tracks ("
"track_id INTEGER DEFAULT 0,"
"playlist_id INTEGER DEFAULT 0,"
"sort_order INTEGER DEFAULT 0"
")");
// INDEXES
this->db.Execute("CREATE UNIQUE INDEX IF NOT EXISTS folders_index ON folders (name,parent_id,path_id)");
this->db.Execute("CREATE UNIQUE INDEX IF NOT EXISTS paths_index ON paths (path)");
this->db.Execute("CREATE INDEX IF NOT EXISTS genre_index ON genres (sort_order)");
this->db.Execute("CREATE INDEX IF NOT EXISTS artist_index ON artists (sort_order)");
this->db.Execute("CREATE INDEX IF NOT EXISTS album_index ON albums (sort_order)");
this->db.Execute("CREATE INDEX IF NOT EXISTS track_index1 ON tracks (album_id,sort_order1)");
this->db.Execute("CREATE INDEX IF NOT EXISTS track_index7 ON tracks (folder_id)");
this->db.Execute("CREATE INDEX IF NOT EXISTS thumbnail_index ON thumbnails (filesize)");
this->db.Execute("CREATE INDEX IF NOT EXISTS trackgenre_index1 ON track_genres (track_id,genre_id)");
this->db.Execute("CREATE INDEX IF NOT EXISTS trackgenre_index2 ON track_genres (genre_id,track_id)");
this->db.Execute("CREATE INDEX IF NOT EXISTS trackartist_index1 ON track_artists (track_id,artist_id)");
this->db.Execute("CREATE INDEX IF NOT EXISTS trackartist_index2 ON track_artists (artist_id,track_id)");
this->db.Execute("CREATE INDEX IF NOT EXISTS trackmeta_index1 ON track_meta (track_id,meta_value_id)");
this->db.Execute("CREATE INDEX IF NOT EXISTS trackmeta_index2 ON track_meta (meta_value_id,track_id)");
this->db.Execute("CREATE INDEX IF NOT EXISTS metakey_index1 ON meta_keys (name)");
this->db.Execute("CREATE INDEX IF NOT EXISTS metavalues_index1 ON meta_values (meta_key_id)");
this->db.Execute("CREATE INDEX IF NOT EXISTS playlist_index ON playlist_tracks (playlist_id,sort_order)");
this->db.Execute("ANALYZE");
}
//////////////////////////////////////////
///\brief
///Main loop the library thread is running in.
///
///The loop will run until Exit(true) has been called.
///The loop will run until Exit() has been called.
//////////////////////////////////////////
void Library::LocalDB::ThreadLoop(){
@ -247,13 +114,13 @@ void Library::LocalDB::ThreadLoop(){
utfstring database(this->GetDBPath());
this->db.Open(database.c_str(),0,prefs.GetInt("DatabaseCache",4096));
this->CreateDatabase();
Library::Base::CreateDatabase(this->db);
// Startup the indexer
this->indexer.database = database;
this->indexer.Startup(this->GetLibraryDirectory());
while(!this->Exit()){
while(!this->Exited()){
Query::Ptr query(this->GetNextQuery());
if(query){ // No empty query

View File

@ -81,7 +81,6 @@ namespace musik{ namespace core{
void ThreadLoop();
void CreateDatabase();
private:
// Variables:
db::Connection db;

View File

@ -37,12 +37,12 @@
#pragma once
#include <core/config.h>
#include <core/Track.h>
#include <core/ITrack.h>
namespace musik{ namespace core{ namespace Plugin{
class IMetaDataReader{
public:
virtual bool ReadTag(musik::core::Track *track)=0;
virtual bool ReadTag(musik::core::ITrack *track)=0;
virtual bool CanReadTag(const utfchar *extension)=0;
virtual void Destroy()=0;
};

View File

@ -51,3 +51,63 @@ Query::Base::Base(void) : status(0){
Query::Base::~Base(void){
}
//////////////////////////////////////////
///\brief
///Recieve the query from XML
///
///\param queryNode
///Reference to query XML node
///
///\returns
///true when successfully recieved
//////////////////////////////////////////
bool Query::Base::RecieveQuery(musik::core::xml::ParserNode &queryNode){
return false;
}
//////////////////////////////////////////
///\brief
///Serialize query to XML
///
///\param queryNode
///Reference to query XML node
///
///\returns
///true when successfully send
//////////////////////////////////////////
bool Query::Base::SendQuery(musik::core::xml::WriterNode &queryNode){
return false;
}
//////////////////////////////////////////
///\brief
///Recieve results from XML
///
///\param queryNode
///Reference to query XML node
///
///\returns
///true when successfully recieved
//////////////////////////////////////////
bool Query::Base::RecieveResults(musik::core::xml::ParserNode &queryNode){
return false;
}
//////////////////////////////////////////
///\brief
///Serialize results to XML
///
///\param queryNode
///Reference to query XML node
///
///\returns
///true when successfully send
//////////////////////////////////////////
bool Query::Base::SendResults(musik::core::xml::WriterNode &queryNode,Library::Base *library){
return false;
}
std::string Query::Base::Name(){
return "Unknown";
}

View File

@ -39,155 +39,171 @@
#include <core/config.h>
#include <core/db/Connection.h>
#include <core/db/Statement.h>
#include <core/xml/ParserNode.h>
#include <core/xml/WriterNode.h>
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <string>
//////////////////////////////////////////////////////////////////////////////
// forward declare
namespace musik{ namespace core{
namespace Library{
class Base;
class LocalDB;
}
namespace server{
class Connection;
}
} }
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{ namespace Query{
#include <string>
//////////////////////////////////////////////////////////////////////////////
class Base;
typedef boost::shared_ptr<Query::Base> Ptr;
namespace musik{ namespace core{
namespace Query{
class Base;
typedef boost::shared_ptr<Query::Base> Ptr;
enum Options:unsigned int{
AutoCallback = 1,
Wait = 2,
Prioritize = 4,
CancelQueue = 8,
CancelSimilar = 16,
UnCanceable = 32
};
enum Options:unsigned int{
AutoCallback = 1,
Wait = 2,
Prioritize = 4,
CancelQueue = 8,
CancelSimilar = 16,
UnCanceable = 32
};
//////////////////////////////////////////
///\brief
///Interface class for all queries.
//////////////////////////////////////////
class Base : public sigslot::has_slots<> {
public:
Base(void);
virtual ~Base(void);
protected:
friend class Library::Base;
friend class Library::LocalDB;
friend class server::Connection;
// Variables:
//////////////////////////////////////////
///\brief
///Interface class for all queries.
///Current state of the query
///
///\remarks
///iState is protected by the Library::Base::oResultMutex
///
///\see
///musik::core::State
//////////////////////////////////////////
class Base{
public:
Base(void);
virtual ~Base(void);
protected:
friend class Library::Base;
friend class Library::LocalDB;
// Variables:
//////////////////////////////////////////
///\brief
///The query id is a unique number for each query.
///
///Used for comparing queries and find similar queries.
//////////////////////////////////////////
unsigned int iQueryId;
//////////////////////////////////////////
///\brief
///Current state of the query
///
///\remarks
///iState is protected by the Library::Base::oResultMutex
///
///\see
///musik::core::State
//////////////////////////////////////////
enum Status:int{
Started = 1,
Ended = 2,
Canceled = 4,
OutputStarted = 8,
OutputEnded = 16,
Finished = 32
};
unsigned int status;
//////////////////////////////////////////
///\brief
///Query options
///
///options is only set inside the AddQuery and should not be altered later.
///It is therefore considered threadsafe.
///
///\see
///musik::core::Library::Base::AddQuery
//////////////////////////////////////////
unsigned int options;
protected:
friend class Library::Base;
friend class Library::LocalDB;
// Methods:
//////////////////////////////////////////
///\brief
///Copy method that is required to be implemented.
///
///\returns
///Shared pointer to Query::Base object.
///
///This method is required by all queries since they are
///copied every time a Library::Base::AddQuery is called.
///
///\see
///Library::Base::AddQuery
//////////////////////////////////////////
virtual Ptr copy() const=0;
//////////////////////////////////////////
///\brief
///Method for calling all the querys signals
///
///\param oLibrary
///Pointer to the library running the query
///
///\returns
///Should return true if query is totaly finished. false otherwise.
//////////////////////////////////////////
virtual bool RunCallbacks(Library::Base *oLibrary){return true;};
//////////////////////////////////////////
///\brief
///Method that do the acctual work.
///
///\param oLibrary
///Pointer to executing library
///
///\param oDB
///Pointer to DBConnection
///
///\returns
///true when successfully executed.
///
///The ParseQuery should consider that all sqlite
///calls could be interrupted by the sqlite3_interrupt call.
//////////////////////////////////////////
virtual bool ParseQuery(Library::Base *oLibrary,db::Connection &db)=0;
//////////////////////////////////////////
///\brief
///PreAddQuery is called from the Library::Base::AddQuery when the copied query is added to the library.
///
///\param library
///Pointer to library
///
///\see
///Library::Base::AddQuery
//////////////////////////////////////////
virtual void PreAddQuery(Library::Base *library){};
enum Status:int{
Started = 1,
Ended = 2,
Canceled = 4,
OutputStarted = 8,
OutputEnded = 16,
Finished = 32
};
unsigned int status;
//////////////////////////////////////////
///\brief
///The query id is a unique number for each query.
///
///Used for comparing queries and find similar queries.
//////////////////////////////////////////
unsigned int iQueryId;
//////////////////////////////////////////
///\brief
///Query options
///
///options is only set inside the AddQuery and should not be altered later.
///It is therefore considered threadsafe.
///
///\see
///musik::core::Library::Base::AddQuery
//////////////////////////////////////////
unsigned int options;
protected:
friend class Library::Base;
friend class Library::LocalDB;
friend class server::Connection;
// Methods:
virtual std::string Name();
//////////////////////////////////////////
///\brief
///Copy method that is required to be implemented.
///
///\returns
///Shared pointer to Query::Base object.
///
///This method is required by all queries since they are
///copied every time a Library::Base::AddQuery is called.
///
///\see
///Library::Base::AddQuery
//////////////////////////////////////////
virtual Ptr copy() const=0;
//////////////////////////////////////////
///\brief
///Method for calling all the querys signals
///
///\param library
///Pointer to the library running the query
///
///\returns
///Should return true if query is totaly finished. false otherwise.
//////////////////////////////////////////
virtual bool RunCallbacks(Library::Base *library){return true;};
//////////////////////////////////////////
///\brief
///Method that do the acctual work.
///
///\param library
///Pointer to executing library
///
///\param oDB
///Pointer to DBConnection
///
///\returns
///true when successfully executed.
///
///The ParseQuery should consider that all sqlite
///calls could be interrupted by the sqlite3_interrupt call.
//////////////////////////////////////////
virtual bool ParseQuery(Library::Base *library,db::Connection &db)=0;
//////////////////////////////////////////
///\brief
///PreAddQuery is called from the Library::Base::AddQuery when the copied query is added to the library.
///
///\param library
///Pointer to library
///
///\see
///Library::Base::AddQuery
//////////////////////////////////////////
virtual void PreAddQuery(Library::Base *library){};
}
} }
virtual bool RecieveQuery(musik::core::xml::ParserNode &queryNode);
virtual bool SendQuery(musik::core::xml::WriterNode &queryNode);
virtual bool RecieveResults(musik::core::xml::ParserNode &queryNode);
virtual bool SendResults(musik::core::xml::WriterNode &queryNode,Library::Base *library);
};
//////////////////////////////////////////////////////////////////////////////
} } } // musik::core::Query
//////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,56 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include <core/Query/Factory.h>
#include <core/Query/ListSelection.h>
#include <core/Query/SortTracks.h>
#include <core/Query/TrackMetadata.h>
//////////////////////////////////////////////////////////////////////////////
using namespace musik::core::Query;
Factory::Factory(void){
}
Factory::~Factory(void){
}
void Factory::GetQueries(QueryMap &queryMap){
queryMap["ListSelection"] = Ptr(new ListSelection());
queryMap["SortTracks"] = Ptr(new SortTracks());
queryMap["TrackMetadata"] = Ptr(new TrackMetadata());
}

66
src/core/Query/Factory.h Normal file
View File

@ -0,0 +1,66 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <core/Query/Base.h>
#include <map>
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{ namespace Query{
//////////////////////////////////////////////////////////////////////////////
typedef std::map<std::string,musik::core::Query::Ptr> QueryMap;
class Factory{
private:
Factory(void);
~Factory(void);
public:
static void GetQueries(QueryMap &queryMap);
};
//////////////////////////////////////////////////////////////////////////////
} } }
//////////////////////////////////////////////////////////////////////////////

View File

@ -54,7 +54,7 @@ Query::ListBase::~ListBase(void){
}
bool Query::ListBase::RunCallbacks(Library::Base *oLibrary){
bool Query::ListBase::RunCallbacks(Library::Base *library){
bool bReturn(false);
@ -62,7 +62,7 @@ bool Query::ListBase::RunCallbacks(Library::Base *oLibrary){
TrackVector trackResultsCopy;
{ // Scope for swapping the results safely
boost::mutex::scoped_lock lock(oLibrary->oResultMutex);
boost::mutex::scoped_lock lock(library->oResultMutex);
metadataResultsCopy.swap(this->metadataResults);
trackResultsCopy.swap(this->trackResults);
@ -110,7 +110,7 @@ bool Query::ListBase::RunCallbacks(Library::Base *oLibrary){
}
if(bReturn){
boost::mutex::scoped_lock lock(oLibrary->oResultMutex);
boost::mutex::scoped_lock lock(library->oResultMutex);
// Check for trackinfo update
this->trackInfoEvent(trackInfoTracks,trackInfoDuration,trackInfoSize);
}
@ -134,8 +134,8 @@ Query::ListBase::TrackInfoSignal& Query::ListBase::OnTrackInfoEvent(){
return this->trackInfoEvent;
}
bool Query::ListBase::ParseTracksSQL(std::string sql,Library::Base *oLibrary,db::Connection &db){
if(this->trackEvent.has_connections() && !oLibrary->QueryCanceled()){
bool Query::ListBase::ParseTracksSQL(std::string sql,Library::Base *library,db::Connection &db){
if(this->trackEvent.has_connections() && !library->QueryCanceled()){
db::Statement selectTracks(sql.c_str(),db);
TrackVector tempTrackResults;
@ -148,7 +148,7 @@ bool Query::ListBase::ParseTracksSQL(std::string sql,Library::Base *oLibrary,db:
this->trackInfoTracks++;
if( (++row)%100==0 ){
boost::mutex::scoped_lock lock(oLibrary->oResultMutex);
boost::mutex::scoped_lock lock(library->oResultMutex);
this->trackResults.insert(this->trackResults.end(),tempTrackResults.begin(),tempTrackResults.end());
tempTrackResults.clear();
@ -156,7 +156,7 @@ bool Query::ListBase::ParseTracksSQL(std::string sql,Library::Base *oLibrary,db:
}
}
if(!tempTrackResults.empty()){
boost::mutex::scoped_lock lock(oLibrary->oResultMutex);
boost::mutex::scoped_lock lock(library->oResultMutex);
this->trackResults.insert(this->trackResults.end(),tempTrackResults.begin(),tempTrackResults.end());
}
@ -167,3 +167,116 @@ bool Query::ListBase::ParseTracksSQL(std::string sql,Library::Base *oLibrary,db:
}
bool Query::ListBase::SendResults(musik::core::xml::WriterNode &queryNode,Library::Base *library){
bool continueSending(true);
while(continueSending){
MetadataResults metadataResultsCopy;
TrackVector trackResultsCopy;
{ // Scope for swapping the results safely
boost::mutex::scoped_lock lock(library->oResultMutex);
metadataResultsCopy.swap(this->metadataResults);
trackResultsCopy.swap(this->trackResults);
if( (this->status & Status::Ended)!=0){
// If the query is finished, stop sending
continueSending = false;
}
}
// Check for metadata results
if(!metadataResultsCopy.empty()){
// Loop metadata tags for results
for( MetadataResults::iterator metatagResult=metadataResultsCopy.begin();metatagResult!=metadataResultsCopy.end();++metatagResult){
std::string metatag(metatagResult->first);
// If the metatag has results, send results
// check if the signal should send the clear flag
bool clearMetatag(false);
if(this->clearedMetadataResults.find(metatag)==this->clearedMetadataResults.end()){
clearMetatag = true;
this->clearedMetadataResults.insert(metatag); // Set this to cleared
}
// Send results
{
musik::core::xml::WriterNode results(queryNode,"metadata");
results.Attributes()["key"] = metatagResult->first;
if(clearMetatag){
results.Attributes()["clear"] = "true";
}
for(musik::core::MetadataValueVector::iterator metaValue=metatagResult->second.begin();metaValue!=metatagResult->second.end();++metaValue){
musik::core::xml::WriterNode metaValueNode(results,"md");
metaValueNode.Attributes()["id"] = boost::lexical_cast<std::string>( (*metaValue)->id );
metaValueNode.Content() = musik::core::ConvertUTF8( (*metaValue)->value );
}
this->metadataEvent[metatag](&metatagResult->second,clearMetatag);
}
}
}
// Check for Tracks
if( !trackResultsCopy.empty() ){
musik::core::xml::WriterNode tracklist(queryNode,"tracklist");
if(!this->clearedTrackResults){
tracklist.Attributes()["clear"] = "true";
this->clearedTrackResults = true;
}
for(musik::core::TrackVector::iterator track=trackResultsCopy.begin();track!=trackResultsCopy.end();){
musik::core::xml::WriterNode tracks(tracklist,"tracks");
int trackCount(0);
while(trackCount<100 && track!=trackResultsCopy.end()){
if(trackCount!=0){
tracks.Content() += ",";
}
tracks.Content() += boost::lexical_cast<std::string>( (*track)->id );
++track;
++trackCount;
}
}
}
if(!continueSending){
boost::mutex::scoped_lock lock(library->oResultMutex);
// Check for trackinfo update
musik::core::xml::WriterNode trackInfoNode(queryNode,"trackinfo");
trackInfoNode.Content() = boost::lexical_cast<std::string>( trackInfoTracks );
trackInfoNode.Content() += ","+boost::lexical_cast<std::string>( trackInfoDuration );
trackInfoNode.Content() += ","+boost::lexical_cast<std::string>( trackInfoSize );
}else{
if( metadataResultsCopy.empty() && trackResultsCopy.empty() ){
// Yield for more results
boost::thread::yield();
}
}
}
return true;
}
void Query::ListBase::DummySlot(MetadataValueVector*,bool){
}
void Query::ListBase::DummySlotTracks(TrackVector*,bool){
}
void Query::ListBase::DummySlotTrackInfo(UINT64,UINT64,UINT64){
}

View File

@ -70,9 +70,13 @@ namespace musik{ namespace core{
typedef sigslot::signal3<UINT64,UINT64,UINT64> TrackInfoSignal;
protected:
bool RunCallbacks(Library::Base *oLibrary);
friend class Library::Base;
friend class Library::LocalDB;
friend class server::Connection;
bool ParseTracksSQL(std::string sql,Library::Base *oLibrary,db::Connection &db);
bool RunCallbacks(Library::Base *library);
bool ParseTracksSQL(std::string sql,Library::Base *library,db::Connection &db);
MetadataResults metadataResults;
TrackVector trackResults;
@ -88,11 +92,17 @@ namespace musik{ namespace core{
UINT64 trackInfoDuration;
UINT64 trackInfoSize;
virtual bool SendResults(musik::core::xml::WriterNode &queryNode,Library::Base *library);
public:
MetadataSignal& OnMetadataEvent(const char* metatag);
MetadataSignal& OnMetadataEvent(const wchar_t* metatag);
TrackSignal& OnTrackEvent();
TrackInfoSignal& OnTrackInfoEvent();
public:
void DummySlot(MetadataValueVector*,bool);
void DummySlotTracks(TrackVector*,bool);
void DummySlotTrackInfo(UINT64,UINT64,UINT64);
};
}
} }

View File

@ -40,7 +40,7 @@
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <algorithm>
#include <boost/algorithm/string.hpp>
using namespace musik::core;
@ -197,7 +197,7 @@ void Query::ListSelection::ClearMetadata(const char* metatag){
///\brief
///Parse the list query
///
///\param oLibrary
///\param library
///pointer to library that parses the query. Needed for mutexes.
///
///\param db
@ -246,7 +246,7 @@ void Query::ListSelection::ClearMetadata(const char* metatag){
/// SELECT id,content FROM meta_values WHERE meta_key_id IN (SELECT id FROM meta_keys WHERE name=?) AND id IN (SELECT meta_value_id FROM track_meta WHERE track_id IN ($tracklist$)) ORDER BY sort_order
///
//////////////////////////////////////////
bool Query::ListSelection::ParseQuery(Library::Base *oLibrary,db::Connection &db){
bool Query::ListSelection::ParseQuery(Library::Base *library,db::Connection &db){
bool success(true);
@ -295,33 +295,33 @@ bool Query::ListSelection::ParseQuery(Library::Base *oLibrary,db::Connection &db
if(!metakeysSelected.empty()){
////////////////////////////////////////////////
// Selected genre
this->SQLSelectQuery("genre","t.id IN (SELECT track_id FROM track_genres WHERE genre_id IN (",")) ",metakeysSelected,sqlSelectTrackWhere,oLibrary);
this->SQLSelectQuery("genre","t.id IN (SELECT track_id FROM track_genres WHERE genre_id IN (",")) ",metakeysSelected,sqlSelectTrackWhere,library);
////////////////////////////////////////////////
// Selected artists
this->SQLSelectQuery("artist","t.id IN (SELECT track_id FROM track_artists WHERE artist_id IN (",")) ",metakeysSelected,sqlSelectTrackWhere,oLibrary);
this->SQLSelectQuery("artist","t.id IN (SELECT track_id FROM track_artists WHERE artist_id IN (",")) ",metakeysSelected,sqlSelectTrackWhere,library);
////////////////////////////////////////////////
// Selected albums
this->SQLSelectQuery("album","t.album_id IN (",") ",metakeysSelected,sqlSelectTrackWhere,oLibrary);
this->SQLSelectQuery("album","t.album_id IN (",") ",metakeysSelected,sqlSelectTrackWhere,library);
////////////////////////////////////////////////
// Selected year
this->SQLSelectQuery("year","t.year IN (",") ",metakeysSelected,sqlSelectTrackWhere,oLibrary);
this->SQLSelectQuery("year","t.year IN (",") ",metakeysSelected,sqlSelectTrackWhere,library);
////////////////////////////////////////////////
// Selected duration
this->SQLSelectQuery("duration","t.duration IN (",") ",metakeysSelected,sqlSelectTrackWhere,oLibrary);
this->SQLSelectQuery("duration","t.duration IN (",") ",metakeysSelected,sqlSelectTrackWhere,library);
////////////////////////////////////////////////
// Selected track
this->SQLSelectQuery("track","t.track IN (",") ",metakeysSelected,sqlSelectTrackWhere,oLibrary);
this->SQLSelectQuery("track","t.track IN (",") ",metakeysSelected,sqlSelectTrackWhere,library);
////////////////////////////////////////////////
// Selected metadata
std::set<std::string> tempMetakeysSelected(metakeysSelected);
for(std::set<std::string>::iterator metakey=tempMetakeysSelected.begin();metakey!=tempMetakeysSelected.end();++metakey){
this->SQLSelectQuery(metakey->c_str(),"t.id IN (SELECT track_id FROM track_meta WHERE meta_value_id IN (",")) ",metakeysSelected,sqlSelectTrackWhere,oLibrary);
this->SQLSelectQuery(metakey->c_str(),"t.id IN (SELECT track_id FROM track_meta WHERE meta_value_id IN (",")) ",metakeysSelected,sqlSelectTrackWhere,library);
}
}
@ -367,17 +367,17 @@ bool Query::ListSelection::ParseQuery(Library::Base *oLibrary,db::Connection &db
// Genre
if(metakeysSelectedCopy.empty()){
this->QueryForMetadata("genre","SELECT g.id,g.name FROM genres g WHERE g.aggregated=0 ORDER BY g.sort_order",metakeysQueried,oLibrary,db);
this->QueryForMetadata("genre","SELECT g.id,g.name FROM genres g WHERE g.aggregated=0 ORDER BY g.sort_order",metakeysQueried,library,db);
}else{
this->QueryForMetadata("genre","SELECT g.id,g.name FROM genres g WHERE g.aggregated=0 AND g.id IN (SELECT genre_id FROM track_genres WHERE track_id IN (SELECT id FROM temp_tracks_list)) ORDER BY g.sort_order",metakeysQueried,oLibrary,db);
this->QueryForMetadata("genre","SELECT g.id,g.name FROM genres g WHERE g.aggregated=0 AND g.id IN (SELECT genre_id FROM track_genres WHERE track_id IN (SELECT id FROM temp_tracks_list)) ORDER BY g.sort_order",metakeysQueried,library,db);
}
// Artists
if(metakeysSelectedCopy.empty()){
this->QueryForMetadata("artist","SELECT a.id,a.name FROM artists a WHERE a.aggregated=0 ORDER BY a.sort_order",metakeysQueried,oLibrary,db);
this->QueryForMetadata("artist","SELECT a.id,a.name FROM artists a WHERE a.aggregated=0 ORDER BY a.sort_order",metakeysQueried,library,db);
}else{
this->QueryForMetadata("artist","SELECT a.id,a.name FROM artists a WHERE a.aggregated=0 AND a.id IN (SELECT artist_id FROM track_artists WHERE track_id IN (SELECT id FROM temp_tracks_list)) ORDER BY a.sort_order",metakeysQueried,oLibrary,db);
this->QueryForMetadata("artist","SELECT a.id,a.name FROM artists a WHERE a.aggregated=0 AND a.id IN (SELECT artist_id FROM track_artists WHERE track_id IN (SELECT id FROM temp_tracks_list)) ORDER BY a.sort_order",metakeysQueried,library,db);
}
////////////////////////////////////////////////
@ -385,30 +385,30 @@ bool Query::ListSelection::ParseQuery(Library::Base *oLibrary,db::Connection &db
// Album
if(metakeysSelectedCopy.empty()){
this->QueryForMetadata("album","SELECT a.id,a.name FROM albums a ORDER BY a.sort_order",metakeysQueried,oLibrary,db);
this->QueryForMetadata("album","SELECT a.id,a.name FROM albums a ORDER BY a.sort_order",metakeysQueried,library,db);
}else{
this->QueryForMetadata("album","SELECT a.id,a.name FROM albums a WHERE a.id IN (SELECT album_id FROM temp_tracks_list) ORDER BY a.sort_order",metakeysQueried,oLibrary,db);
this->QueryForMetadata("album","SELECT a.id,a.name FROM albums a WHERE a.id IN (SELECT album_id FROM temp_tracks_list) ORDER BY a.sort_order",metakeysQueried,library,db);
}
// Track
if(metakeysSelectedCopy.empty()){
this->QueryForMetadata("track","SELECT track,track FROM (SELECT DISTINCT(track) AS track FROM tracks ORDER BY track)",metakeysQueried,oLibrary,db);
this->QueryForMetadata("track","SELECT track,track FROM (SELECT DISTINCT(track) AS track FROM tracks ORDER BY track)",metakeysQueried,library,db);
}else{
this->QueryForMetadata("track","SELECT track,track FROM (SELECT DISTINCT(track) AS track FROM temp_tracks_list ORDER BY track)",metakeysQueried,oLibrary,db);
this->QueryForMetadata("track","SELECT track,track FROM (SELECT DISTINCT(track) AS track FROM temp_tracks_list ORDER BY track)",metakeysQueried,library,db);
}
// Year
if(metakeysSelectedCopy.empty()){
this->QueryForMetadata("year","SELECT year,year FROM (SELECT DISTINCT(year) AS year FROM tracks ORDER BY year)",metakeysQueried,oLibrary,db);
this->QueryForMetadata("year","SELECT year,year FROM (SELECT DISTINCT(year) AS year FROM tracks ORDER BY year)",metakeysQueried,library,db);
}else{
this->QueryForMetadata("year","SELECT year,year FROM (SELECT DISTINCT(year) AS year FROM temp_tracks_list ORDER BY year)",metakeysQueried,oLibrary,db);
this->QueryForMetadata("year","SELECT year,year FROM (SELECT DISTINCT(year) AS year FROM temp_tracks_list ORDER BY year)",metakeysQueried,library,db);
}
// Duration
if(metakeysSelectedCopy.empty()){
this->QueryForMetadata("duration","SELECT duration,duration FROM (SELECT DISTINCT(duration) AS duration FROM tracks ORDER BY duration)",metakeysQueried,oLibrary,db);
this->QueryForMetadata("duration","SELECT duration,duration FROM (SELECT DISTINCT(duration) AS duration FROM tracks ORDER BY duration)",metakeysQueried,library,db);
}else{
this->QueryForMetadata("duration","SELECT duration,duration FROM (SELECT DISTINCT(duration) AS duration FROM temp_tracks_list ORDER BY duration)",metakeysQueried,oLibrary,db);
this->QueryForMetadata("duration","SELECT duration,duration FROM (SELECT DISTINCT(duration) AS duration FROM temp_tracks_list ORDER BY duration)",metakeysQueried,library,db);
}
@ -434,7 +434,7 @@ bool Query::ListSelection::ParseQuery(Library::Base *oLibrary,db::Connection &db
}else{
sql.append(" AND mv.id IN (SELECT meta_value_id FROM track_meta WHERE track_id IN (SELECT id FROM temp_tracks_list))");
}
this->QueryForMetadata(metakey->c_str(),sql.c_str(),metakeysQueried,oLibrary,db);
this->QueryForMetadata(metakey->c_str(),sql.c_str(),metakeysQueried,library,db);
}
metakeyId.Reset();
@ -448,7 +448,7 @@ bool Query::ListSelection::ParseQuery(Library::Base *oLibrary,db::Connection &db
sql = "SELECT t.id,t.sum_duration,t.sum_filesize FROM temp_tracks_list t";
}
return (success && this->ParseTracksSQL(sql,oLibrary,db));
return (success && this->ParseTracksSQL(sql,library,db));
}
//////////////////////////////////////////
@ -474,9 +474,9 @@ void Query::ListSelection::SQLPrependWhereOrAnd(std::string &sql){
///\brief
///Helper method to construct SQL query for selected metakeys
//////////////////////////////////////////
void Query::ListSelection::SQLSelectQuery(const char *metakey,const char *sqlStart,const char *sqlEnd,std::set<std::string> &metakeysSelected,std::string &sqlSelectTrackWhere,Library::Base *oLibrary){
void Query::ListSelection::SQLSelectQuery(const char *metakey,const char *sqlStart,const char *sqlEnd,std::set<std::string> &metakeysSelected,std::string &sqlSelectTrackWhere,Library::Base *library){
if(!oLibrary->QueryCanceled()){
if(!library->QueryCanceled()){
SelectedMetadata::iterator selected = this->selectedMetadata.find(metakey);
if(selected!=this->selectedMetadata.end()){
@ -503,8 +503,8 @@ void Query::ListSelection::SQLSelectQuery(const char *metakey,const char *sqlSta
///\brief
///Method called by ParseQuery for every queried metakey
//////////////////////////////////////////
void Query::ListSelection::QueryForMetadata(const char *metakey,const char *sql,std::set<std::string> &metakeysQueried,Library::Base *oLibrary,db::Connection &db){
if(oLibrary->QueryCanceled())
void Query::ListSelection::QueryForMetadata(const char *metakey,const char *sql,std::set<std::string> &metakeysQueried,Library::Base *library,db::Connection &db){
if(library->QueryCanceled())
return;
if(metakeysQueried.find(metakey)!=metakeysQueried.end()){
@ -516,7 +516,7 @@ void Query::ListSelection::QueryForMetadata(const char *metakey,const char *sql,
int row(0);
{
boost::mutex::scoped_lock lock(oLibrary->oResultMutex);
boost::mutex::scoped_lock lock(library->oResultMutex);
this->metadataResults[metakey];
}
@ -531,14 +531,14 @@ void Query::ListSelection::QueryForMetadata(const char *metakey,const char *sql,
);
if( (++row)%10==0 ){
boost::mutex::scoped_lock lock(oLibrary->oResultMutex);
boost::mutex::scoped_lock lock(library->oResultMutex);
this->metadataResults[metakey].insert(this->metadataResults[metakey].end(),tempMetadataValues.begin(),tempMetadataValues.end());
tempMetadataValues.clear();
tempMetadataValues.reserve(10);
}
}
if(!tempMetadataValues.empty()){
boost::mutex::scoped_lock lock(oLibrary->oResultMutex);
boost::mutex::scoped_lock lock(library->oResultMutex);
this->metadataResults[metakey].insert(this->metadataResults[metakey].end(),tempMetadataValues.begin(),tempMetadataValues.end());
}
@ -546,6 +546,78 @@ void Query::ListSelection::QueryForMetadata(const char *metakey,const char *sql,
}
}
//////////////////////////////////////////
///\brief
///Recieve the query from XML
///
///\param queryNode
///Reference to query XML node
///
///The excpeted input format is like this:
///\code
///<query type="ListSelection">
/// <selections>
/// <selection key="genre">1,3,5,7</selection>
/// <selection key="artist">6,7,8</selection>
/// </selections>
/// <listeners>genre,artist,album</listeners>
///</query>
///\endcode
///
///\returns
///true when successfully recieved
//////////////////////////////////////////
bool Query::ListSelection::RecieveQuery(musik::core::xml::ParserNode &queryNode){
while( musik::core::xml::ParserNode node = queryNode.ChildNode() ){
if(node.Name()=="selections"){
// Get metakey nodes
// Expected tag is likle this:
// <selection key="genre">2,5,3</selection>
while( musik::core::xml::ParserNode selectionNode = node.ChildNode("selection") ){
// Wait for all content
selectionNode.WaitForContent();
// Split comaseparated list
typedef std::vector<std::string> StringVector;
StringVector values;
boost::algorithm::split(values,selectionNode.Content(),boost::algorithm::is_any_of(","));
for(StringVector::iterator value=values.begin();value!=values.end();++value){
this->SelectMetadata(selectionNode.Attributes()["key"].c_str(),boost::lexical_cast<DBINT>(*value));
}
}
}else if(node.Name()=="listeners"){
// Wait for all content
node.WaitForContent();
// Secondly, lets look for what to query for
// Split comaseparated list
typedef std::vector<std::string> StringVector;
StringVector keys;
boost::algorithm::split(keys,node.Content(),boost::algorithm::is_any_of(","));
for(StringVector::iterator key=keys.begin();key!=keys.end();++key){
if(!key->empty()){
// connect dummy to the signals
this->OnMetadataEvent(key->c_str()).connect( (Query::ListBase*)this,&Query::ListBase::DummySlot);
}
}
}else if(node.Name()=="listtracks"){
this->OnTrackEvent().connect( (Query::ListBase*)this,&Query::ListBase::DummySlotTracks);
}else if(node.Name()=="listtrackinfo"){
this->OnTrackInfoEvent().connect( (Query::ListBase*)this,&Query::ListBase::DummySlotTrackInfo);
}
}
return true;
}
std::string Query::ListSelection::Name(){
return "ListSelection";
}

View File

@ -81,14 +81,19 @@ namespace musik{ namespace core{
protected:
friend class Library::Base;
friend class Library::LocalDB;
friend class server::Connection;
virtual bool ParseQuery(Library::Base *oLibrary,db::Connection &db);
virtual std::string Name();
virtual bool ParseQuery(Library::Base *library,db::Connection &db);
Ptr copy() const;
virtual bool RecieveQuery(musik::core::xml::ParserNode &queryNode);
private:
typedef std::map<std::string,std::set<DBINT>> SelectedMetadata;
//////////////////////////////////////////
///\brief
///A map of selected metakeys
@ -109,8 +114,8 @@ namespace musik{ namespace core{
inline void SQLPrependWhereOrAnd(std::string &sql);
void SQLSelectQuery(const char *metakey,const char *sqlStart,const char *sqlEnd,std::set<std::string> &metakeysSelected,std::string &sqlSelectTrackWhere,Library::Base *oLibrary);
void QueryForMetadata(const char *metakey,const char *sql,std::set<std::string> &metakeysQueried,Library::Base *oLibrary,db::Connection &db);
void SQLSelectQuery(const char *metakey,const char *sqlStart,const char *sqlEnd,std::set<std::string> &metakeysSelected,std::string &sqlSelectTrackWhere,Library::Base *library);
void QueryForMetadata(const char *metakey,const char *sql,std::set<std::string> &metakeysQueried,Library::Base *library,db::Connection &db);
};

View File

@ -59,13 +59,13 @@ void Query::PlaylistLoad::LoadPlaylist(int playlistId){
this->playlistId = playlistId;
}
bool Query::PlaylistLoad::ParseQuery(Library::Base *oLibrary,db::Connection &db){
bool Query::PlaylistLoad::ParseQuery(Library::Base *library,db::Connection &db){
db::Statement selectTracks("SELECT track_id FROM playlist_tracks WHERE playlist_id=? ORDER BY sort_order",db);
selectTracks.BindInt(0,this->playlistId);
while(selectTracks.Step()==db::Row){
boost::mutex::scoped_lock lock(oLibrary->oResultMutex);
boost::mutex::scoped_lock lock(library->oResultMutex);
this->trackResults.push_back(TrackPtr(new Track(selectTracks.ColumnInt(0))));
}
return true;

View File

@ -73,7 +73,7 @@ namespace musik{ namespace core{
friend class Library::Base;
friend class Library::LocalDB;
virtual bool ParseQuery(Library::Base *oLibrary,db::Connection &db);
virtual bool ParseQuery(Library::Base *library,db::Connection &db);
Ptr copy() const;

View File

@ -67,7 +67,7 @@ void Query::PlaylistSave::SavePlaylist(int playlistId,utfstring playlistName,mus
}
}
bool Query::PlaylistSave::ParseQuery(Library::Base *oLibrary,db::Connection &db){
bool Query::PlaylistSave::ParseQuery(Library::Base *library,db::Connection &db){
db::ScopedTransaction transaction(db);
@ -113,8 +113,8 @@ Query::Ptr Query::PlaylistSave::copy() const{
return Query::Ptr(new Query::PlaylistSave(*this));
}
bool Query::PlaylistSave::RunCallbacks(Library::Base *oLibrary){
boost::mutex::scoped_lock lock(oLibrary->oResultMutex);
bool Query::PlaylistSave::RunCallbacks(Library::Base *library){
boost::mutex::scoped_lock lock(library->oResultMutex);
if( (this->status & Status::Ended)!=0){
this->PlaylistSaved(this->playlistId);
return true;

View File

@ -70,7 +70,7 @@ namespace musik{ namespace core{
protected:
bool RunCallbacks(Library::Base *oLibrary);
bool RunCallbacks(Library::Base *library);
int playlistId;
utfstring playlistName;
@ -80,7 +80,7 @@ namespace musik{ namespace core{
friend class Library::Base;
friend class Library::LocalDB;
virtual bool ParseQuery(Library::Base *oLibrary,db::Connection &db);
virtual bool ParseQuery(Library::Base *library,db::Connection &db);
Ptr copy() const;

View File

@ -56,7 +56,7 @@ Query::Playlists::~Playlists(void){
}
bool Query::Playlists::ParseQuery(Library::Base *oLibrary,db::Connection &db){
bool Query::Playlists::ParseQuery(Library::Base *library,db::Connection &db){
return true;
}
@ -72,7 +72,7 @@ Query::Ptr Query::Playlists::copy() const{
return Query::Ptr(new Query::Playlists(*this));
}
bool Query::Playlists::RunCallbacks(Library::Base *oLibrary){
bool Query::Playlists::RunCallbacks(Library::Base *library){
return true;
}

View File

@ -66,12 +66,12 @@ namespace musik{ namespace core{
protected:
bool RunCallbacks(Library::Base *oLibrary);
bool RunCallbacks(Library::Base *library);
friend class Library::Base;
friend class Library::LocalDB;
virtual bool ParseQuery(Library::Base *oLibrary,db::Connection &db);
virtual bool ParseQuery(Library::Base *library,db::Connection &db);
Ptr copy() const;

View File

@ -56,7 +56,7 @@ Query::SortTracks::~SortTracks(void){
}
bool Query::SortTracks::ParseQuery(Library::Base *oLibrary,db::Connection &db){
bool Query::SortTracks::ParseQuery(Library::Base *library,db::Connection &db){
std::vector<int> sortFieldsMetakeyId;
@ -165,7 +165,7 @@ bool Query::SortTracks::ParseQuery(Library::Base *oLibrary,db::Connection &db){
std::string sql=selectSQL+" FROM "+selectSQLTables+selectSQLWhere+selectSQLGroup+selectSQLSort;
return this->ParseTracksSQL(sql,oLibrary,db);
return this->ParseTracksSQL(sql,library,db);
}
//////////////////////////////////////////

View File

@ -81,7 +81,7 @@ namespace musik{ namespace core{
friend class Library::Base;
friend class Library::LocalDB;
virtual bool ParseQuery(Library::Base *oLibrary,db::Connection &db);
virtual bool ParseQuery(Library::Base *library,db::Connection &db);
Ptr copy() const;

View File

@ -131,7 +131,7 @@ void TrackMetadata::GetFixedTrackMetakeys(std::string &fieldName,std::set<std::s
}
bool TrackMetadata::ParseQuery(Library::Base *oLibrary,db::Connection &db){
bool TrackMetadata::ParseQuery(Library::Base *library,db::Connection &db){
db::CachedStatement genres("SELECT g.name FROM genres g,track_genres tg WHERE tg.genre_id=g.id AND tg.track_id=? ORDER BY tg.id",db);
db::CachedStatement artists("SELECT ar.name FROM artists ar,track_artists ta WHERE ta.artist_id=ar.id AND ta.track_id=? ORDER BY ta.id",db);
@ -213,7 +213,7 @@ bool TrackMetadata::ParseQuery(Library::Base *oLibrary,db::Connection &db){
{
boost::mutex::scoped_lock oLock(oLibrary->oResultMutex);
boost::mutex::scoped_lock oLock(library->oResultMutex);
this->aResultTracks.push_back(track);
}
}
@ -221,7 +221,7 @@ bool TrackMetadata::ParseQuery(Library::Base *oLibrary,db::Connection &db){
trackData.Reset();
{
boost::mutex::scoped_lock oLock(oLibrary->oResultMutex);
boost::mutex::scoped_lock oLock(library->oResultMutex);
bCancel = ((this->status & Status::Canceled)!=0);
}
@ -229,21 +229,21 @@ bool TrackMetadata::ParseQuery(Library::Base *oLibrary,db::Connection &db){
{
boost::mutex::scoped_lock oLock(oLibrary->oResultMutex);
boost::mutex::scoped_lock oLock(library->oResultMutex);
this->status |= Status::Ended;
}
return true;
}
bool TrackMetadata::RunCallbacks(Library::Base *oLibrary){
bool TrackMetadata::RunCallbacks(Library::Base *library){
TrackVector aResultCopy;
bool bReturn(false);
// First swap the results so that Query can continue to parse
{
boost::mutex::scoped_lock oLock(oLibrary->oResultMutex);
boost::mutex::scoped_lock oLock(library->oResultMutex);
aResultCopy.swap(this->aResultTracks);
if( (this->status & Status::Ended)!=0){

View File

@ -61,7 +61,7 @@ class TrackMetadata : public Query::Base {
TrackMetadata(void);
~TrackMetadata(void);
bool RunCallbacks(Library::Base *oLibrary);
bool RunCallbacks(Library::Base *library);
void Clear();
void RequestTrack(TrackPtr track);
@ -89,7 +89,7 @@ class TrackMetadata : public Query::Base {
protected:
friend class Library::Base;
friend class Library::LocalDB;
bool ParseQuery(Library::Base *oLibrary,db::Connection &db);
bool ParseQuery(Library::Base *library,db::Connection &db);
Ptr copy() const;
void PreAddQuery(Library::Base *library);
};

145
src/core/Server.cpp Normal file
View File

@ -0,0 +1,145 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include "Server.h"
#include <core/Preferences.h>
#include <core/Common.h>
#include <core/Library/Base.h>
#include <core/db/Connection.h>
#include <boost/bind.hpp>
using namespace musik::core;
Server::Server(unsigned int port)
:exitThread(false)
,acceptor(ioService,boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port))
{
this->acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
}
Server::~Server(void){
this->connections.clear();
this->nextConnection.reset();
this->Exit();
this->threads.join_all();
}
void Server::Exit(){
boost::mutex::scoped_lock lock(this->serverMutex);
this->exitThread = true;
this->ioService.stop();
}
bool Server::Exited(){
boost::mutex::scoped_lock lock(this->serverMutex);
return this->exitThread;
}
bool Server::Startup(){
// Start the server thread
this->threads.create_thread(boost::bind(&Server::ThreadLoop,this));
return true;
}
void Server::ThreadLoop(){
// Get server preferences
musik::core::Preferences prefs("Server");
// Get directory and database paths
utfstring directory( musik::core::GetDataDirectory()+UTF("server/") );
utfstring database(directory+UTF("musik.db"));
{
// Create database
db::Connection db;
db.Open(database.c_str(),0,prefs.GetInt("DatabaseCache",4096));
Library::Base::CreateDatabase(db);
}
// Start the indexer
this->indexer.database = database;
this->indexer.Startup(directory);
while(!this->Exited()){
// tcp/ip port
// int port( prefs.GetInt("ipPort",10543) );
boost::system::error_code error;
// Connect the next socket connection
this->SetNextConnection();
// loop, waiting for incomming connections
this->ioService.run(error);
}
}
void Server::SetNextConnection(){
this->nextConnection.reset( new musik::core::server::Connection(this->ioService) );
this->acceptor.async_accept(this->nextConnection->Socket(),boost::bind(&Server::AcceptConnection,this,boost::asio::placeholders::error));
}
void Server::AcceptConnection(const boost::system::error_code& error){
if(!error){
this->CleanupConnections();
// Start the connection
this->nextConnection->Startup();
this->connections.push_back(this->nextConnection);
this->SetNextConnection();
}
}
void Server::CleanupConnections(){
for(server::ConnectionVector::iterator connection=this->connections.begin();connection!=this->connections.end();){
if( (*connection)->Exited() ){
connection = this->connections.erase(connection);
}else{
++connection;
}
}
}

89
src/core/Server.h Normal file
View File

@ -0,0 +1,89 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <core/server/Connection.h>
#include <core/Indexer.h>
#include <boost/asio.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{
//////////////////////////////////////////////////////////////////////////////
class Server{
public:
// Methods
Server(unsigned int port);
~Server(void);
bool Startup();
public:
Indexer indexer;
private:
// Methods
void Exit();
bool Exited();
void ThreadLoop();
void AcceptConnection(const boost::system::error_code& error);
void SetNextConnection();
void CleanupConnections();
private:
// Variables
boost::asio::io_service ioService;
boost::asio::ip::tcp::acceptor acceptor;
bool exitThread;
boost::mutex serverMutex;
boost::thread_group threads;
musik::core::server::ConnectionVector connections;
musik::core::server::ConnectionPtr nextConnection;
};
//////////////////////////////////////////////////////////////////////////////
} }

View File

@ -46,14 +46,14 @@ ThreadHelper::ThreadHelper(void):bExit(false){
ThreadHelper::~ThreadHelper(void){
}
bool ThreadHelper::Exit(void){
bool ThreadHelper::Exited(){
boost::mutex::scoped_lock oLock(this->exitMutex);
return this->bExit;
}
void ThreadHelper::Exit(bool bNewExit){
void ThreadHelper::Exit(){
boost::mutex::scoped_lock oLock(this->exitMutex);
this->bExit = bNewExit;
this->bExit = true;
this->notify.notify_all();
}

View File

@ -47,10 +47,10 @@ namespace musik{ namespace core{
ThreadHelper(void);
~ThreadHelper(void);
virtual void Exit(bool bNewExit);
virtual void Exit();
boost::mutex exitMutex;
protected:
bool Exit(void);
bool Exited();
void NotificationWait();
void NotificationTimedWait(const boost::xtime &oTime);

View File

@ -45,6 +45,7 @@
#include <core/config.h>
#include <core/TrackMeta.h>
#include <core/db/Connection.h>
#include <core/ITrack.h>
namespace musik{ namespace core{
@ -76,7 +77,7 @@ namespace musik{ namespace core{
* \see
* TrackPtr|TrackVector
*/
class Track : boost::noncopyable{
class Track : public ITrack {
public:
Track(void);
Track(DBINT newId);
@ -87,10 +88,11 @@ namespace musik{ namespace core{
//void SetValue(const TrackMeta::Key &key,TrackMeta::Value &value);
DLLEXPORT TrackMeta::TagMapIteratorPair GetValues(const char* metakey) const;
DLLEXPORT const utfchar* GetValue(const char* metakey) const;
DLLEXPORT void SetValue(const char* metakey,const utfchar* value);
DLLEXPORT void SetThumbnail(const char *data,unsigned int size);
TrackMeta::TagMapIteratorPair GetValues(const char* metakey) const;
const utfchar* GetValue(const char* metakey) const;
void SetValue(const char* metakey,const utfchar* value);
void SetThumbnail(const char *data,unsigned int size);
void InitMeta(Library::Base *library);

View File

@ -2,7 +2,7 @@
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
@ -48,7 +48,8 @@
#include <TCHAR.h>
#ifndef MUSIKCOREIMPORT
#define DLLEXPORT __declspec( dllexport )
//#define DLLEXPORT __declspec( dllexport )
#define DLLEXPORT
#else
#define DLLEXPORT __declspec( dllimport )
#endif
@ -96,7 +97,7 @@ typedef unsigned int DBTIME;
// Boost specific
namespace boost{
namespace filesystem{
typedef wpath utfpath;
typedef boost::filesystem::wpath utfpath;
typedef wdirectory_iterator utfdirectory_iterator;
}

View File

@ -40,7 +40,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
PreprocessorDefinitions="BOOST_ALL_NO_LIB;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE"
PreprocessorDefinitions="BOOST_ALL_NO_LIB;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;XML_STATIC"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@ -107,7 +107,7 @@
InlineFunctionExpansion="0"
FavorSizeOrSpeed="0"
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
PreprocessorDefinitions="BOOST_ALL_NO_LIB;WIN32;_CRT_SECURE_NO_DEPRECATE"
PreprocessorDefinitions="BOOST_ALL_NO_LIB;WIN32;_CRT_SECURE_NO_DEPRECATE;XML_STATIC"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="pch.hpp"
@ -150,6 +150,10 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\ITrack.h"
>
</File>
<File
RelativePath=".\pch.cpp"
>
@ -282,6 +286,14 @@
RelativePath=".\Query\Base.h"
>
</File>
<File
RelativePath=".\Query\Factory.cpp"
>
</File>
<File
RelativePath=".\Query\Factory.h"
>
</File>
<File
RelativePath=".\Query\ListBase.cpp"
>
@ -504,6 +516,88 @@
>
</File>
</Filter>
<Filter
Name="server"
>
<File
RelativePath=".\server\Connection.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\$(InputName)1.obj"
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\$(InputName)1.obj"
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\server\Connection.h"
>
</File>
<File
RelativePath=".\Server.cpp"
>
</File>
<File
RelativePath=".\Server.h"
>
</File>
</Filter>
<Filter
Name="xml"
>
<File
RelativePath=".\xml\Node.cpp"
>
</File>
<File
RelativePath=".\xml\Node.h"
>
</File>
<File
RelativePath=".\xml\Parser.cpp"
>
</File>
<File
RelativePath=".\xml\Parser.h"
>
</File>
<File
RelativePath=".\xml\ParserNode.cpp"
>
</File>
<File
RelativePath=".\xml\ParserNode.h"
>
</File>
<File
RelativePath=".\xml\Writer.cpp"
>
</File>
<File
RelativePath=".\xml\Writer.h"
>
</File>
<File
RelativePath=".\xml\WriterNode.cpp"
>
</File>
<File
RelativePath=".\xml\WriterNode.h"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>

View File

@ -40,6 +40,7 @@
#include <core/db/CachedStatement.h>
#include <core/db/Statement.h>
#include <core/db/Connection.h>
#include <sqlite/sqlite3.h>
using namespace musik::core::db;

View File

@ -37,6 +37,7 @@
#include "pch.hpp"
#include <core/db/Connection.h>
#include <boost/lexical_cast.hpp>
#include <sqlite/sqlite3.h>
using namespace musik::core::db;
@ -45,6 +46,7 @@ using namespace musik::core::db;
///Constructor
//////////////////////////////////////////
Connection::Connection() : connection(NULL),transactionCounter(0) {
this->Maintenance(true);
}
@ -56,6 +58,7 @@ Connection::Connection() : connection(NULL),transactionCounter(0) {
//////////////////////////////////////////
Connection::~Connection(){
this->Close();
this->Maintenance(false);
}
@ -76,6 +79,8 @@ Connection::~Connection(){
///Error code returned by SQLite
//////////////////////////////////////////
int Connection::Open(const utfchar *database,unsigned int options,unsigned int cache){
sqlite3_enable_shared_cache(1);
int error;
#ifdef UTF_WIDECHAR
error = sqlite3_open16(database,&this->connection);
@ -106,6 +111,8 @@ int Connection::Open(const utfchar *database,unsigned int options,unsigned int c
///Error code returned by SQLite
//////////////////////////////////////////
int Connection::Open(const utfstring &database,unsigned int options,unsigned int cache){
sqlite3_enable_shared_cache(1);
int error;
#ifdef UTF_WIDECHAR
error = sqlite3_open16(database.c_str(),&this->connection);
@ -291,12 +298,6 @@ sqlite3_stmt *Connection::GetCachedStatement(const char* sql){
boost::mutex::scoped_lock lock(this->mutex);
int err = sqlite3_prepare_v2(this->connection,sql,-1,&newStmt,NULL);
/* #ifdef _DEBUG
if(err!=0){
const char *errorMsg = sqlite3_errmsg(this->connection);
_ASSERT(false);
}
#endif*/
return newStmt;
}
@ -338,3 +339,20 @@ void Connection::Interrupt(){
boost::mutex::scoped_lock lock(this->mutex);
sqlite3_interrupt(this->connection);
}
void Connection::Maintenance(bool init){
static int counter(0);
if(init){
if(counter==0){
sqlite3_initialize();
}
++counter;
}else{
--counter;
if(counter==0){
sqlite3_shutdown();
}
}
}

View File

@ -45,10 +45,15 @@
#include <boost/utility.hpp>
#include <boost/thread/mutex.hpp>
//////////////////////////////////////////
// Forward declare
struct sqlite3;
struct sqlite3_stmt;
//////////////////////////////////////////
namespace musik{ namespace core{ namespace db{
//////////////////////////////////////////
///\brief
///Database Wrapper
@ -88,6 +93,8 @@ namespace musik{ namespace core{ namespace db{
boost::mutex mutex;
void Maintenance(bool init);
};

View File

@ -39,6 +39,7 @@
#include "pch.hpp"
#include <core/db/Statement.h>
#include <core/db/Connection.h>
#include <sqlite/sqlite3.h>
using namespace musik::core::db;
@ -55,12 +56,6 @@ using namespace musik::core::db;
Statement::Statement(const char* sql,Connection &connection) : connection(&connection),stmt(NULL){
boost::mutex::scoped_lock lock(connection.mutex);
int err = sqlite3_prepare_v2(this->connection->connection,sql,-1,&this->stmt,NULL);
/* #ifdef _DEBUG
if(err!=0){
const char *errorMsg = sqlite3_errmsg(this->connection->connection);
_ASSERT(false);
}
#endif*/
}
//////////////////////////////////////////
@ -86,12 +81,6 @@ Statement::~Statement(){
//////////////////////////////////////////
void Statement::Reset(){
int err = sqlite3_reset(this->stmt);
/* #ifdef _DEBUG
if(err!=0){
const char *errorMsg = sqlite3_errmsg(this->connection->connection);
_ASSERT(false);
}
#endif*/
}
//////////////////////////////////////////

View File

@ -40,7 +40,12 @@
#include <map>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
#include <sqlite/sqlite3.h>
//////////////////////////////////////////
// Forward declare
struct sqlite3_stmt;
//////////////////////////////////////////
namespace musik{ namespace core{ namespace db{

View File

@ -36,11 +36,10 @@
#pragma once
#include <sqlite/sqlite3.h>
#ifdef _DEBUG
// #define DB_ASSERT(x) _ASSERT(x==0)
#define DB_ASSERT(x) x
#define DB_ASSERT(x) _ASSERT(x==0)
// #define DB_ASSERT(x) x
#else
#define DB_ASSERT(x) x
#endif
@ -53,10 +52,10 @@ namespace musik{ namespace core{ namespace db{
///The ReturnCode is used by several method to return the status of a execution
//////////////////////////////////////////
enum ReturnCode : int{
OK = SQLITE_OK,
Row = SQLITE_ROW,
Done = SQLITE_DONE,
Error = SQLITE_ERROR
OK = 0,
Row = 100,
Done = 101,
Error = 1
};
} } }

View File

@ -0,0 +1,264 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include <core/server/Connection.h>
#include <core/Preferences.h>
#include <core/Query/Factory.h>
#include <core/xml/Parser.h>
#include <core/xml/ParserNode.h>
#include <core/xml/Writer.h>
#include <core/xml/WriterNode.h>
using namespace musik::core::server;
Connection::Connection(boost::asio::io_service &ioService)
:socket(ioService)
{
this->identifier = UTF("server");
}
Connection::~Connection(void){
this->Exit();
this->threads.join_all();
}
boost::asio::ip::tcp::socket &Connection::Socket(){
return this->socket;
}
//////////////////////////////////////////
///\brief
///Start the Connections threads
///
///3 different threads will be started:
///1. Reading from the socket and parsing the XML, adding queries to the queue.
///2. One thread for executing the Queries
///3. And one thread for sending the results
//////////////////////////////////////////
bool Connection::Startup(){
std::cout << "Connection::Startup" << std::endl;
this->threads.create_thread(boost::bind(&Connection::ReadThread,this));
this->threads.create_thread(boost::bind(&Connection::ParseThread,this));
this->threads.create_thread(boost::bind(&Connection::WriteThread,this));
return true;
}
void Connection::ReadThread(){
musik::core::xml::Parser xmlParser(&this->socket);
try{
// Test waiting for a Node
if( musik::core::xml::ParserNode root = xmlParser.ChildNode("musik") ){
// musik node initialized
musik::core::Query::QueryMap queryMap;
musik::core::Query::Factory::GetQueries(queryMap);
// Loop waiting for queries
while( musik::core::xml::ParserNode queryNode = root.ChildNode("query") ){
// Got a query
std::string queryType(queryNode.Attributes()["type"]);
musik::core::Query::QueryMap::iterator queryIt = queryMap.find(queryType);
if(queryIt!=queryMap.end()){
// Query type exists, lets create a copy
musik::core::Query::Ptr query( queryIt->second->copy() );
if(query->RecieveQuery(queryNode)){
// TODO: check for AddQuery options in tag
this->AddQuery( *query );
}
}
}
}
}
catch(...){
// Connection dropped
std::cout << "Connection dropped" << std::endl;
}
this->Exit();
}
void Connection::ParseThread(){
Preferences prefs("Server");
utfstring database(this->GetDBPath());
this->db.Open(database.c_str(),0,prefs.GetInt("DatabaseCache",4096));
while(!this->Exited()){
Query::Ptr query(this->GetNextQuery());
if(query){ // No empty query
////////////////////////////////////////////////////////////
// Add to the finished queries
{
boost::mutex::scoped_lock lock(this->libraryMutex);
this->bCurrentQueryCanceled = false;
this->runningQuery = query;
this->outgoingQueries.push_back(query);
// Set query as started
query->status |= Query::Base::Status::Started;
}
////////////////////////////////////////////////////////////
// Lets parse the query
query->ParseQuery(this,this->db);
{
boost::mutex::scoped_lock lock(this->libraryMutex);
this->runningQuery.reset();
// And set it as finished
query->status |= Query::Base::Status::Ended;
}
////////////////////////////////////////////////////////////
// Notify that the Query is finished.
this->waitCondition.notify_all();
}else{
////////////////////////////////////////////////////////////
// Tricky part, waiting for queries to be added.
// Not sure I'm doing this the right way.
// Could this part lead to a deadlock???
boost::mutex::scoped_lock lock(this->libraryMutex);
if(!this->exit && this->incomingQueries.size()==0 ){
this->waitCondition.wait(lock);
}
}
}
this->db.Close();
}
void Connection::WriteThread(){
musik::core::xml::Writer xmlWriter(&this->socket);
try{
// Lets start with a <musik> node
musik::core::xml::WriterNode musikNode(xmlWriter,"musik");
while(!this->Exited()){
Query::Ptr sendQuery;
// Wait for outgoingQueries
{
boost::mutex::scoped_lock lock(this->libraryMutex);
if(this->outgoingQueries.empty()){
this->waitCondition.wait(lock);
}
if(!this->outgoingQueries.empty()){
sendQuery = this->outgoingQueries.front();
}
}
// now there should be sendQuery
if(sendQuery){
// Send the query
{
musik::core::xml::WriterNode queryNode(musikNode,"queryresults");
queryNode.Attributes()["type"] = sendQuery->Name();
sendQuery->SendResults(queryNode,this);
}
// Remove the query from the queue
{
boost::mutex::scoped_lock lock(this->libraryMutex);
// We can not be sure that the query is the front query
//so lets loop through the outgoing queries and remove the match
for(QueryList::iterator query=this->outgoingQueries.begin();query!=this->outgoingQueries.end();){
if( sendQuery== *query ){
query = this->outgoingQueries.erase(query);
}else{
++query;
}
}
}
}
}
}
catch(...){
}
this->Exit();
}
//////////////////////////////////////////
///\brief
///Cancel the current running query
///
///This method will also send a sqlite3_interrupt to cancel the
///current running SQL Query
//////////////////////////////////////////
void Connection::CancelCurrentQuery( ){
this->bCurrentQueryCanceled = true;
this->db.Interrupt();
}
utfstring Connection::GetInfo(){
return UTF("");
}
void Connection::Exit(){
{
boost::mutex::scoped_lock lock(this->libraryMutex);
if(!this->exit){
if(this->socket.is_open()){
this->socket.close();
}
}
this->exit = true;
}
this->waitCondition.notify_all();
}

View File

@ -0,0 +1,92 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <core/Library/Base.h>
#include <core/db/Connection.h>
#include <boost/asio.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/mutex.hpp>
#include <vector>
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{ namespace server{
//////////////////////////////////////////////////////////////////////////////
// Forward declare
class Connection;
typedef boost::shared_ptr<Connection> ConnectionPtr;
typedef std::vector<ConnectionPtr> ConnectionVector;
//////////////////////////////////////////////////////////////////////////////
class Connection : public musik::core::Library::Base{
public:
Connection(boost::asio::io_service &ioService);
~Connection(void);
utfstring GetInfo();
bool Startup();
boost::asio::ip::tcp::socket &Socket();
private:
// Methods:
void ReadThread();
void ParseThread();
void WriteThread();
protected:
void CancelCurrentQuery( );
virtual void Exit();
private:
boost::asio::ip::tcp::socket socket;
boost::thread_group threads;
musik::core::db::Connection db;
};
//////////////////////////////////////////////////////////////////////////////
} } }

102
src/core/xml/Node.cpp Normal file
View File

@ -0,0 +1,102 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include "Node.h"
#include <core/xml/Parser.h>
using namespace musik::core::xml;
Node::Node()
:status(0)
{
}
Node::Node(Ptr parent)
:status(0)
,parent(parent)
{
}
Node::~Node(void){
if(this->parent){
// Erase in parents childnodes
for(ChildNodes::iterator node=this->parent->childNodes.begin();node!=this->parent->childNodes.end();){
if( node->px==this ){
node = this->parent->childNodes.erase(node);
}else{
++node;
}
}
}
}
std::string Node::NodeLevelPath(){
std::string nodeLevels(this->name);
Ptr currentNode = this->parent;
while(currentNode){
nodeLevels = currentNode->name + "/" + nodeLevels;
currentNode = currentNode->parent;
}
return nodeLevels;
}
int Node::NodeLevel(){
int level(1);
Ptr currentNode = this->parent;
while(currentNode){
level++;
currentNode = currentNode->parent;
}
return level;
}
void Node::RemoveFromParent(){
if(this->parent){
for(Node::ChildNodes::iterator node=this->parent->childNodes.begin();node!=this->parent->childNodes.end();){
if( this == node->px ){
node = this->parent->childNodes.erase(node);
}else{
++node;
}
}
}
}

98
src/core/xml/Node.h Normal file
View File

@ -0,0 +1,98 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <string>
#include <map>
#include <list>
#include <boost/shared_ptr.hpp>
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{ namespace xml{
//////////////////////////////////////////////////////////////////////////////
// Forward declare
class Parser;
class ParserNode;
class Writer;
class WriterNode;
//////////////////////////////////////////////////////////////////////////////
class Node{
public:
~Node(void);
private:
friend class Parser;
friend class ParserNode;
friend class Writer;
friend class WriterNode;
typedef boost::shared_ptr<Node> Ptr;
Node();
Node(Ptr parent);
typedef std::map<std::string,std::string> AttributeMap;
AttributeMap attributes;
std::string name;
std::string content;
std::string NodeLevelPath();
int NodeLevel();
enum Status:int{
Started = 1,
Ended = 2,
StartSend = 4,
EndSend = 8,
};
unsigned int status;
Ptr parent;
typedef std::list<Ptr> ChildNodes;
ChildNodes childNodes;
void RemoveFromParent();
};
//////////////////////////////////////////////////////////////////////////////
} } }

219
src/core/xml/Parser.cpp Normal file
View File

@ -0,0 +1,219 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include <core/xml/Parser.h>
#include <core/xml/ParserNode.h>
using namespace musik::core::xml;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////
///\brief
///Constructor
///
///\param socket
///pointer to boost::asio socket to be used by the Parser
///
///The Parser will continously parse XML and
///read from the socket when there is no buffer
///left in the parser.
//////////////////////////////////////////
Parser::Parser(boost::asio::ip::tcp::socket *socket)
:level(0)
,xmlParser(NULL)
,socket(socket)
,xmlParserStatus(XML_Status::XML_STATUS_OK)
,readBufferLength(0)
,currentEventType(0)
,exit(false)
{
// Set node stuff
this->parser = this;
this->xmlParser = XML_ParserCreate(NULL);
XML_SetUserData(this->xmlParser,this);
XML_SetElementHandler(this->xmlParser,&Parser::OnElementStart,&Parser::OnElementEnd);
XML_SetCharacterDataHandler(this->xmlParser,&Parser::OnContent);
}
//////////////////////////////////////////////////////////////////////////////
Parser::~Parser(void){
XML_ParserFree(this->xmlParser);
}
//////////////////////////////////////////////////////////////////////////////
void Parser::OnElementStart(void *thisobject,const char *name, const char **atts){
((Parser*)thisobject)->OnElementStartReal(name,atts);
}
void Parser::OnElementStartReal(const char *name, const char **atts){
this->xmlFound = true;
this->level++;
// First, lets create the new Node and add to the nodeLevels
Node::Ptr node(new Node());
node->name = name;
// fix attributes
for (int i(0);atts[i];i+=2){
node->attributes[atts[i]] = atts[i + 1];
}
// Set the parent node
if(!this->currentNodeLevels.empty()){
node->parent = this->currentNodeLevels.back();
}
this->currentNodeLevels.push_back(node);
this->currentEventType = EventTypes::NodeStart;
XML_StopParser(this->xmlParser,true);
}
//////////////////////////////////////////////////////////////////////////////
void Parser::OnElementEnd(void *thisobject,const char *name){
((Parser*)thisobject)->OnElementEndReal(name);
}
void Parser::OnElementEndReal(const char *name){
this->xmlFound = true;
this->level--;
if(this->currentNodeLevels.size()>0){
if(this->currentNodeLevels.back()->name == name){
this->currentNodeLevels.back()->status = Node::Status::Ended;
this->currentNodeLevels.pop_back();
this->currentEventType = EventTypes::NodeEnd;
XML_StopParser(this->xmlParser,true);
}else{
// Wrong endtag expected, mallformated input
this->Exit();
XML_StopParser(this->xmlParser,true);
}
}else{
// below root level, mallformated input
this->Exit();
XML_StopParser(this->xmlParser,true);
}
}
//////////////////////////////////////////////////////////////////////////////
void Parser::OnContent(void *thisobject,const char *content,int length){
((Parser*)thisobject)->OnContentReal(content,length);
}
void Parser::OnContentReal(const char *content,int length){
if(this->currentNodeLevels.size()>0){
this->currentNodeLevels.back()->content.append(content,length);
}
}
//////////////////////////////////////////////////////////////////////////////
void Parser::ReadFromSocket(){
boost::system::error_code error;
this->readBufferLength = this->socket->read_some(boost::asio::buffer(this->readBuffer),error);
if(error){
// Connection closed or some other error occured
this->Exit();
}
}
//////////////////////////////////////////////////////////////////////////////
void Parser::ContinueParsing(){
this->xmlFound = false;
while(!this->xmlFound && !this->exit){
switch(this->xmlParserStatus){
case XML_Status::XML_STATUS_SUSPENDED:
this->xmlParserStatus = XML_ResumeParser(this->xmlParser);
break;
case XML_Status::XML_STATUS_OK:
this->ReadFromSocket();
this->xmlParserStatus = XML_Parse(this->xmlParser,this->readBuffer.c_array(),this->readBufferLength,0);
break;
case XML_Status::XML_STATUS_ERROR:
this->Exit();
break;
}
}
}
void Parser::Exit(){
this->exit = true;
for(std::vector<Node::Ptr>::iterator node=this->currentNodeLevels.begin();node!=this->currentNodeLevels.end();++node){
(*node)->status = Node::Status::Ended;
}
}
//////////////////////////////////////////////////////////////////////////////
std::string Parser::CurrentNodeLevelPath(bool getParent){
std::string nodeLevels;
bool first(true);
int i(0);
for(std::vector<Node::Ptr>::iterator node=this->currentNodeLevels.begin();node!=this->currentNodeLevels.end();++node){
++i;
if(!getParent || this->currentNodeLevels.size()!=i){
if(first){
first=false;
nodeLevels += (*node)->name;
}else{
nodeLevels += "/"+(*node)->name;
}
}
}
return nodeLevels;
}
//////////////////////////////////////////////////////////////////////////////
Node::Ptr Parser::LastNode(){
if(this->currentNodeLevels.empty()){
return Node::Ptr();
}
return this->currentNodeLevels.back();
}

116
src/core/xml/Parser.h Normal file
View File

@ -0,0 +1,116 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <expat/expat.h>
#include <sigslot/sigslot.h>
#include <string>
#include <vector>
#include <set>
#include <boost/asio.hpp>
#include <boost/array.hpp>
#include <core/xml/Node.h>
#include <core/xml/ParserNode.h>
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{ namespace xml{
// Forward
class ParserNode;
//////////////////////////////////////////////////////////////////////////////
class Parser : public ParserNode{
public:
Parser(boost::asio::ip::tcp::socket *socket);
~Parser();
private:
// XML Parser status
XML_Parser xmlParser;
int xmlParserStatus;
// XML specific info
int level;
std::vector<Node::Ptr> currentNodeLevels;
// Socket stuff
boost::asio::ip::tcp::socket *socket;
boost::array<char, 4096> readBuffer;
size_t readBufferLength;
private:
static void OnElementStart(void *thisobject,const char *name, const char **atts);
void OnElementStartReal(const char *name, const char **atts);
static void OnElementEnd(void *thisobject,const char *name);
void OnElementEndReal(const char *name);
static void OnContent(void *thisobject,const char *content,int length);
void OnContentReal(const char *content,int length);
private:
void ReadFromSocket();
private:
friend class ParserNode;
bool exit;
void Exit();
enum EventTypes:int{
NodeStart=1,
NodeEnd=2,
Content=3
};
Node::Ptr LastNode();
void ContinueParsing();
std::string CurrentNodeLevelPath(bool getParent=false);
int currentEventType;
bool xmlFound;
};
//////////////////////////////////////////////////////////////////////////////
} } }

227
src/core/xml/ParserNode.cpp Normal file
View File

@ -0,0 +1,227 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include <core/xml/ParserNode.h>
#include <core/xml/Parser.h>
using namespace musik::core::xml;
ParserNode::ParserNode()
:status(0)
,parser(NULL)
{
}
ParserNode& ParserNode::operator=(ParserNode const &copyNode){
this->node = copyNode.node;
this->parentNode = copyNode.parentNode;
this->parser = copyNode.parser;
this->status = copyNode.status;
return *this;
}
ParserNode::ParserNode(const ParserNode *parent)
: status(0)
{
this->parentNode = parent->node;
this->parser = parent->parser;
std::set<std::string> nodeNames;
this->WaitForNode(nodeNames);
}
ParserNode::ParserNode(const ParserNode *parent,std::string &expectedNode)
: status(0)
{
this->parentNode = parent->node;
this->parser = parent->parser;
std::set<std::string> nodeNames;
nodeNames.insert(expectedNode);
this->WaitForNode(nodeNames);
}
//////////////////////////////////////////
///\brief
///Get the first childnode of the current node
//////////////////////////////////////////
ParserNode ParserNode::ChildNode() const{
return ParserNode(this);
}
//////////////////////////////////////////
///\brief
///Get the first childnode of the current node with
///the expectedNodes name.
//////////////////////////////////////////
ParserNode ParserNode::ChildNode(std::string expectedNode) const{
return ParserNode(this,expectedNode);
}
//////////////////////////////////////////
///\brief
///Destructor
///
///The destructor will halt until the nodes
///endtag has been retrieved, assuming that
///this is a valid node in the first place
//////////////////////////////////////////
ParserNode::~ParserNode(){
if(this->node && this->status==1){
while(this->node->status!=Node::Status::Ended){
// Wait for node to be ended
this->parser->ContinueParsing();
}
}
}
//////////////////////////////////////////
///\brief
///Get the name of the node
//////////////////////////////////////////
std::string& ParserNode::Name(){
return this->node->name;
}
//////////////////////////////////////////
///\brief
///Get the text content of the node
//////////////////////////////////////////
std::string& ParserNode::Content(){
return this->node->content;
}
//////////////////////////////////////////
///\brief
///Wait for all content to be retrieved
///
///What realy happens is that the method will wait until
///the nodes end tag has been set to assure that all content
///has been retrieved.
//////////////////////////////////////////
void ParserNode::WaitForContent(){
if(this->node && this->status==1){
while(this->node->status!=Node::Status::Ended){
// Wait for node to be ended
this->parser->ContinueParsing();
}
}
}
//////////////////////////////////////////
///\brief
///Get a reference to the nodes Attributes
///
///The AttributeMap is a std::map that can be used
///like:
///std::string nodeType = node.Attibutes()["type"];
//////////////////////////////////////////
Node::AttributeMap& ParserNode::Attributes(){
return this->node->attributes;
}
ParserNode::operator bool(){
return this->status==1;
}
int ParserNode::NodeLevel(){
int level(0);
if(this->parentNode){
return this->parentNode->NodeLevel();
}
return level;
}
std::string ParserNode::NodeParentsPath(){
std::string nodeParents;
if(this->parentNode){
return this->parentNode->NodeLevelPath();
}
return nodeParents;
}
void ParserNode::WaitForNode(const std::set<std::string> &nodeNames){
// Wait for the node
std::string nodeParentPath(this->NodeParentsPath());
while(this->status==0){
if(this->parser->exit){
this->status = -1;
}else{
// Parse until next stop
this->parser->ContinueParsing();
// First of all, check if the nodeParentPath is a substring of the parsers current node level
if( this->parser->CurrentNodeLevelPath().compare(0,nodeParentPath.size(),nodeParentPath)!=0 ){
// Node has not turned up, fail
this->status=-1;
}else{
// Check if this is the expected EventType
if(this->parser->currentEventType==Parser::EventTypes::NodeStart){
// Is the "level" the right one?
// This is a check so that the parser isn't a level down from the expected
if(this->parser->level-1==this->NodeLevel()){
// Is this an expected node name
if(nodeNames.empty()){
// Success
this->node = this->parser->LastNode();
this->status = 1;
}else{
Node::Ptr lastNode = this->parser->LastNode();
if(lastNode){
if(nodeNames.find(lastNode->name)!=nodeNames.end()){
// Success
this->node = lastNode;
this->status = 1;
}
}
}
}
}
}
}
}
}

89
src/core/xml/ParserNode.h Normal file
View File

@ -0,0 +1,89 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <core/xml/Node.h>
#include <boost/utility.hpp>
using namespace musik::core::xml;
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{ namespace xml{
// Forward
class Parser;
class ParserNode {
public:
ParserNode();
~ParserNode();
ParserNode& operator=(ParserNode const &copyNode);
ParserNode ChildNode() const;
ParserNode ChildNode(std::string expectedNode) const;
std::string& Name();
std::string& Content();
Node::AttributeMap& Attributes();
void WaitForContent();
operator bool();
protected:
friend class Parser;
ParserNode(const ParserNode *parent);
ParserNode(const ParserNode *parent,std::string &expectedNode);
void WaitForNode(const std::set<std::string> &nodeNames);
std::string NodeParentsPath();
int NodeLevel();
Node::Ptr node;
Node::Ptr parentNode;
Parser *parser;
int status;
};
//////////////////////////////////////////////////////////////////////////////
} } }

178
src/core/xml/Writer.cpp Normal file
View File

@ -0,0 +1,178 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include <core/xml/Writer.h>
#include <core/xml/WriterNode.h>
using namespace musik::core::xml;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////
///\brief
///Constructor
///
///\param socket
///pointer to boost::asio socket to be used by the Parser
///
///The Parser will continously parse XML and
///read from the socket when there is no buffer
///left in the parser.
//////////////////////////////////////////
Writer::Writer(boost::asio::ip::tcp::socket *socket)
:socket(socket)
,exit(false)
{
this->writer = this;
}
//////////////////////////////////////////////////////////////////////////////
Writer::~Writer(void){
this->node.reset();
}
//////////////////////////////////////////////////////////////////////////////
void Writer::Exit(){
this->exit = true;
}
//////////////////////////////////////////////////////////////////////////////
void Writer::Send(){
// If no node is set, set the root node
if(!this->currentWritingNode && this->node){
this->currentWritingNode = this->node;
}
std::string sendBuffer;
bool keepSending(true);
while(keepSending && this->currentWritingNode){
keepSending=false;
// If the node has already been send, and has childnodes, set currentWritingNode to the first childnode
if(this->currentWritingNode->status&Node::Status::StartSend && !this->currentWritingNode->childNodes.empty() ){
this->currentWritingNode = this->currentWritingNode->childNodes.front();
}
// 1. Send start tag if:
// * start is not send before
// * the node is started, and has childnodes
// * if it's ended
Node::Ptr node(this->currentWritingNode);
int status(node->status);
bool noChildren(node->childNodes.empty());
if( !(status&Node::Status::StartSend) &&
(
(status&Node::Status::Started && !noChildren)
||
(status&Node::Status::Ended)
)
){
if(node!=this->node){
// OK, lets send the start tag
sendBuffer.append("<"+node->name);
// append the attributes
for(Node::AttributeMap::iterator attribute=node->attributes.begin();attribute!=node->attributes.end();++attribute){
sendBuffer.append(" "+attribute->first+"=\""+attribute->second+"\"");
}
sendBuffer.append(">");
}
// Set the node to StartSend
node->status |= Node::Status::StartSend;
// Lets see if the node has any children to continue with
if(!keepSending && !noChildren){
this->currentWritingNode = node->childNodes.front();
keepSending = true;
}
}
// 2. Lets send endtag if:
// * keepSending == false (currentWritingNode has not been altered)
// * StartTag has been send
// * Ended is set
// * There are no childnodes left
if(this->currentWritingNode){
node = this->currentWritingNode;
status = node->status;
noChildren = node->childNodes.empty();
if(!keepSending &&
status&Node::Status::StartSend &&
status&Node::Status::Ended &&
noChildren
){
if(node!=this->node){ // Do not send root node
// Send the content and end tag
sendBuffer.append(node->content);
sendBuffer.append("</"+node->name+">");
}
// Set to send
node->status |= Node::Status::EndSend;
// Remove from parent node
node->RemoveFromParent();
// And lets step down the currentWritingNode to parent
this->currentWritingNode = node->parent;
keepSending = true;
}
}
}
// Time to send the buffer
if(!sendBuffer.empty()){
boost::asio::write(*(this->socket),boost::asio::buffer(sendBuffer));
sendBuffer.clear();
}
}

81
src/core/xml/Writer.h Normal file
View File

@ -0,0 +1,81 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <string>
#include <boost/asio.hpp>
//#include <boost/array.hpp>
#include <core/xml/Node.h>
#include <core/xml/WriterNode.h>
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{ namespace xml{
//////////////////////////////////////////////////////////////////////////////
class Writer : public WriterNode{
public:
Writer(boost::asio::ip::tcp::socket *socket);
~Writer();
private:
// Socket stuff
boost::asio::ip::tcp::socket *socket;
// boost::array<char, 4096> readBuffer;
// size_t readBufferLength;
private:
friend class WriterNode;
std::vector<Node::Ptr> currentNodeLevels;
Node::Ptr currentWritingNode;
void Send();
bool exit;
void Exit();
std::string sendBuffer;
};
//////////////////////////////////////////////////////////////////////////////
} } }

108
src/core/xml/WriterNode.cpp Normal file
View File

@ -0,0 +1,108 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include <core/xml/WriterNode.h>
#include <core/xml/Writer.h>
using namespace musik::core::xml;
WriterNode::WriterNode(WriterNode &parentNode,std::string name)
:writer(parentNode.writer)
,node(new Node(parentNode.node))
{
this->parentNode = parentNode.node;
this->node->name = name;
if(parentNode.node){
parentNode.node->childNodes.push_back(this->node);
// if a childnode has been added to a node, it should be set to started
parentNode.node->status |= Node::Status::Started;
}
this->writer->Send();
}
WriterNode::WriterNode()
:writer(NULL)
,node(new Node())
{
}
//////////////////////////////////////////
///\brief
///Destructor
///
//////////////////////////////////////////
WriterNode::~WriterNode(){
if(this->node){
this->node->status |= Node::Status::Started | Node::Status::Ended;
if(this!=this->writer){
this->writer->Send();
}
}
}
//////////////////////////////////////////
///\brief
///Get the name of the node
//////////////////////////////////////////
std::string& WriterNode::Name(){
return this->node->name;
}
//////////////////////////////////////////
///\brief
///Get the text content of the node
//////////////////////////////////////////
std::string& WriterNode::Content(){
return this->node->content;
}
//////////////////////////////////////////
///\brief
///Get a reference to the nodes Attributes
///
///The AttributeMap is a std::map that can be used
///like:
///node.Attibutes()["type"] = "tjobba";
//////////////////////////////////////////
Node::AttributeMap& WriterNode::Attributes(){
return this->node->attributes;
}

73
src/core/xml/WriterNode.h Normal file
View File

@ -0,0 +1,73 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2008, Daniel Önnerby
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <core/xml/Node.h>
#include <boost/utility.hpp>
using namespace musik::core::xml;
//////////////////////////////////////////////////////////////////////////////
namespace musik{ namespace core{ namespace xml{
// Forward
class Writer;
class WriterNode {
public:
WriterNode(WriterNode &parentNode,std::string name);
~WriterNode();
std::string& Name();
std::string& Content();
Node::AttributeMap& Attributes();
protected:
friend class Writer;
WriterNode();
Node::Ptr node;
Node::Ptr parentNode;
Writer *writer;
};
//////////////////////////////////////////////////////////////////////////////
} } }

View File

@ -41,7 +41,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;XML_STATIC"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@ -67,6 +67,7 @@
LinkIncremental="2"
AdditionalLibraryDirectories="../3rdparty/lib"
IgnoreDefaultLibraryNames=""
ModuleDefinitionFile=""
GenerateDebugInformation="true"
SubSystem="2"
EntryPointSymbol="wWinMainCRTStartup"
@ -126,7 +127,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;XML_STATIC"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="pch.hpp"
@ -149,6 +150,7 @@
AdditionalDependencies="gdiplus.lib comctl32.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="../3rdparty/lib"
ModuleDefinitionFile=""
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"

53
src/daemon/daemon.cpp Normal file
View File

@ -0,0 +1,53 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2007, mC2 Team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#include "pch.hpp"
#include <core/config.h>
#include <core/Server.h>
using namespace musik::core;
int main(int argc, utfchar* argv[]){
Server server(10543);
server.Startup();
system("PAUSE");
return 0;
}

216
src/daemon/daemon.vcproj Normal file
View File

@ -0,0 +1,216 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="daemon"
ProjectGUID="{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}"
RootNamespace="daemon"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../../bin/$(ConfigurationName)"
IntermediateDirectory="obj/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;XML_STATIC"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="pch.hpp"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="../3rdparty/lib"
ModuleDefinitionFile=""
GenerateDebugInformation="true"
SubSystem="1"
ImportLibrary="../../bin/$(ConfigurationName)/daemon.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(SolutionDir)\src\3rdparty\vld\*.*&quot; &quot;$(TargetDir)&quot;"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../../bin/$(ConfigurationName)"
IntermediateDirectory="obj/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;XML_STATIC"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="pch.hpp"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="../3rdparty/lib"
ModuleDefinitionFile=""
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="../../bin/$(ConfigurationName)/daemon.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\daemon.cpp"
>
</File>
<File
RelativePath=".\pch.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\pch.hpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

1
src/daemon/pch.cpp Normal file
View File

@ -0,0 +1 @@
#include "pch.hpp"

37
src/daemon/pch.hpp Normal file
View File

@ -0,0 +1,37 @@
//////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright © 2007, mC2 Team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

View File

@ -38,6 +38,7 @@
#pragma once
#include <win32cpp/Win32Config.hpp> // Must be first!
#include <win32cpp/Types.hpp>
#include <win32cpp/Window.hpp>
#include <win32cpp/TopLevelWindow.hpp>

View File

@ -40,6 +40,8 @@
#include <list>
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <win32cpp/Win32Config.hpp> // Must be first!
#include <win32cpp/Application.hpp>
#include <win32cpp/Window.hpp>

View File

@ -38,6 +38,7 @@
#include <pch.hpp>
#include <win32cpp/BarLayout.hpp>
#include <win32cpp/RedrawLock.hpp>
#include <algorithm>

View File

@ -40,6 +40,7 @@
//////////////////////////////////////////////////////////////////////////////
#include <win32cpp/Win32Config.hpp> // Must be first!
#include <win32cpp/Panel.hpp>
#include <win32cpp/ILayout.hpp>

View File

@ -38,6 +38,7 @@
#include <pch.hpp>
#include <win32cpp/Button.hpp>
#include <win32cpp/Application.hpp>
//////////////////////////////////////////////////////////////////////////////

View File

@ -40,6 +40,7 @@
//////////////////////////////////////////////////////////////////////////////
#include <win32cpp/Win32Config.hpp> // Must be first!
#include <win32cpp/Window.hpp>
namespace win32cpp {

Some files were not shown because too many files have changed in this diff Show More