1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-07-09 18:37:12 +02:00

Major plugin refactor and cleanup.

Switched to POCO library for unified platform/library interface.
Deprecated the external module API. It was creating more problems than solving.
Removed most built-in libraries in favor of system libraries for easier maintenance.
Cleaned and secured code with help from static analyzers.
This commit is contained in:
Sandu Liviu Catalin
2021-01-30 08:51:39 +02:00
parent e0e34b4030
commit 4a6bfc086c
6219 changed files with 1209835 additions and 454916 deletions
CMakeLists.txt
cmake
module
Base
CMakeLists.txtCore.cppCore.hpp
Core
Entity
Library
Logger.cppLogger.hppMain.cpp
Misc
Register.cppSqBase.hpp
Sqrat
VCMP
Vendor
AES256
B64
CMakeLists.txt
CPR
CURL
CHANGES
CMake
CMakeLists.txtCOPYINGGIT-INFOMacOSX-FrameworkMakefile.amMakefile.distREADMEREADME.mdRELEASE-NOTESSECURITY.mdacinclude.m4appveyor.ymlbuildconfbuildconf.batconfigure.accurl-config.in
include
lib
CMakeLists.txtMakefile.amMakefile.incMakefile.m32Makefile.netwareMakefile.vxworksaltsvc.caltsvc.hamigaos.camigaos.harpa_telnet.hasyn-ares.casyn-thread.casyn.hbase64.cc-hyper.cc-hyper.hchecksrc.plconfig-amigaos.hconfig-dos.hconfig-mac.hconfig-os400.hconfig-plan9.hconfig-riscos.hconfig-tpf.hconfig-vxworks.hconfig-win32.hconfig-win32ce.hconncache.cconncache.hconnect.cconnect.hcontent_encoding.ccontent_encoding.hcookie.ccookie.hcurl_addrinfo.ccurl_addrinfo.hcurl_base64.hcurl_config.h.cmakecurl_ctype.ccurl_ctype.hcurl_des.ccurl_des.hcurl_endian.ccurl_endian.hcurl_fnmatch.ccurl_fnmatch.hcurl_get_line.ccurl_get_line.hcurl_gethostname.ccurl_gethostname.hcurl_gssapi.ccurl_gssapi.hcurl_hmac.hcurl_krb5.hcurl_ldap.hcurl_md4.hcurl_md5.hcurl_memory.hcurl_memrchr.ccurl_memrchr.hcurl_multibyte.ccurl_multibyte.hcurl_ntlm_core.ccurl_ntlm_core.hcurl_ntlm_wb.ccurl_ntlm_wb.hcurl_path.ccurl_path.hcurl_printf.hcurl_range.ccurl_range.hcurl_rtmp.ccurl_rtmp.hcurl_sasl.ccurl_sasl.hcurl_setup.hcurl_setup_once.hcurl_sha256.hcurl_sspi.ccurl_sspi.hcurl_threads.ccurl_threads.hcurlx.hdict.cdict.hdoh.cdoh.hdotdot.cdotdot.hdynbuf.cdynbuf.heasy.ceasygetopt.ceasyif.heasyoptions.ceasyoptions.hescape.cescape.hfile.cfile.hfileinfo.cfileinfo.hfirefox-db2pem.shformdata.cformdata.hftp.cftp.hftplistparser.cftplistparser.hgetenv.cgetinfo.cgetinfo.hgopher.cgopher.hhash.chash.hhmac.chostasyn.chostcheck.chostcheck.hhostip.chostip.hhostip4.chostip6.chostsyn.chsts.chsts.hhttp.chttp.hhttp2.chttp2.hhttp_aws_sigv4.chttp_aws_sigv4.hhttp_chunks.chttp_chunks.hhttp_digest.chttp_digest.hhttp_negotiate.chttp_negotiate.hhttp_ntlm.chttp_ntlm.hhttp_proxy.chttp_proxy.hidn_win32.cif2ip.cif2ip.himap.cimap.hinet_ntop.cinet_ntop.hinet_pton.cinet_pton.hkrb5.cldap.clibcurl.plistlibcurl.rclibcurl.vers.inllist.cllist.hmakefile.amigamakefile.djmd4.cmd5.cmemdebug.cmemdebug.hmime.cmime.hmk-ca-bundle.plmk-ca-bundle.vbsmprintf.cmqtt.cmqtt.hmulti.cmultihandle.hmultiif.hnetrc.cnetrc.hnon-ascii.cnon-ascii.hnonblock.cnonblock.hnwlib.cnwos.copenldap.coptiontable.plparsedate.cparsedate.hpingpong.cpingpong.hpop3.cpop3.hprogress.cprogress.hpsl.cpsl.hquic.hrand.crand.hrename.crename.hrtsp.crtsp.hselect.cselect.hsendf.csendf.hsetopt.csetopt.hsetup-os400.hsetup-vms.hsetup-win32.hsha256.cshare.cshare.hsigpipe.hslist.cslist.hsmb.csmb.hsmtp.csmtp.hsockaddr.hsocketpair.csocketpair.hsocks.csocks.hsocks_gssapi.csocks_sspi.cspeedcheck.cspeedcheck.hsplay.csplay.hstrcase.cstrcase.hstrdup.cstrdup.hstrerror.cstrerror.hstrtok.cstrtok.hstrtoofft.cstrtoofft.hsystem_win32.csystem_win32.htelnet.ctelnet.htftp.ctftp.htimeval.ctimeval.htransfer.ctransfer.hurl.curl.hurlapi-int.hurlapi.curldata.h
vauth
version.cversion_win32.cversion_win32.h
vquic
vssh
vtls
warnless.cwarnless.hwildcard.cwildcard.hx509asn1.cx509asn1.h
libcurl.pc.in
m4
maketgz
packages
plan9
scripts
src
winbuild
CivetWeb
ConcurrentQueue
Hash
MDBC
CMakeLists.txtCOPYING.LIBREADME
cmake
examples
include
libmariadb
mariadb_config
plugins
win-iconv
win
MaxmindDB
PUGIXML
SQLite
SimpleIni
SimpleSocket
TinyDir
Whirlpool
ZLib
CMakeLists.txtChangeLogFAQINDEXMakefileMakefile.inREADMEadler32.c
amiga
configure
contrib
README.contrib
ada
amd64
asm686
blast
delphi
dotzlib
gcc_gvmat64
infback9
inflate86
iostream
iostream2
iostream3
masmx64
masmx86
minizip
pascal
puff
testzlib
untgz
vstudio
crc32.c
doc
examples
gzclose.cgzlib.cgzread.cgzwrite.cmake_vms.com
msdos
nintendods
old
os400
qnx
test
treebuild.xmluncompr.c
watcom
win32
zconf.h.cmakeinzconf.h.inzconf.h.includedzlib.3zlib.3.pdfzlib.mapzlib.pc.cmakeinzlib.pc.inzlib2ansizutil.czutil.h
sdk
vendor
CMakeLists.txt
CPR
ConcurrentQueue
Fmt
POCO
ApacheConnector
CHANGELOGCMakeLists.txtCODE_OF_CONDUCT.mdCONTRIBUTING.mdCONTRIBUTORS
CppParser
CppUnit
Crypto
CMakeLists.txtCrypto.progenCrypto_VS90.slnCrypto_VS90.vcprojCrypto_vs140.slnCrypto_vs140.vcxprojCrypto_vs140.vcxproj.filtersCrypto_vs150.slnCrypto_vs150.vcxprojCrypto_vs150.vcxproj.filtersCrypto_vs160.slnCrypto_vs160.vcxprojCrypto_vs160.vcxproj.filtersMakefile
cmake
dependencies
include
samples
src
testsuite
Data
CMakeLists.txtData.progenData_VS90.slnData_VS90.vcprojData_vs140.slnData_vs140.vcxprojData_vs140.vcxproj.filtersData_vs150.slnData_vs150.vcxprojData_vs150.vcxproj.filtersData_vs160.slnData_vs160.vcxprojData_vs160.vcxproj.filtersMakefile
MySQL
ODBC
PostgreSQL
SQLite
cmake
dependencies
doc
include
samples
Binding
CMakeLists.txtMakefile
RecordSet
RowFormatter
Tuple
TypeHandler
WebNotifier
dependenciessamples.progensamples_vs140.slnsamples_vs150.slnsamples_vs160.slnsamples_vs90.sln
src
testsuite
Encodings
CMakeLists.txt
Compiler
Encodings.progenEncodings_vs140.slnEncodings_vs140.vcxprojEncodings_vs140.vcxproj.filtersEncodings_vs150.slnEncodings_vs150.vcxprojEncodings_vs150.vcxproj.filtersEncodings_vs160.slnEncodings_vs160.vcxprojEncodings_vs160.vcxproj.filtersEncodings_vs90.slnEncodings_vs90.vcprojMakefile
cmake
dependenciesgenerateEncodings.sh
include
samples
src
testsuite
Foundation
CMakeLists.txtFoundation_vs140.slnFoundation_vs140.vcxprojFoundation_vs140.vcxproj.filtersFoundation_vs150.slnFoundation_vs150.vcxprojFoundation_vs150.vcxproj.filtersFoundation_vs160.slnFoundation_vs160.vcxprojFoundation_vs160.vcxproj.filtersMakefile
cmake
extradirs
include
Poco
ASCIIEncoding.hAbstractCache.hAbstractDelegate.hAbstractEvent.hAbstractObserver.hAbstractPriorityDelegate.hAbstractStrategy.hAccessExpirationDecorator.hAccessExpireCache.hAccessExpireLRUCache.hAccessExpireStrategy.hActiveDispatcher.hActiveMethod.hActiveResult.hActiveRunnable.hActiveStarter.hActivity.hAlignment.hAny.hArchiveStrategy.hArray.hAscii.hAsyncChannel.hAtomicCounter.hAtomicFlag.hAutoPtr.hAutoReleasePool.hBase32Decoder.hBase32Encoder.hBase64Decoder.hBase64Encoder.hBasicEvent.hBinaryReader.hBinaryWriter.hBuffer.hBufferAllocator.hBufferedBidirectionalStreamBuf.hBufferedStreamBuf.hBugcheck.hByteOrder.hChannel.hChecksum.hClassLibrary.hClassLoader.hClock.hCondition.hConfig.hConfigurable.hConsoleChannel.hCountingStream.hDataURIStream.hDataURIStreamFactory.hDateTime.hDateTimeFormat.hDateTimeFormatter.hDateTimeParser.hDebugger.hDefaultStrategy.hDeflatingStream.hDelegate.hDigestEngine.hDigestStream.hDirectoryIterator.hDirectoryIteratorStrategy.hDirectoryIterator_UNIX.hDirectoryIterator_WIN32U.hDirectoryWatcher.h
Dynamic
DynamicAny.hDynamicAnyHolder.hDynamicFactory.hDynamicStruct.hEnvironment.hEnvironment_UNIX.hEnvironment_VX.hEnvironment_WIN32U.hEnvironment_WINCE.hError.hErrorHandler.hEvent.hEventArgs.hEventChannel.hEventLogChannel.hEvent_POSIX.hEvent_VX.hEvent_WIN32.hException.hExpirationDecorator.hExpire.hExpireCache.hExpireLRUCache.hExpireStrategy.hFIFOBuffer.hFIFOBufferStream.hFIFOEvent.hFIFOStrategy.hFPEnvironment.hFPEnvironment_C99.hFPEnvironment_DEC.hFPEnvironment_DUMMY.hFPEnvironment_QNX.hFPEnvironment_SUN.hFPEnvironment_WIN32.hFile.hFileChannel.hFileStream.hFileStreamFactory.hFileStream_POSIX.hFileStream_WIN32.hFile_UNIX.hFile_VX.hFile_WIN32U.hFile_WINCE.hFormat.hFormatter.hFormattingChannel.hFoundation.hFunctionDelegate.hFunctionPriorityDelegate.hGlob.hHMACEngine.hHash.hHashFunction.hHashMap.hHashSet.hHashStatistic.hHashTable.hHexBinaryDecoder.hHexBinaryEncoder.hInflatingStream.hInstantiator.hJSONString.hKeyValueArgs.hLRUCache.hLRUStrategy.hLatin1Encoding.hLatin2Encoding.hLatin9Encoding.hLineEndingConverter.hLinearHashTable.hListMap.hLocalDateTime.hLogFile.hLogFile_STD.hLogFile_WIN32U.hLogStream.hLogger.hLoggingFactory.hLoggingRegistry.hMD4Engine.hMD5Engine.hManifest.hMemoryPool.hMemoryStream.hMessage.hMetaObject.hMetaProgramming.hMutex.hMutex_POSIX.hMutex_VX.hMutex_WIN32.hMutex_WINCE.hNObserver.hNamedEvent.hNamedEvent_Android.hNamedEvent_UNIX.hNamedEvent_WIN32U.hNamedMutex.hNamedMutex_Android.hNamedMutex_UNIX.hNamedMutex_WIN32U.hNamedTuple.hNestedDiagnosticContext.hNotification.hNotificationCenter.hNotificationQueue.hNotificationStrategy.hNullChannel.hNullStream.hNullable.hNumberFormatter.hNumberParser.hNumericString.hObjectPool.hObserver.hOptional.hOrderedMap.hOrderedSet.hPBKDF2Engine.hPath.hPath_UNIX.hPath_WIN32U.hPath_WINCE.hPatternFormatter.hPipe.hPipeImpl.hPipeImpl_DUMMY.hPipeImpl_POSIX.hPipeImpl_WIN32.hPipeStream.hPlatform.hPlatform_POSIX.hPlatform_VX.hPlatform_WIN32.hPoco.hPriorityDelegate.hPriorityEvent.hPriorityExpire.hPriorityNotificationQueue.hPriorityStrategy.hProcess.hProcess_UNIX.hProcess_VX.hProcess_WIN32U.hProcess_WINCE.hPurgeStrategy.hRWLock.hRWLock_Android.hRWLock_POSIX.hRWLock_VX.hRWLock_WIN32.hRWLock_WINCE.hRandom.hRandomStream.hRecursiveDirectoryIterator.hRecursiveDirectoryIteratorImpl.hRefCountedObject.hRegularExpression.hRotateStrategy.hRunnable.hRunnableAdapter.hSHA1Engine.hSHA2Engine.hScopedLock.hScopedUnlock.hSemaphore.hSemaphore_POSIX.hSemaphore_VX.hSemaphore_WIN32.hSharedLibrary.hSharedLibrary_HPUX.hSharedLibrary_UNIX.hSharedLibrary_VX.hSharedLibrary_WIN32U.hSharedMemory.hSharedMemory_DUMMY.hSharedMemory_POSIX.hSharedMemory_WIN32.hSharedPtr.hSignalHandler.hSimpleFileChannel.hSimpleHashTable.hSingletonHolder.hSortedDirectoryIterator.hSplitterChannel.hStopwatch.hStrategyCollection.hStreamChannel.hStreamConverter.hStreamCopier.hStreamTokenizer.hStreamUtil.hString.hStringTokenizer.hSynchronizedObject.hSyslogChannel.hTask.hTaskManager.hTaskNotification.hTeeStream.hTemporaryFile.hTextBufferIterator.hTextConverter.hTextEncoding.hTextIterator.hThread.hThreadLocal.hThreadPool.hThreadTarget.hThread_POSIX.hThread_VX.hThread_WIN32.hThread_WINCE.hTimedNotificationQueue.hTimer.hTimespan.hTimestamp.hTimezone.hToken.hTuple.hTypeList.hTypes.hURI.hURIStreamFactory.hURIStreamOpener.hUTF16Encoding.hUTF32Encoding.hUTF8Encoding.hUTF8String.hUTFString.hUUID.hUUIDGenerator.hUnWindows.hUnbufferedStreamBuf.hUnicode.hUnicodeConverter.hUniqueAccessExpireCache.hUniqueAccessExpireLRUCache.hUniqueAccessExpireStrategy.hUniqueExpireCache.hUniqueExpireLRUCache.hUniqueExpireStrategy.hValidArgs.hVersion.hVoid.hWindows1250Encoding.hWindows1251Encoding.hWindows1252Encoding.hWindowsConsoleChannel.hordered_hash.hordered_map.hordered_set.hzconf.hzlib.h
samples
ActiveMethod
Activity
BinaryReaderWriter
CMakeLists.txt
DateTime
LineEndingConverter
LogRotation
Logger
Makefile
NotificationQueue
StringTokenizer
Timer
URI
base64decode
base64encode
deflate
dir
grep
hmacmd5
inflate
md5
samples.progensamples_vs140.slnsamples_vs150.slnsamples_vs160.slnsamples_vs90.sln
uuidgen
src
ASCIIEncoding.cppAbstractObserver.cppActiveDispatcher.cppArchiveStrategy.cppAscii.cppAsyncChannel.cppAtomicCounter.cppAtomicFlag.cppBase32Decoder.cppBase32Encoder.cppBase64Decoder.cppBase64Encoder.cppBinaryReader.cppBinaryWriter.cppBugcheck.cppByteOrder.cppChannel.cppChecksum.cppClock.cppCondition.cppConfigurable.cppConsoleChannel.cppCountingStream.cppDataURIStream.cppDataURIStreamFactory.cppDateTime.cppDateTimeFormat.cppDateTimeFormatter.cppDateTimeParser.cppDebugger.cppDeflatingStream.cppDigestEngine.cppDigestStream.cppDirectoryIterator.cppDirectoryIteratorStrategy.cppDirectoryIterator_UNIX.cppDirectoryIterator_WIN32U.cppDirectoryWatcher.cppEnvironment.cppEnvironment_UNIX.cppEnvironment_VX.cppEnvironment_WIN32U.cppEnvironment_WINCE.cppError.cppErrorHandler.cppEvent.cppEventArgs.cppEventChannel.cppEventLogChannel.cppEvent_POSIX.cppEvent_VX.cppEvent_WIN32.cppException.cppFIFOBufferStream.cppFPEnvironment.cppFPEnvironment_C99.cppFPEnvironment_DEC.cppFPEnvironment_DUMMY.cppFPEnvironment_QNX.cppFPEnvironment_SUN.cppFPEnvironment_WIN32.cppFile.cppFileChannel.cppFileStream.cppFileStreamFactory.cppFileStream_POSIX.cppFileStream_WIN32.cppFile_UNIX.cppFile_VX.cppFile_WIN32U.cppFile_WINCE.cppFormat.cppFormatter.cppFormattingChannel.cppGlob.cppHash.cppHashStatistic.cppHexBinaryDecoder.cppHexBinaryEncoder.cppInflatingStream.cppJSONString.cppLatin1Encoding.cppLatin2Encoding.cppLatin9Encoding.cppLineEndingConverter.cppLocalDateTime.cppLogFile.cppLogFile_STD.cppLogFile_WIN32U.cppLogStream.cppLogger.cppLoggingFactory.cppLoggingRegistry.cppMD4Engine.cppMD5Engine.cppMSG00001.binManifest.cppMemoryPool.cppMemoryStream.cppMessage.cppMutex.cppMutex_POSIX.cppMutex_VX.cppMutex_WIN32.cppMutex_WINCE.cppNamedEvent.cppNamedEvent_Android.cppNamedEvent_UNIX.cppNamedEvent_WIN32U.cppNamedMutex.cppNamedMutex_Android.cppNamedMutex_UNIX.cppNamedMutex_WIN32U.cppNestedDiagnosticContext.cppNotification.cppNotificationCenter.cppNotificationQueue.cppNullChannel.cppNullStream.cppNumberFormatter.cppNumberParser.cppNumericString.cppPath.cppPath_UNIX.cppPath_WIN32U.cppPath_WINCE.cppPatternFormatter.cppPipe.cppPipeImpl.cppPipeImpl_DUMMY.cppPipeImpl_POSIX.cppPipeImpl_WIN32.cppPipeStream.cppPriorityNotificationQueue.cppProcess.cppProcess_UNIX.cppProcess_VX.cppProcess_WIN32U.cppProcess_WINCE.cppPurgeStrategy.cppRWLock.cppRWLock_Android.cppRWLock_POSIX.cppRWLock_VX.cppRWLock_WIN32.cppRWLock_WINCE.cppRandom.cppRandomStream.cppRefCountedObject.cppRegularExpression.cppRotateStrategy.cppRunnable.cppSHA1Engine.cppSHA2Engine.cppSemaphore.cppSemaphore_POSIX.cppSemaphore_VX.cppSemaphore_WIN32.cppSharedLibrary.cppSharedLibrary_HPUX.cppSharedLibrary_UNIX.cppSharedLibrary_VX.cppSharedLibrary_WIN32U.cppSharedMemory.cppSharedMemory_DUMMY.cppSharedMemory_POSIX.cppSharedMemory_WIN32.cppSignalHandler.cppSimpleFileChannel.cppSortedDirectoryIterator.cppSplitterChannel.cppStopwatch.cppStreamChannel.cppStreamConverter.cppStreamCopier.cppStreamTokenizer.cppString.cppStringTokenizer.cppSynchronizedObject.cppSyslogChannel.cppTask.cppTaskManager.cppTaskNotification.cppTeeStream.cppTemporaryFile.cppTextBufferIterator.cppTextConverter.cppTextEncoding.cppTextIterator.cppThread.cppThreadLocal.cppThreadPool.cppThreadTarget.cppThread_POSIX.cppThread_VX.cppThread_WIN32.cppThread_WINCE.cppTimedNotificationQueue.cppTimer.cppTimespan.cppTimestamp.cppTimezone.cppTimezone_UNIX.cppTimezone_VX.cppTimezone_WIN32.cppTimezone_WINCE.cppToken.cppURI.cppURIStreamFactory.cppURIStreamOpener.cppUTF16Encoding.cppUTF32Encoding.cppUTF8Encoding.cppUTF8String.cppUUID.cppUUIDGenerator.cppUnicode.cppUnicodeConverter.cppVar.cppVarHolder.cppVarIterator.cppVoid.cppWindows1250Encoding.cppWindows1251Encoding.cppWindows1252Encoding.cppWindowsConsoleChannel.cppadler32.cbignum-dtoa.ccbignum-dtoa.hbignum.ccbignum.hcached-powers.cccached-powers.hcompress.ccrc32.ccrc32.hdeflate.cdeflate.hdiy-fp.ccdiy-fp.hdouble-conversion.ccdouble-conversion.hfast-dtoa.ccfast-dtoa.hfixed-dtoa.ccfixed-dtoa.hgzguts.hieee.hinfback.cinffast.cinffast.hinffixed.hinflate.cinflate.hinftrees.cinftrees.hpcre.hpcre_byte_order.cpcre_chartables.cpcre_compile.cpcre_config.cpcre_config.hpcre_dfa_exec.cpcre_exec.cpcre_fullinfo.cpcre_get.cpcre_globals.cpcre_internal.hpcre_jit_compile.cpcre_maketables.cpcre_newline.cpcre_ord2utf8.cpcre_refcount.cpcre_string_utils.cpcre_study.cpcre_tables.cpcre_ucd.cpcre_valid_utf8.cpcre_version.cpcre_xclass.cpocomsg.mcstrtod.ccstrtod.htrees.ctrees.hucp.hutils.hzconf.hzlib.hzutil.czutil.h
testsuite
CMakeLists.txtMakefileMakefile-DriverMakefile-TestAppMakefile-TestLibraryTestApp_vs140.vcxprojTestApp_vs140.vcxproj.filtersTestApp_vs150.vcxprojTestApp_vs150.vcxproj.filtersTestApp_vs160.vcxprojTestApp_vs160.vcxproj.filtersTestLibrary_vs140.vcxprojTestLibrary_vs140.vcxproj.filtersTestLibrary_vs150.vcxprojTestLibrary_vs150.vcxproj.filtersTestLibrary_vs160.vcxprojTestLibrary_vs160.vcxproj.filtersTestSuite_vs140.vcxprojTestSuite_vs140.vcxproj.filtersTestSuite_vs150.vcxprojTestSuite_vs150.vcxproj.filtersTestSuite_vs160.vcxprojTestSuite_vs160.vcxproj.filtersnonexistent.txt
src
ActiveDispatcherTest.cppActiveDispatcherTest.hActiveMethodTest.cppActiveMethodTest.hActivityTest.cppActivityTest.hAnyTest.cppAnyTest.hArrayTest.cppArrayTest.hAutoPtrTest.cppAutoPtrTest.hAutoReleasePoolTest.cppAutoReleasePoolTest.hBase32Test.cppBase32Test.hBase64Test.cppBase64Test.hBasicEventTest.cppBasicEventTest.hBinaryReaderWriterTest.cppBinaryReaderWriterTest.hByteOrderTest.cppByteOrderTest.hCacheTestSuite.cppCacheTestSuite.hChannelTest.cppChannelTest.hClassLoaderTest.cppClassLoaderTest.hClockTest.cppClockTest.hConditionTest.cppConditionTest.hCoreTest.cppCoreTest.hCoreTestSuite.cppCoreTestSuite.hCountingStreamTest.cppCountingStreamTest.hCryptTestSuite.cppCryptTestSuite.hDataURIStreamTest.cppDataURIStreamTest.hDateTimeFormatterTest.cppDateTimeFormatterTest.hDateTimeParserTest.cppDateTimeParserTest.hDateTimeTest.cppDateTimeTest.hDateTimeTestSuite.cppDateTimeTestSuite.hDigestStreamTest.cppDigestStreamTest.hDirectoryIteratorsTest.cppDirectoryIteratorsTest.hDirectoryWatcherTest.cppDirectoryWatcherTest.hDriver.cppDummyDelegate.cppDummyDelegate.hDynamicFactoryTest.cppDynamicFactoryTest.hDynamicTestSuite.cppDynamicTestSuite.hEventTestSuite.cppEventTestSuite.hExpireCacheTest.cppExpireCacheTest.hExpireLRUCacheTest.cppExpireLRUCacheTest.hFIFOBufferStreamTest.cppFIFOBufferStreamTest.hFIFOEventTest.cppFIFOEventTest.hFPETest.cppFPETest.hFileChannelTest.cppFileChannelTest.hFileStreamTest.cppFileStreamTest.hFileTest.cppFileTest.hFilesystemTestSuite.cppFilesystemTestSuite.hFormatTest.cppFormatTest.hFoundationTestSuite.cppFoundationTestSuite.hGlobTest.cppGlobTest.hHMACEngineTest.cppHMACEngineTest.hHashMapTest.cppHashMapTest.hHashSetTest.cppHashSetTest.hHashTableTest.cppHashTableTest.hHashingTestSuite.cppHashingTestSuite.hHexBinaryTest.cppHexBinaryTest.hLRUCacheTest.cppLRUCacheTest.hLineEndingConverterTest.cppLineEndingConverterTest.hLinearHashTableTest.cppLinearHashTableTest.hListMapTest.cppListMapTest.hLocalDateTimeTest.cppLocalDateTimeTest.hLogStreamTest.cppLogStreamTest.hLoggerTest.cppLoggerTest.hLoggingFactoryTest.cppLoggingFactoryTest.hLoggingRegistryTest.cppLoggingRegistryTest.hLoggingTestSuite.cppLoggingTestSuite.hMD4EngineTest.cppMD4EngineTest.hMD5EngineTest.cppMD5EngineTest.hManifestTest.cppManifestTest.hMemoryPoolTest.cppMemoryPoolTest.hMemoryStreamTest.cppMemoryStreamTest.hNDCTest.cppNDCTest.hNamedEventTest.cppNamedEventTest.hNamedMutexTest.cppNamedMutexTest.hNamedTuplesTest.cppNamedTuplesTest.hNotificationCenterTest.cppNotificationCenterTest.hNotificationQueueTest.cppNotificationQueueTest.hNotificationsTestSuite.cppNotificationsTestSuite.hNullStreamTest.cppNullStreamTest.hNumberFormatterTest.cppNumberFormatterTest.hNumberParserTest.cppNumberParserTest.hObjectPoolTest.cppObjectPoolTest.hOrderedContainersTest.cppOrderedContainersTest.hPBKDF2EngineTest.cppPBKDF2EngineTest.hPathTest.cppPathTest.hPatternFormatterTest.cppPatternFormatterTest.hPriorityEventTest.cppPriorityEventTest.hPriorityNotificationQueueTest.cppPriorityNotificationQueueTest.hProcessTest.cppProcessTest.hProcessesTestSuite.cppProcessesTestSuite.hRWLockTest.cppRWLockTest.hRandomStreamTest.cppRandomStreamTest.hRandomTest.cppRandomTest.hRegularExpressionTest.cppRegularExpressionTest.hSHA1EngineTest.cppSHA1EngineTest.hSHA2EngineTest.cppSHA2EngineTest.hSemaphoreTest.cppSemaphoreTest.hSharedLibraryTest.cppSharedLibraryTest.hSharedLibraryTestSuite.cppSharedLibraryTestSuite.hSharedMemoryTest.cppSharedMemoryTest.hSharedPtrTest.cppSharedPtrTest.hSimpleFileChannelTest.cppSimpleFileChannelTest.hSimpleHashTableTest.cppSimpleHashTableTest.hStopwatchTest.cppStopwatchTest.hStreamConverterTest.cppStreamConverterTest.hStreamCopierTest.cppStreamCopierTest.hStreamTokenizerTest.cppStreamTokenizerTest.hStreamsTestSuite.cppStreamsTestSuite.hStringTest.cppStringTest.hStringTokenizerTest.cppStringTokenizerTest.hTaskManagerTest.cppTaskManagerTest.hTaskTest.cppTaskTest.hTaskTestSuite.cppTaskTestSuite.hTeeStreamTest.cppTeeStreamTest.hTestApp.cppTestApp_WINCE.cppTestChannel.cppTestChannel.hTestLibrary.cppTestPlugin.cppTestPlugin.hTextBufferIteratorTest.cppTextBufferIteratorTest.hTextConverterTest.cppTextConverterTest.hTextEncodingTest.cppTextEncodingTest.hTextIteratorTest.cppTextIteratorTest.hTextTestSuite.cppTextTestSuite.hThreadLocalTest.cppThreadLocalTest.hThreadPoolTest.cppThreadPoolTest.hThreadTest.cppThreadTest.hThreadingTestSuite.cppThreadingTestSuite.hTimedNotificationQueueTest.cppTimedNotificationQueueTest.hTimerTest.cppTimerTest.hTimespanTest.cppTimespanTest.hTimestampTest.cppTimestampTest.hTimezoneTest.cppTimezoneTest.hTuplesTest.cppTuplesTest.hTypeListTest.cppTypeListTest.hURIStreamOpenerTest.cppURIStreamOpenerTest.hURITest.cppURITest.hURITestSuite.cppURITestSuite.hUTF8StringTest.cppUTF8StringTest.hUUIDGeneratorTest.cppUUIDGeneratorTest.hUUIDTest.cppUUIDTest.hUUIDTestSuite.cppUUIDTestSuite.hUnicodeConverterTest.cppUnicodeConverterTest.hUniqueExpireCacheTest.cppUniqueExpireCacheTest.hUniqueExpireLRUCacheTest.cppUniqueExpireLRUCacheTest.hVarTest.cppVarTest.hWinCEDriver.cppWinDriver.cppZLibTest.cppZLibTest.hordered_map_util.h
testlibrary.opt
wcelibcex-1.0
JSON
CMakeLists.txtJSON.progenJSON_vs140.slnJSON_vs140.vcxprojJSON_vs140.vcxproj.filtersJSON_vs150.slnJSON_vs150.vcxprojJSON_vs150.vcxproj.filtersJSON_vs160.slnJSON_vs160.vcxprojJSON_vs160.vcxproj.filtersJSON_vs90.slnJSON_vs90.vcprojMakefile
cmake
dependencies
include
samples
src
testsuite
CMakeLists.txtMakefileTestSuite.progenTestSuite_vs140.vcxprojTestSuite_vs140.vcxproj.filtersTestSuite_vs150.vcxprojTestSuite_vs150.vcxproj.filtersTestSuite_vs160.vcxprojTestSuite_vs160.vcxproj.filtersTestSuite_vs90.vcproj
data
invalid-unicode
encoded-surrogate-half
invalid-utf-8-after-backslash
invalid-utf-8-in-array
invalid-utf-8-in-bigger-int
invalid-utf-8-in-escape
invalid-utf-8-in-exponent
invalid-utf-8-in-identifier
invalid-utf-8-in-int
invalid-utf-8-in-real-after-e
invalid-utf-8-in-string
lone-invalid-utf-8
lone-utf-8-continuation-byte
not-in-unicode-range
overlong-3-byte-encoding
overlong-4-byte-encoding
overlong-ascii-encoding
restricted-utf-8
truncated-utf-8
invalid
apostrophe
ascii-unicode-identifier
brace-comma
bracket-comma
bracket-one-comma
double-closing-brace
double-closing-bracket
empty
escaped-null-byte-in-string
extra-comma-in-array
extra-comma-in-multiline-array
garbage-after-newline
garbage-at-the-end
integer-starting-with-zero
invalid-escape
invalid-identifier
invalid-negative-integer
invalid-negative-real
invalid-second-surrogate
lone-open-brace
lone-open-bracket
lone-second-surrogate
minus-sign-without-number
negative-integer-starting-with-zero
null-byte-in-string
null-byte-outside-string
null
object-apostrophes
object-garbage-at-end
object-in-unterminated-array
object-no-colon
object-no-value
object-unterminated-value
real-garbage-after-e
real-negative-overflow
real-positive-overflow
real-truncated-at-e
real-truncated-at-point
tab-character-in-string
too-big-negative-integer
too-big-positive-integer
truncated-unicode-surrogate
unicode-identifier
unterminated-array-and-object
unterminated-array
unterminated-empty-key
unterminated-key
unterminated-object-and-array
unterminated-string
valid
complex-array
complex-object
empty-array
empty-object-in-array
empty-object
empty-string
escaped-utf-control-char
false
negative-int
negative-one
negative-zero
null
one-byte-utf-8
real-capital-e-negative-exponent
real-capital-e-positive-exponent
real-capital-e
real-exponent
real-fraction-exponent
real-negative-exponent
real-positive-exponent
real-underflow
short-string
simple-ascii-string
simple-int-0
simple-int-1
simple-int-123
simple-object
simple-real
string-escapes
three-byte-utf-8
true
two-byte-utf-8
utf-8-string
utf-surrogate-four-byte-encoding
src
JWT
LICENSEMakefile
MongoDB
CMakeLists.txtMakefileMongoDB.progenMongoDB_vs140.slnMongoDB_vs140.vcxprojMongoDB_vs140.vcxproj.filtersMongoDB_vs150.slnMongoDB_vs150.vcxprojMongoDB_vs150.vcxproj.filtersMongoDB_vs160.slnMongoDB_vs160.vcxprojMongoDB_vs160.vcxproj.filtersMongoDB_vs90.slnMongoDB_vs90.vcproj
cmake
dependencies
include
samples
src
testsuite
NEWS
Net
CMakeLists.txtMakefileNet.progenNet_vs140.slnNet_vs140.vcxprojNet_vs140.vcxproj.filtersNet_vs150.slnNet_vs150.vcxprojNet_vs150.vcxproj.filtersNet_vs160.slnNet_vs160.vcxprojNet_vs160.vcxproj.filtersNet_vs90.slnNet_vs90.vcproj
cmake
dependencies
include
Poco
Net
AbstractHTTPRequestHandler.hDNS.hDatagramSocket.hDatagramSocketImpl.hDialogSocket.hEscapeHTMLStream.hFTPClientSession.hFTPStreamFactory.hFilePartSource.hHTMLForm.hHTTPAuthenticationParams.hHTTPBasicCredentials.hHTTPBasicStreamBuf.hHTTPBufferAllocator.hHTTPChunkedStream.hHTTPClientSession.hHTTPCookie.hHTTPCredentials.hHTTPDigestCredentials.hHTTPFixedLengthStream.hHTTPHeaderStream.hHTTPIOStream.hHTTPMessage.hHTTPNTLMCredentials.hHTTPRequest.hHTTPRequestHandler.hHTTPRequestHandlerFactory.hHTTPResponse.hHTTPServer.hHTTPServerConnection.hHTTPServerConnectionFactory.hHTTPServerParams.hHTTPServerRequest.hHTTPServerRequestImpl.hHTTPServerResponse.hHTTPServerResponseImpl.hHTTPServerSession.hHTTPSession.hHTTPSessionFactory.hHTTPSessionInstantiator.hHTTPStream.hHTTPStreamFactory.hHostEntry.hICMPClient.hICMPEventArgs.hICMPPacket.hICMPPacketImpl.hICMPSocket.hICMPSocketImpl.hICMPv4PacketImpl.hIPAddress.hIPAddressImpl.hMailMessage.hMailRecipient.hMailStream.hMediaType.hMessageHeader.hMultiSocketPoller.hMulticastSocket.hMultipartReader.hMultipartWriter.hNTLMCredentials.hNTPClient.hNTPEventArgs.hNTPPacket.hNameValueCollection.hNet.hNetException.hNetworkInterface.hNullPartHandler.hOAuth10Credentials.hOAuth20Credentials.hPOP3ClientSession.hParallelSocketAcceptor.hParallelSocketReactor.hPartHandler.hPartSource.hPartStore.hPollSet.hQuotedPrintableDecoder.hQuotedPrintableEncoder.hRawSocket.hRawSocketImpl.hRemoteSyslogChannel.hRemoteSyslogListener.hSMTPChannel.hSMTPClientSession.hSSPINTLMCredentials.hServerSocket.hServerSocketImpl.hSingleSocketPoller.hSocket.hSocketAcceptor.hSocketAddress.hSocketAddressImpl.hSocketConnector.hSocketDefs.hSocketImpl.hSocketNotification.hSocketNotifier.hSocketReactor.hSocketStream.hStreamSocket.hStreamSocketImpl.hStringPartSource.hTCPServer.hTCPServerConnection.hTCPServerConnectionFactory.hTCPServerDispatcher.hTCPServerParams.hUDPClient.hUDPHandler.hUDPServer.hUDPServerParams.hUDPSocketReader.hWebSocket.hWebSocketImpl.h
samples
CMakeLists.txt
EchoServer
HTTPFormServer
HTTPLoadTest
HTTPTimeServer
Mail
Makefile
Ping
SMTPLogger
TimeServer
WebSocketServer
dependencies
dict
download
httpget
ifconfig
samples.progensamples_vs140.slnsamples_vs150.slnsamples_vs160.slnsamples_vs90.sln
tcpserver
src
AbstractHTTPRequestHandler.cppDNS.cppDatagramSocket.cppDatagramSocketImpl.cppDialogSocket.cppEscapeHTMLStream.cppFTPClientSession.cppFTPStreamFactory.cppFilePartSource.cppHTMLForm.cppHTTPAuthenticationParams.cppHTTPBasicCredentials.cppHTTPBufferAllocator.cppHTTPChunkedStream.cppHTTPClientSession.cppHTTPCookie.cppHTTPCredentials.cppHTTPDigestCredentials.cppHTTPFixedLengthStream.cppHTTPHeaderStream.cppHTTPIOStream.cppHTTPMessage.cppHTTPNTLMCredentials.cppHTTPRequest.cppHTTPRequestHandler.cppHTTPRequestHandlerFactory.cppHTTPResponse.cppHTTPServer.cppHTTPServerConnection.cppHTTPServerConnectionFactory.cppHTTPServerParams.cppHTTPServerRequest.cppHTTPServerRequestImpl.cppHTTPServerResponse.cppHTTPServerResponseImpl.cppHTTPServerSession.cppHTTPSession.cppHTTPSessionFactory.cppHTTPSessionInstantiator.cppHTTPStream.cppHTTPStreamFactory.cppHostEntry.cppICMPClient.cppICMPEventArgs.cppICMPPacket.cppICMPPacketImpl.cppICMPSocket.cppICMPSocketImpl.cppICMPv4PacketImpl.cppIPAddress.cppIPAddressImpl.cppMailMessage.cppMailRecipient.cppMailStream.cppMediaType.cppMessageHeader.cppMulticastSocket.cppMultipartReader.cppMultipartWriter.cppNTLMCredentials.cppNTPClient.cppNTPEventArgs.cppNTPPacket.cppNameValueCollection.cppNet.cppNetException.cppNetworkInterface.cppNullPartHandler.cppOAuth10Credentials.cppOAuth20Credentials.cppPOP3ClientSession.cppPartHandler.cppPartSource.cppPartStore.cppPollSet.cppQuotedPrintableDecoder.cppQuotedPrintableEncoder.cppRawSocket.cppRawSocketImpl.cppRemoteSyslogChannel.cppRemoteSyslogListener.cppSMTPChannel.cppSMTPClientSession.cppSSPINTLMCredentials.cppServerSocket.cppServerSocketImpl.cppSocket.cppSocketAddress.cppSocketAddressImpl.cppSocketImpl.cppSocketNotification.cppSocketNotifier.cppSocketReactor.cppSocketStream.cppStreamSocket.cppStreamSocketImpl.cppStringPartSource.cppTCPServer.cppTCPServerConnection.cppTCPServerConnectionFactory.cppTCPServerDispatcher.cppTCPServerParams.cppUDPClient.cppUDPServerParams.cppWebSocket.cppWebSocketImpl.cpp
testsuite
CMakeLists.txtMakefileTestSuite.progenTestSuite_vs140.vcxprojTestSuite_vs140.vcxproj.filtersTestSuite_vs150.vcxprojTestSuite_vs150.vcxproj.filtersTestSuite_vs160.vcxprojTestSuite_vs160.vcxproj.filtersTestSuite_vs90.vcproj
src
DNSTest.cppDNSTest.hDatagramSocketTest.cppDatagramSocketTest.hDialogServer.cppDialogServer.hDialogSocketTest.cppDialogSocketTest.hDriver.cppEchoServer.cppEchoServer.hFTPClientSessionTest.cppFTPClientSessionTest.hFTPClientTestSuite.cppFTPClientTestSuite.hFTPStreamFactoryTest.cppFTPStreamFactoryTest.hHTMLFormTest.cppHTMLFormTest.hHTMLTestSuite.cppHTMLTestSuite.hHTTPClientSessionTest.cppHTTPClientSessionTest.hHTTPClientTestSuite.cppHTTPClientTestSuite.hHTTPCookieTest.cppHTTPCookieTest.hHTTPCredentialsTest.cppHTTPCredentialsTest.hHTTPRequestTest.cppHTTPRequestTest.hHTTPResponseTest.cppHTTPResponseTest.hHTTPServerTest.cppHTTPServerTest.hHTTPServerTestSuite.cppHTTPServerTestSuite.hHTTPStreamFactoryTest.cppHTTPStreamFactoryTest.hHTTPTestServer.cppHTTPTestServer.hHTTPTestSuite.cppHTTPTestSuite.hICMPClientTest.cppICMPClientTest.hICMPClientTestSuite.cppICMPClientTestSuite.hICMPSocketTest.cppICMPSocketTest.hIPAddressTest.cppIPAddressTest.hMailMessageTest.cppMailMessageTest.hMailStreamTest.cppMailStreamTest.hMailTestSuite.cppMailTestSuite.hMediaTypeTest.cppMediaTypeTest.hMessageHeaderTest.cppMessageHeaderTest.hMessagesTestSuite.cppMessagesTestSuite.hMulticastEchoServer.cppMulticastEchoServer.hMulticastSocketTest.cppMulticastSocketTest.hMultipartReaderTest.cppMultipartReaderTest.hMultipartWriterTest.cppMultipartWriterTest.hNTLMCredentialsTest.cppNTLMCredentialsTest.hNTPClientTest.cppNTPClientTest.hNTPClientTestSuite.cppNTPClientTestSuite.hNameValueCollectionTest.cppNameValueCollectionTest.hNetCoreTestSuite.cppNetCoreTestSuite.hNetTestSuite.cppNetTestSuite.hNetworkInterfaceTest.cppNetworkInterfaceTest.hOAuth10CredentialsTest.cppOAuth10CredentialsTest.hOAuth20CredentialsTest.cppOAuth20CredentialsTest.hOAuthTestSuite.cppOAuthTestSuite.hPOP3ClientSessionTest.cppPOP3ClientSessionTest.hPollSetTest.cppPollSetTest.hQuotedPrintableTest.cppQuotedPrintableTest.hRawSocketTest.cppRawSocketTest.hReactorTestSuite.cppReactorTestSuite.hSMTPClientSessionTest.cppSMTPClientSessionTest.hSocketAddressTest.cppSocketAddressTest.hSocketReactorTest.cppSocketReactorTest.hSocketStreamTest.cppSocketStreamTest.hSocketTest.cppSocketTest.hSocketsTestSuite.cppSocketsTestSuite.hSyslogTest.cppSyslogTest.hTCPServerTest.cppTCPServerTest.hTCPServerTestSuite.cppTCPServerTestSuite.hUDPEchoServer.cppUDPEchoServer.hUDPServerTest.cppUDPServerTest.hUDPServerTestSuite.cppUDPServerTestSuite.hWebSocketTest.cppWebSocketTest.hWebSocketTestSuite.cppWebSocketTestSuite.hWinCEDriver.cppWinDriver.cpp
NetSSL_OpenSSL
CMakeLists.txtMakefileNetSSL_OpenSSL.progenNetSSL_OpenSSL_vs140.slnNetSSL_OpenSSL_vs140.vcxprojNetSSL_OpenSSL_vs140.vcxproj.filtersNetSSL_OpenSSL_vs150.slnNetSSL_OpenSSL_vs150.vcxprojNetSSL_OpenSSL_vs150.vcxproj.filtersNetSSL_OpenSSL_vs160.slnNetSSL_OpenSSL_vs160.vcxprojNetSSL_OpenSSL_vs160.vcxproj.filtersNetSSL_OpenSSL_vs90.slnNetSSL_OpenSSL_vs90.vcproj
cmake
dependencies
doc
include
samples
src
testsuite
NetSSL_Win
CMakeLists.txtNetSSL_Win.progenNetSSL_Win_vs140.slnNetSSL_Win_vs140.vcxprojNetSSL_Win_vs140.vcxproj.filtersNetSSL_Win_vs150.slnNetSSL_Win_vs150.vcxprojNetSSL_Win_vs150.vcxproj.filtersNetSSL_Win_vs160.slnNetSSL_Win_vs160.vcxprojNetSSL_Win_vs160.vcxproj.filtersNetSSL_Win_vs90.slnNetSSL_Win_vs90.vcproj
cmake
doc
include
samples
src
testsuite
PDF
CMakeLists.txtMakefilePDF.progenPDF_vs140.slnPDF_vs140.vcxprojPDF_vs140.vcxproj.filtersPDF_vs150.slnPDF_vs150.vcxprojPDF_vs150.vcxproj.filtersPDF_vs160.slnPDF_vs160.vcxprojPDF_vs160.vcxproj.filtersPDF_vs90.slnPDF_vs90.vcproj
cmake
dependencies
include
samples
src
testsuite
PageCompiler
PocoDoc
ProGen
ProGen.progenProGen_vs140.slnProGen_vs140.vcxprojProGen_vs140.vcxproj.filtersProGen_vs150.slnProGen_vs150.vcxprojProGen_vs150.vcxproj.filtersProGen_vs160.slnProGen_vs160.vcxprojProGen_vs160.vcxproj.filtersProGen_vs90.slnProGen_vs90.vcprojprogen.batprogen.propertiesprogen32.batprogen64.batrebuildall32.batrebuildall64.bat
src
templates
vs140
vs150
vs160
READMEREADME.md
Redis
SevenZip
Util
CMakeLists.txtMakefileUtil.progenUtil_vs140.slnUtil_vs140.vcxprojUtil_vs140.vcxproj.filtersUtil_vs150.slnUtil_vs150.vcxprojUtil_vs150.vcxproj.filtersUtil_vs160.slnUtil_vs160.vcxprojUtil_vs160.vcxproj.filtersUtil_vs90.slnUtil_vs90.vcproj
cmake
dependencies
include
samples
src
testsuite
VERSION
XML
CMakeLists.txtMakefileXML.progenXML_vs140.slnXML_vs140.vcxprojXML_vs140.vcxproj.filtersXML_vs150.slnXML_vs150.vcxprojXML_vs150.vcxproj.filtersXML_vs160.slnXML_vs160.vcxprojXML_vs160.vcxproj.filtersXML_vs90.slnXML_vs90.vcproj
cmake
dependencies
include
samples
src
testsuite
Zip
CMakeLists.txtMakefileZip.progenZip_vs140.slnZip_vs140.vcxprojZip_vs140.vcxproj.filtersZip_vs150.slnZip_vs150.vcxprojZip_vs150.vcxproj.filtersZip_vs160.slnZip_vs160.vcxprojZip_vs160.vcxproj.filtersZip_vs90.slnZip_vs90.vcproj
cmake
dependencies
doc
include
samples
src
testsuite
appveyor.yml
appveyor
build
build_cmake.cmdbuild_cmake.shbuild_vs140.cmdbuild_vs150.cmdbuild_vs160.cmdbuildwin.cmdbuildwin.ps1
cmake
componentsconfigure
contrib
cppignore.lnxcppignore.win
doc
env.batenv.shlibversion
packaging
patches
release
travis
SimpleIni
Squirrel
TinyDir

@ -0,0 +1,110 @@
//
// Array.h
//
// Library: MongoDB
// Package: MongoDB
// Module: Array
//
// Definition of the Array class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_Array_INCLUDED
#define MongoDB_Array_INCLUDED
#include "Poco/NumberFormatter.h"
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Document.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API Array: public Document
/// This class represents a BSON Array.
{
public:
using Ptr = SharedPtr<Array>;
Array();
/// Creates an empty Array.
virtual ~Array();
/// Destroys the Array.
template<typename T>
T get(int pos) const
/// Returns the element at the given index and tries to convert
/// it to the template type. If the element is not found, a
/// Poco::NotFoundException will be thrown. If the element cannot be
/// converted a BadCastException will be thrown.
{
return Document::get<T>(Poco::NumberFormatter::format(pos));
}
template<typename T>
T get(int pos, const T& deflt) const
/// Returns the element at the given index and tries to convert
/// it to the template type. If the element is not found, or
/// has the wrong type, the deflt argument will be returned.
{
return Document::get<T>(Poco::NumberFormatter::format(pos), deflt);
}
Element::Ptr get(int pos) const;
/// Returns the element at the given index.
/// An empty element will be returned if the element is not found.
template<typename T>
bool isType(int pos) const
/// Returns true if the type of the element equals the TypeId of ElementTrait,
/// otherwise false.
{
return Document::isType<T>(Poco::NumberFormatter::format(pos));
}
std::string toString(int indent = 0) const;
/// Returns a string representation of the Array.
};
// BSON Embedded Array
// spec: document
template<>
struct ElementTraits<Array::Ptr>
{
enum { TypeId = 0x04 };
static std::string toString(const Array::Ptr& value, int indent = 0)
{
//TODO:
return value.isNull() ? "null" : value->toString(indent);
}
};
template<>
inline void BSONReader::read<Array::Ptr>(Array::Ptr& to)
{
to->read(_reader);
}
template<>
inline void BSONWriter::write<Array::Ptr>(Array::Ptr& from)
{
from->write(_writer);
}
} } // namespace Poco::MongoDB
#endif // MongoDB_Array_INCLUDED

@ -0,0 +1,84 @@
//
// BSONReader.h
//
// Library: MongoDB
// Package: MongoDB
// Module: BSONReader
//
// Definition of the BSONReader class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_BSONReader_INCLUDED
#define MongoDB_BSONReader_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/BinaryReader.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API BSONReader
/// Class for reading BSON using a Poco::BinaryReader
{
public:
BSONReader(const Poco::BinaryReader& reader):
_reader(reader)
/// Creates the BSONReader using the given BinaryWriter.
{
}
virtual ~BSONReader()
/// Destroys the BSONReader.
{
}
template<typename T>
void read(T& t)
/// Reads the value from the reader. The default implementation uses the >> operator to
/// the given argument. Special types can write their own version.
{
_reader >> t;
}
std::string readCString();
/// Reads a cstring from the reader.
/// A cstring is a string terminated with a 0x00.
private:
Poco::BinaryReader _reader;
};
//
// inlines
//
inline std::string BSONReader::readCString()
{
std::string val;
while(_reader.good())
{
char c;
_reader >> c;
if ( _reader.good() )
{
if (c == 0x00) return val;
else val += c;
}
}
return val;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_BSONReader_INCLUDED

@ -0,0 +1,74 @@
//
// BSONWriter.h
//
// Library: MongoDB
// Package: MongoDB
// Module: BSONWriter
//
// Definition of the BSONWriter class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_BSONWriter_INCLUDED
#define MongoDB_BSONWriter_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/BinaryWriter.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API BSONWriter
/// Class for writing BSON using a Poco::BinaryWriter.
{
public:
BSONWriter(const Poco::BinaryWriter& writer):
_writer(writer)
/// Creates the BSONWriter.
{
}
virtual ~BSONWriter()
/// Destroys the BSONWriter.
{
}
template<typename T>
void write(T& t)
/// Writes the value to the writer. The default implementation uses
/// the << operator. Special types can write their own version.
{
_writer << t;
}
void writeCString(const std::string& value);
/// Writes a cstring to the writer. A cstring is a string
/// terminated a null character.
private:
Poco::BinaryWriter _writer;
};
//
// inlines
//
inline void BSONWriter::writeCString(const std::string& value)
{
_writer.writeRaw(value);
_writer << (unsigned char) 0x00;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_BSONWriter_INCLUDED

@ -0,0 +1,155 @@
//
// Binary.h
//
// Library: MongoDB
// Package: MongoDB
// Module: Binary
//
// Definition of the Binary class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_Binary_INCLUDED
#define MongoDB_Binary_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Element.h"
#include "Poco/Base64Encoder.h"
#include "Poco/Buffer.h"
#include "Poco/StreamCopier.h"
#include "Poco/MemoryStream.h"
#include "Poco/UUID.h"
#include <sstream>
namespace Poco {
namespace MongoDB {
class MongoDB_API Binary
/// Implements BSON Binary.
///
/// A Binary stores its data in a Poco::Buffer<unsigned char>.
{
public:
using Ptr = SharedPtr<Binary>;
Binary();
/// Creates an empty Binary with subtype 0.
Binary(Poco::Int32 size, unsigned char subtype);
/// Creates a Binary with a buffer of the given size and the given subtype.
Binary(const UUID& uuid);
/// Creates a Binary containing an UUID.
Binary(const std::string& data, unsigned char subtype = 0);
/// Creates a Binary with the contents of the given string and the given subtype.
Binary(const void* data, Poco::Int32 size, unsigned char subtype = 0);
/// Creates a Binary with the contents of the given buffer and the given subtype.
virtual ~Binary();
/// Destroys the Binary.
Buffer<unsigned char>& buffer();
/// Returns a reference to the internal buffer
unsigned char subtype() const;
/// Returns the subtype.
void subtype(unsigned char type);
/// Sets the subtype.
std::string toString(int indent = 0) const;
/// Returns the contents of the Binary as Base64-encoded string.
std::string toRawString() const;
/// Returns the raw content of the Binary as a string.
UUID uuid() const;
/// Returns the UUID when the binary subtype is 0x04.
/// Otherwise, throws a Poco::BadCastException.
private:
Buffer<unsigned char> _buffer;
unsigned char _subtype;
};
//
// inlines
//
inline unsigned char Binary::subtype() const
{
return _subtype;
}
inline void Binary::subtype(unsigned char type)
{
_subtype = type;
}
inline Buffer<unsigned char>& Binary::buffer()
{
return _buffer;
}
inline std::string Binary::toRawString() const
{
return std::string(reinterpret_cast<const char*>(_buffer.begin()), _buffer.size());
}
// BSON Embedded Document
// spec: binary
template<>
struct ElementTraits<Binary::Ptr>
{
enum { TypeId = 0x05 };
static std::string toString(const Binary::Ptr& value, int indent = 0)
{
return value.isNull() ? "" : value->toString();
}
};
template<>
inline void BSONReader::read<Binary::Ptr>(Binary::Ptr& to)
{
Poco::Int32 size;
_reader >> size;
to->buffer().resize(size);
unsigned char subtype;
_reader >> subtype;
to->subtype(subtype);
_reader.readRaw((char*) to->buffer().begin(), size);
}
template<>
inline void BSONWriter::write<Binary::Ptr>(Binary::Ptr& from)
{
_writer << (Poco::Int32) from->buffer().size();
_writer << from->subtype();
_writer.writeRaw((char*) from->buffer().begin(), from->buffer().size());
}
} } // namespace Poco::MongoDB
#endif // MongoDB_Binary_INCLUDED

@ -0,0 +1,164 @@
//
// Connection.h
//
// Library: MongoDB
// Package: MongoDB
// Module: Connection
//
// Definition of the Connection class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_Connection_INCLUDED
#define MongoDB_Connection_INCLUDED
#include "Poco/Net/SocketAddress.h"
#include "Poco/Net/StreamSocket.h"
#include "Poco/Mutex.h"
#include "Poco/MongoDB/RequestMessage.h"
#include "Poco/MongoDB/ResponseMessage.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API Connection
/// Represents a connection to a MongoDB server
/// using the MongoDB wire protocol.
///
/// See https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/
/// for more information on the wire protocol.
{
public:
using Ptr = Poco::SharedPtr<Connection>;
class MongoDB_API SocketFactory
{
public:
SocketFactory();
/// Creates the SocketFactory.
virtual ~SocketFactory();
/// Destroys the SocketFactory.
virtual Poco::Net::StreamSocket createSocket(const std::string& host, int port, Poco::Timespan connectTimeout, bool secure);
/// Creates a Poco::Net::StreamSocket (if secure is false), or a
/// Poco::Net::SecureStreamSocket (if secure is true) connected to the
/// given host and port number.
///
/// The default implementation will throw a Poco::NotImplementedException
/// if secure is true.
};
Connection();
/// Creates an unconnected Connection.
///
/// Use this when you want to connect later on.
Connection(const std::string& hostAndPort);
/// Creates a Connection connected to the given MongoDB instance at host:port.
///
/// The host and port must be separated with a colon.
Connection(const std::string& uri, SocketFactory& socketFactory);
/// Creates a Connection connected to the given MongoDB instance at the
/// given URI.
///
/// See the corresponding connect() method for more information.
Connection(const std::string& host, int port);
/// Creates a Connection connected to the given MongoDB instance at host and port.
Connection(const Poco::Net::SocketAddress& addrs);
/// Creates a Connection connected to the given MongoDB instance at the given address.
Connection(const Poco::Net::StreamSocket& socket);
/// Creates a Connection connected to the given MongoDB instance using the given socket,
/// which must already be connected.
virtual ~Connection();
/// Destroys the Connection.
Poco::Net::SocketAddress address() const;
/// Returns the address of the MongoDB server.
void connect(const std::string& hostAndPort);
/// Connects to the given MongoDB server.
///
/// The host and port must be separated with a colon.
void connect(const std::string& uri, SocketFactory& socketFactory);
/// Connects to the given MongoDB instance at the given URI.
///
/// The URI must be in standard MongoDB connection string URI format:
///
/// mongodb://<user>:<password>@hostname.com:<port>/database-name?options
///
/// The following options are supported:
///
/// - ssl: If ssl=true is specified, a custom SocketFactory subclass creating
/// a SecureStreamSocket must be supplied.
/// - connectTimeoutMS: Socket connection timeout in milliseconds.
/// - socketTimeoutMS: Socket send/receive timeout in milliseconds.
/// - authMechanism: Authentication mechanism. Only "SCRAM-SHA-1" (default)
/// and "MONGODB-CR" are supported.
///
/// Unknown options are silently ignored.
///
/// Will also attempt to authenticate using the specified credentials,
/// using Database::authenticate().
///
/// Throws a Poco::NoPermissionException if authentication fails.
void connect(const std::string& host, int port);
/// Connects to the given MongoDB server.
void connect(const Poco::Net::SocketAddress& addrs);
/// Connects to the given MongoDB server.
void connect(const Poco::Net::StreamSocket& socket);
/// Connects using an already connected socket.
void disconnect();
/// Disconnects from the MongoDB server.
void sendRequest(RequestMessage& request);
/// Sends a request to the MongoDB server.
///
/// Used for one-way requests without a response.
void sendRequest(RequestMessage& request, ResponseMessage& response);
/// Sends a request to the MongoDB server and receives the response.
///
/// Use this when a response is expected: only a "query" or "getmore"
/// request will return a response.
protected:
void connect();
private:
Poco::Net::SocketAddress _address;
Poco::Net::StreamSocket _socket;
};
//
// inlines
//
inline Net::SocketAddress Connection::address() const
{
return _address;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_Connection_INCLUDED

@ -0,0 +1,74 @@
//
// Cursor.h
//
// Library: MongoDB
// Package: MongoDB
// Module: Cursor
//
// Definition of the Cursor class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_Cursor_INCLUDED
#define MongoDB_Cursor_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Connection.h"
#include "Poco/MongoDB/QueryRequest.h"
#include "Poco/MongoDB/ResponseMessage.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API Cursor: public Document
/// Cursor is an helper class for querying multiple documents.
{
public:
Cursor(const std::string& dbname, const std::string& collectionName, QueryRequest::Flags flags = QueryRequest::QUERY_DEFAULT);
/// Creates a Cursor for the given database and collection, using the specified flags.
Cursor(const std::string& fullCollectionName, QueryRequest::Flags flags = QueryRequest::QUERY_DEFAULT);
/// Creates a Cursor for the given database and collection ("database.collection"), using the specified flags.
virtual ~Cursor();
/// Destroys the Cursor.
ResponseMessage& next(Connection& connection);
/// Tries to get the next documents. As long as ResponseMessage has a
/// cursor ID next can be called to retrieve the next bunch of documents.
///
/// The cursor must be killed (see kill()) when not all documents are needed.
QueryRequest& query();
/// Returns the associated query.
void kill(Connection& connection);
/// Kills the cursor and reset it so that it can be reused.
private:
QueryRequest _query;
ResponseMessage _response;
};
//
// inlines
//
inline QueryRequest& Cursor::query()
{
return _query;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_Cursor_INCLUDED

@ -0,0 +1,162 @@
//
// Database.h
//
// Library: MongoDB
// Package: MongoDB
// Module: Database
//
// Definition of the Database class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_Database_INCLUDED
#define MongoDB_Database_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Connection.h"
#include "Poco/MongoDB/Document.h"
#include "Poco/MongoDB/QueryRequest.h"
#include "Poco/MongoDB/InsertRequest.h"
#include "Poco/MongoDB/UpdateRequest.h"
#include "Poco/MongoDB/DeleteRequest.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API Database
/// Database is a helper class for creating requests. MongoDB works with
/// collection names and uses the part before the first dot as the name of
/// the database.
{
public:
explicit Database(const std::string& name);
/// Creates a Database for the database with the given name.
virtual ~Database();
/// Destroys the Database.
bool authenticate(Connection& connection, const std::string& username, const std::string& password, const std::string& method = AUTH_SCRAM_SHA1);
/// Authenticates against the database using the given connection,
/// username and password, as well as authentication method.
///
/// "MONGODB-CR" (default prior to MongoDB 3.0) and
/// "SCRAM-SHA-1" (default starting in 3.0) are the only supported
/// authentication methods.
///
/// Returns true if authentication was successful, otherwise false.
///
/// May throw a Poco::ProtocolException if authentication fails for a reason other than
/// invalid credentials.
Int64 count(Connection& connection, const std::string& collectionName) const;
/// Sends a count request for the given collection to MongoDB.
///
/// If the command fails, -1 is returned.
Poco::SharedPtr<Poco::MongoDB::QueryRequest> createCommand() const;
/// Creates a QueryRequest for a command.
Poco::SharedPtr<Poco::MongoDB::QueryRequest> createCountRequest(const std::string& collectionName) const;
/// Creates a QueryRequest to count the given collection.
/// The collectionname must not contain the database name.
Poco::SharedPtr<Poco::MongoDB::DeleteRequest> createDeleteRequest(const std::string& collectionName) const;
/// Creates a DeleteRequest to delete documents in the given collection.
/// The collectionname must not contain the database name.
Poco::SharedPtr<Poco::MongoDB::InsertRequest> createInsertRequest(const std::string& collectionName) const;
/// Creates an InsertRequest to insert new documents in the given collection.
/// The collectionname must not contain the database name.
Poco::SharedPtr<Poco::MongoDB::QueryRequest> createQueryRequest(const std::string& collectionName) const;
/// Creates a QueryRequest.
/// The collectionname must not contain the database name.
Poco::SharedPtr<Poco::MongoDB::UpdateRequest> createUpdateRequest(const std::string& collectionName) const;
/// Creates an UpdateRequest.
/// The collectionname must not contain the database name.
Poco::MongoDB::Document::Ptr ensureIndex(Connection& connection,
const std::string& collection,
const std::string& indexName,
Poco::MongoDB::Document::Ptr keys,
bool unique = false,
bool background = false,
int version = 0,
int ttl = 0);
/// Creates an index. The document returned is the result of a getLastError call.
/// For more info look at the ensureIndex information on the MongoDB website.
Document::Ptr getLastErrorDoc(Connection& connection) const;
/// Sends the getLastError command to the database and returns the error document.
std::string getLastError(Connection& connection) const;
/// Sends the getLastError command to the database and returns the err element
/// from the error document. When err is null, an empty string is returned.
static const std::string AUTH_MONGODB_CR;
/// Default authentication mechanism prior to MongoDB 3.0.
static const std::string AUTH_SCRAM_SHA1;
/// Default authentication mechanism for MongoDB 3.0.
protected:
bool authCR(Connection& connection, const std::string& username, const std::string& password);
bool authSCRAM(Connection& connection, const std::string& username, const std::string& password);
private:
std::string _dbname;
};
//
// inlines
//
inline Poco::SharedPtr<Poco::MongoDB::QueryRequest> Database::createCommand() const
{
Poco::SharedPtr<Poco::MongoDB::QueryRequest> cmd = createQueryRequest("$cmd");
cmd->setNumberToReturn(1);
return cmd;
}
inline Poco::SharedPtr<Poco::MongoDB::DeleteRequest>
Database::createDeleteRequest(const std::string& collectionName) const
{
return new Poco::MongoDB::DeleteRequest(_dbname + '.' + collectionName);
}
inline Poco::SharedPtr<Poco::MongoDB::InsertRequest>
Database::createInsertRequest(const std::string& collectionName) const
{
return new Poco::MongoDB::InsertRequest(_dbname + '.' + collectionName);
}
inline Poco::SharedPtr<Poco::MongoDB::QueryRequest>
Database::createQueryRequest(const std::string& collectionName) const
{
return new Poco::MongoDB::QueryRequest(_dbname + '.' + collectionName);
}
inline Poco::SharedPtr<Poco::MongoDB::UpdateRequest>
Database::createUpdateRequest(const std::string& collectionName) const
{
return new Poco::MongoDB::UpdateRequest(_dbname + '.' + collectionName);
}
} } // namespace Poco::MongoDB
#endif // MongoDB_Database_INCLUDED

@ -0,0 +1,113 @@
//
// DeleteRequest.h
//
// Library: MongoDB
// Package: MongoDB
// Module: DeleteRequest
//
// Definition of the DeleteRequest class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_DeleteRequest_INCLUDED
#define MongoDB_DeleteRequest_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/RequestMessage.h"
#include "Poco/MongoDB/Document.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API DeleteRequest: public RequestMessage
/// A DeleteRequest is used to delete one ore more documents from a database.
///
/// Specific flags for this request
/// - DELETE_DEFAULT: default delete operation
/// - DELETE_SINGLE_REMOVE: delete only the first document
{
public:
enum Flags
{
DELETE_DEFAULT = 0,
/// Default
DELETE_SINGLE_REMOVE = 1
/// Delete only the first document.
};
DeleteRequest(const std::string& collectionName, Flags flags = DELETE_DEFAULT);
/// Creates a DeleteRequest for the given collection using the given flags.
///
/// The full collection name is the concatenation of the database
/// name with the collection name, using a "." for the concatenation. For example,
/// for the database "foo" and the collection "bar", the full collection name is
/// "foo.bar".
DeleteRequest(const std::string& collectionName, bool justOne);
/// Creates a DeleteRequest for the given collection.
///
/// The full collection name is the concatenation of the database
/// name with the collection name, using a "." for the concatenation. For example,
/// for the database "foo" and the collection "bar", the full collection name is
/// "foo.bar".
///
/// If justOne is true, only the first matching document will
/// be removed (the same as using flag DELETE_SINGLE_REMOVE).
virtual ~DeleteRequest();
/// Destructor
Flags flags() const;
/// Returns the flags.
void flags(Flags flag);
/// Sets the flags.
Document& selector();
/// Returns the selector document.
protected:
void buildRequest(BinaryWriter& writer);
/// Writes the OP_DELETE request to the writer.
private:
Flags _flags;
std::string _fullCollectionName;
Document _selector;
};
///
/// inlines
///
inline DeleteRequest::Flags DeleteRequest::flags() const
{
return _flags;
}
inline void DeleteRequest::flags(DeleteRequest::Flags flags)
{
_flags = flags;
}
inline Document& DeleteRequest::selector()
{
return _selector;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_DeleteRequest_INCLUDED

@ -0,0 +1,277 @@
//
// Document.h
//
// Library: MongoDB
// Package: MongoDB
// Module: Document
//
// Definition of the Document class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_Document_INCLUDED
#define MongoDB_Document_INCLUDED
#include "Poco/BinaryReader.h"
#include "Poco/BinaryWriter.h"
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Element.h"
#include <algorithm>
#include <cstdlib>
namespace Poco {
namespace MongoDB {
class ElementFindByName
{
public:
ElementFindByName(const std::string& name):
_name(name)
{
}
bool operator()(const Element::Ptr& element)
{
return !element.isNull() && element->name() == _name;
}
private:
std::string _name;
};
class MongoDB_API Document
/// Represents a MongoDB (BSON) document.
{
public:
using Ptr = SharedPtr<Document>;
using Vector = std::vector<Document::Ptr>;
Document();
/// Creates an empty Document.
virtual ~Document();
/// Destroys the Document.
Document& addElement(Element::Ptr element);
/// Add an element to the document.
///
/// The active document is returned to allow chaining of the add methods.
template<typename T>
Document& add(const std::string& name, T value)
/// Creates an element with the given name and value and
/// adds it to the document.
///
/// The active document is returned to allow chaining of the add methods.
{
return addElement(new ConcreteElement<T>(name, value));
}
Document& add(const std::string& name, const char* value)
/// Creates an element with the given name and value and
/// adds it to the document.
///
/// The active document is returned to allow chaining of the add methods.
{
return addElement(new ConcreteElement<std::string>(name, std::string(value)));
}
Document& addNewDocument(const std::string& name);
/// Create a new document and add it to this document.
/// Unlike the other add methods, this method returns
/// a reference to the new document.
void clear();
/// Removes all elements from the document.
void elementNames(std::vector<std::string>& keys) const;
/// Puts all element names into std::vector.
bool empty() const;
/// Returns true if the document doesn't contain any documents.
bool exists(const std::string& name);
/// Returns true if the document has an element with the given name.
template<typename T>
T get(const std::string& name) const
/// Returns the element with the given name and tries to convert
/// it to the template type. When the element is not found, a
/// NotFoundException will be thrown. When the element can't be
/// converted a BadCastException will be thrown.
{
Element::Ptr element = get(name);
if (element.isNull())
{
throw NotFoundException(name);
}
else
{
if (ElementTraits<T>::TypeId == element->type())
{
ConcreteElement<T>* concrete = dynamic_cast<ConcreteElement<T>* >(element.get());
if (concrete != 0)
{
return concrete->value();
}
}
throw BadCastException("Invalid type mismatch!");
}
}
template<typename T>
T get(const std::string& name, const T& def) const
/// Returns the element with the given name and tries to convert
/// it to the template type. When the element is not found, or
/// has the wrong type, the def argument will be returned.
{
Element::Ptr element = get(name);
if (element.isNull())
{
return def;
}
if (ElementTraits<T>::TypeId == element->type())
{
ConcreteElement<T>* concrete = dynamic_cast<ConcreteElement<T>* >(element.get());
if (concrete != 0)
{
return concrete->value();
}
}
return def;
}
Element::Ptr get(const std::string& name) const;
/// Returns the element with the given name.
/// An empty element will be returned when the element is not found.
Int64 getInteger(const std::string& name) const;
/// Returns an integer. Useful when MongoDB returns Int32, Int64
/// or double for a number (count for example). This method will always
/// return an Int64. When the element is not found, a
/// Poco::NotFoundException will be thrown.
template<typename T>
bool isType(const std::string& name) const
/// Returns true when the type of the element equals the TypeId of ElementTrait.
{
Element::Ptr element = get(name);
if (element.isNull())
{
return false;
}
return ElementTraits<T>::TypeId == element->type();
}
void read(BinaryReader& reader);
/// Reads a document from the reader
std::size_t size() const;
/// Returns the number of elements in the document.
virtual std::string toString(int indent = 0) const;
/// Returns a String representation of the document.
void write(BinaryWriter& writer);
/// Writes a document to the reader
protected:
ElementSet _elements;
};
//
// inlines
//
inline Document& Document::addElement(Element::Ptr element)
{
_elements.push_back(element);
return *this;
}
inline Document& Document::addNewDocument(const std::string& name)
{
Document::Ptr newDoc = new Document();
add(name, newDoc);
return *newDoc;
}
inline void Document::clear()
{
_elements.clear();
}
inline bool Document::empty() const
{
return _elements.empty();
}
inline void Document::elementNames(std::vector<std::string>& keys) const
{
for (ElementSet::const_iterator it = _elements.begin(); it != _elements.end(); ++it)
{
keys.push_back((*it)->name());
}
}
inline bool Document::exists(const std::string& name)
{
return std::find_if(_elements.begin(), _elements.end(), ElementFindByName(name)) != _elements.end();
}
inline std::size_t Document::size() const
{
return _elements.size();
}
// BSON Embedded Document
// spec: document
template<>
struct ElementTraits<Document::Ptr>
{
enum { TypeId = 0x03 };
static std::string toString(const Document::Ptr& value, int indent = 0)
{
return value.isNull() ? "null" : value->toString(indent);
}
};
template<>
inline void BSONReader::read<Document::Ptr>(Document::Ptr& to)
{
to->read(_reader);
}
template<>
inline void BSONWriter::write<Document::Ptr>(Document::Ptr& from)
{
from->write(_writer);
}
} } // namespace Poco::MongoDB
#endif // MongoDB_Document_INCLUDED

@ -0,0 +1,403 @@
//
// Element.h
//
// Library: MongoDB
// Package: MongoDB
// Module: Element
//
// Definition of the Element class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_Element_INCLUDED
#define MongoDB_Element_INCLUDED
#include "Poco/BinaryReader.h"
#include "Poco/BinaryWriter.h"
#include "Poco/SharedPtr.h"
#include "Poco/Timestamp.h"
#include "Poco/Nullable.h"
#include "Poco/NumberFormatter.h"
#include "Poco/DateTimeFormatter.h"
#include "Poco/UTF8String.h"
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/BSONReader.h"
#include "Poco/MongoDB/BSONWriter.h"
#include <string>
#include <sstream>
#include <iomanip>
#include <list>
namespace Poco {
namespace MongoDB {
class MongoDB_API Element
/// Represents an Element of a Document or an Array.
{
public:
using Ptr = Poco::SharedPtr<Element>;
explicit Element(const std::string& name);
/// Creates the Element with the given name.
virtual ~Element();
/// Destructor
const std::string& name() const;
/// Returns the name of the element.
virtual std::string toString(int indent = 0) const = 0;
/// Returns a string representation of the element.
virtual int type() const = 0;
/// Returns the MongoDB type of the element.
private:
virtual void read(BinaryReader& reader) = 0;
virtual void write(BinaryWriter& writer) = 0;
friend class Document;
std::string _name;
};
//
// inlines
//
inline const std::string& Element::name() const
{
return _name;
}
using ElementSet = std::list<Element::Ptr>;
template<typename T>
struct ElementTraits
{
};
// BSON Floating point
// spec: double
template<>
struct ElementTraits<double>
{
enum { TypeId = 0x01 };
static std::string toString(const double& value, int indent = 0)
{
return Poco::NumberFormatter::format(value);
}
};
// BSON UTF-8 string
// spec: int32 (byte*) "\x00"
// int32 is the number bytes in byte* + 1 (for trailing "\x00")
template<>
struct ElementTraits<std::string>
{
enum { TypeId = 0x02 };
static std::string toString(const std::string& value, int indent = 0)
{
std::ostringstream oss;
oss << '"';
for (std::string::const_iterator it = value.begin(); it != value.end(); ++it)
{
switch (*it)
{
case '"':
oss << "\\\"";
break;
case '\\':
oss << "\\\\";
break;
case '\b':
oss << "\\b";
break;
case '\f':
oss << "\\f";
break;
case '\n':
oss << "\\n";
break;
case '\r':
oss << "\\r";
break;
case '\t':
oss << "\\t";
break;
default:
{
if ( *it > 0 && *it <= 0x1F )
{
oss << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast<int>(*it);
}
else
{
oss << *it;
}
break;
}
}
}
oss << '"';
return oss.str();
}
};
template<>
inline void BSONReader::read<std::string>(std::string& to)
{
Poco::Int32 size;
_reader >> size;
_reader.readRaw(size, to);
to.erase(to.end() - 1); // remove terminating 0
}
template<>
inline void BSONWriter::write<std::string>(std::string& from)
{
_writer << (Poco::Int32) (from.length() + 1);
writeCString(from);
}
// BSON bool
// spec: "\x00" "\x01"
template<>
struct ElementTraits<bool>
{
enum { TypeId = 0x08 };
static std::string toString(const bool& value, int indent = 0)
{
return value ? "true" : "false";
}
};
template<>
inline void BSONReader::read<bool>(bool& to)
{
unsigned char b;
_reader >> b;
to = b != 0;
}
template<>
inline void BSONWriter::write<bool>(bool& from)
{
unsigned char b = from ? 0x01 : 0x00;
_writer << b;
}
// BSON 32-bit integer
// spec: int32
template<>
struct ElementTraits<Int32>
{
enum { TypeId = 0x10 };
static std::string toString(const Int32& value, int indent = 0)
{
return Poco::NumberFormatter::format(value);
}
};
// BSON UTC datetime
// spec: int64
template<>
struct ElementTraits<Timestamp>
{
enum { TypeId = 0x09 };
static std::string toString(const Timestamp& value, int indent = 0)
{
std::string result;
result.append(1, '"');
result.append(DateTimeFormatter::format(value, "%Y-%m-%dT%H:%M:%s%z"));
result.append(1, '"');
return result;
}
};
template<>
inline void BSONReader::read<Timestamp>(Timestamp& to)
{
Poco::Int64 value;
_reader >> value;
to = Timestamp::fromEpochTime(static_cast<std::time_t>(value / 1000));
to += (value % 1000 * 1000);
}
template<>
inline void BSONWriter::write<Timestamp>(Timestamp& from)
{
_writer << (from.epochMicroseconds() / 1000);
}
using NullValue = Nullable<unsigned char>;
// BSON Null Value
// spec:
template<>
struct ElementTraits<NullValue>
{
enum { TypeId = 0x0A };
static std::string toString(const NullValue& value, int indent = 0)
{
return "null";
}
};
template<>
inline void BSONReader::read<NullValue>(NullValue& to)
{
}
template<>
inline void BSONWriter::write<NullValue>(NullValue& from)
{
}
struct BSONTimestamp
{
Poco::Timestamp ts;
Poco::Int32 inc;
};
// BSON Timestamp
// spec: int64
template<>
struct ElementTraits<BSONTimestamp>
{
enum { TypeId = 0x11 };
static std::string toString(const BSONTimestamp& value, int indent = 0)
{
std::string result;
result.append(1, '"');
result.append(DateTimeFormatter::format(value.ts, "%Y-%m-%dT%H:%M:%s%z"));
result.append(1, ' ');
result.append(NumberFormatter::format(value.inc));
result.append(1, '"');
return result;
}
};
template<>
inline void BSONReader::read<BSONTimestamp>(BSONTimestamp& to)
{
Poco::Int64 value;
_reader >> value;
to.inc = value & 0xffffffff;
value >>= 32;
to.ts = Timestamp::fromEpochTime(static_cast<std::time_t>(value));
}
template<>
inline void BSONWriter::write<BSONTimestamp>(BSONTimestamp& from)
{
Poco::Int64 value = from.ts.epochMicroseconds() / 1000;
value <<= 32;
value += from.inc;
_writer << value;
}
// BSON 64-bit integer
// spec: int64
template<>
struct ElementTraits<Int64>
{
enum { TypeId = 0x12 };
static std::string toString(const Int64& value, int indent = 0)
{
return NumberFormatter::format(value);
}
};
template<typename T>
class ConcreteElement: public Element
{
public:
ConcreteElement(const std::string& name, const T& init):
Element(name),
_value(init)
{
}
virtual ~ConcreteElement()
{
}
T value() const
{
return _value;
}
std::string toString(int indent = 0) const
{
return ElementTraits<T>::toString(_value, indent);
}
int type() const
{
return ElementTraits<T>::TypeId;
}
void read(BinaryReader& reader)
{
BSONReader(reader).read(_value);
}
void write(BinaryWriter& writer)
{
BSONWriter(writer).write(_value);
}
private:
T _value;
};
} } // namespace Poco::MongoDB
#endif // MongoDB_Element_INCLUDED

@ -0,0 +1,89 @@
//
// GetMoreRequest.h
//
// Library: MongoDB
// Package: MongoDB
// Module: GetMoreRequest
//
// Definition of the GetMoreRequest class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_GetMoreRequest_INCLUDED
#define MongoDB_GetMoreRequest_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/RequestMessage.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API GetMoreRequest: public RequestMessage
/// A GetMoreRequest is used to query the database for more documents in a collection
/// after a query request is send (OP_GETMORE).
{
public:
GetMoreRequest(const std::string& collectionName, Int64 cursorID);
/// Creates a GetMoreRequest for the give collection and cursor.
///
/// The full collection name is the concatenation of the database
/// name with the collection name, using a "." for the concatenation. For example,
/// for the database "foo" and the collection "bar", the full collection name is
/// "foo.bar". The cursorID has been returned by the response on the query request.
/// By default the numberToReturn is set to 100.
virtual ~GetMoreRequest();
/// Destroys the GetMoreRequest.
Int32 getNumberToReturn() const;
/// Returns the limit of returned documents.
void setNumberToReturn(Int32 n);
/// Sets the limit of returned documents.
Int64 cursorID() const;
/// Returns the cursor ID.
protected:
void buildRequest(BinaryWriter& writer);
private:
std::string _fullCollectionName;
Int32 _numberToReturn;
Int64 _cursorID;
};
//
// inlines
//
inline Int32 GetMoreRequest::getNumberToReturn() const
{
return _numberToReturn;
}
inline void GetMoreRequest::setNumberToReturn(Int32 n)
{
_numberToReturn = n;
}
inline Int64 GetMoreRequest::cursorID() const
{
return _cursorID;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_GetMoreRequest_INCLUDED

@ -0,0 +1,97 @@
//
// InsertRequest.h
//
// Library: MongoDB
// Package: MongoDB
// Module: InsertRequest
//
// Definition of the InsertRequest class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_InsertRequest_INCLUDED
#define MongoDB_InsertRequest_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/RequestMessage.h"
#include "Poco/MongoDB/Document.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API InsertRequest: public RequestMessage
/// A request for inserting one or more documents to the database
/// (OP_INSERT).
{
public:
enum Flags
{
INSERT_DEFAULT = 0,
/// If specified, perform a normal insert operation.
INSERT_CONTINUE_ON_ERROR = 1
/// If set, the database will not stop processing a bulk insert if one
/// fails (e.g. due to duplicate IDs). This makes bulk insert behave similarly
/// to a series of single inserts, except lastError will be set if any insert
/// fails, not just the last one. If multiple errors occur, only the most
/// recent will be reported.
};
InsertRequest(const std::string& collectionName, Flags flags = INSERT_DEFAULT);
/// Creates an InsertRequest.
///
/// The full collection name is the concatenation of the database
/// name with the collection name, using a "." for the concatenation. For example,
/// for the database "foo" and the collection "bar", the full collection name is
/// "foo.bar".
virtual ~InsertRequest();
/// Destroys the InsertRequest.
Document& addNewDocument();
/// Adds a new document for insertion. A reference to the empty document is
/// returned. InsertRequest is the owner of the Document and will free it
/// on destruction.
Document::Vector& documents();
/// Returns the documents to insert into the database.
protected:
void buildRequest(BinaryWriter& writer);
private:
Int32 _flags;
std::string _fullCollectionName;
Document::Vector _documents;
};
//
// inlines
//
inline Document& InsertRequest::addNewDocument()
{
Document::Ptr doc = new Document();
_documents.push_back(doc);
return *doc;
}
inline Document::Vector& InsertRequest::documents()
{
return _documents;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_InsertRequest_INCLUDED

@ -0,0 +1,105 @@
//
// JavaScriptCode.h
//
// Library: MongoDB
// Package: MongoDB
// Module: JavaScriptCode
//
// Definition of the JavaScriptCode class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_JavaScriptCode_INCLUDED
#define MongoDB_JavaScriptCode_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/BSONReader.h"
#include "Poco/MongoDB/BSONWriter.h"
#include "Poco/MongoDB/Element.h"
#include "Poco/SharedPtr.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API JavaScriptCode
/// Represents JavaScript type in BSON.
{
public:
using Ptr = SharedPtr<JavaScriptCode>;
JavaScriptCode();
/// Creates an empty JavaScriptCode object.
virtual ~JavaScriptCode();
/// Destroys the JavaScriptCode.
void setCode(const std::string& code);
/// Sets the JavaScript code.
std::string getCode() const;
/// Returns the JavaScript code.
private:
std::string _code;
};
//
// inlines
//
inline void JavaScriptCode::setCode(const std::string& code)
{
_code = code;
}
inline std::string JavaScriptCode::getCode() const
{
return _code;
}
// BSON JavaScript code
// spec: string
template<>
struct ElementTraits<JavaScriptCode::Ptr>
{
enum { TypeId = 0x0D };
static std::string toString(const JavaScriptCode::Ptr& value, int indent = 0)
{
return value.isNull() ? "" : value->getCode();
}
};
template<>
inline void BSONReader::read<JavaScriptCode::Ptr>(JavaScriptCode::Ptr& to)
{
std::string code;
BSONReader(_reader).read(code);
to = new JavaScriptCode();
to->setCode(code);
}
template<>
inline void BSONWriter::write<JavaScriptCode::Ptr>(JavaScriptCode::Ptr& from)
{
std::string code = from->getCode();
BSONWriter(_writer).write(code);
}
} } // namespace Poco::MongoDB
#endif // MongoDB_JavaScriptCode_INCLUDED

@ -0,0 +1,62 @@
//
// KillCursorsRequest.h
//
// Library: MongoDB
// Package: MongoDB
// Module: KillCursorsRequest
//
// Definition of the KillCursorsRequest class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_KillCursorsRequest_INCLUDED
#define MongoDB_KillCursorsRequest_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/RequestMessage.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API KillCursorsRequest: public RequestMessage
/// Class for creating an OP_KILL_CURSORS client request. This
/// request is used to kill cursors, which are still open,
/// returned by query requests.
{
public:
KillCursorsRequest();
/// Creates a KillCursorsRequest.
virtual ~KillCursorsRequest();
/// Destroys the KillCursorsRequest.
std::vector<Int64>& cursors();
/// The internal list of cursors.
protected:
void buildRequest(BinaryWriter& writer);
std::vector<Int64> _cursors;
};
//
// inlines
//
inline std::vector<Int64>& KillCursorsRequest::cursors()
{
return _cursors;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_KillCursorsRequest_INCLUDED

@ -0,0 +1,73 @@
//
// Message.h
//
// Library: MongoDB
// Package: MongoDB
// Module: Message
//
// Definition of the Message class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_Message_INCLUDED
#define MongoDB_Message_INCLUDED
#include "Poco/Net/Socket.h"
#include "Poco/BinaryReader.h"
#include "Poco/BinaryWriter.h"
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/MessageHeader.h"
#include <sstream>
namespace Poco {
namespace MongoDB {
class MongoDB_API Message
/// Base class for all messages send or retrieved from MongoDB server.
{
public:
explicit Message(MessageHeader::OpCode opcode);
/// Creates a Message using the given OpCode.
virtual ~Message();
/// Destructor
MessageHeader& header();
/// Returns the message header
protected:
MessageHeader _header;
void messageLength(Poco::Int32 length);
/// Sets the message length in the message header
};
//
// inlines
//
inline MessageHeader& Message::header()
{
return _header;
}
inline void Message::messageLength(Poco::Int32 length)
{
poco_assert(length > 0);
_header.setMessageLength(length);
}
} } // namespace Poco::MongoDB
#endif // MongoDB_Message_INCLUDED

@ -0,0 +1,130 @@
//
// MessageHeader.h
//
// Library: MongoDB
// Package: MongoDB
// Module: MessageHeader
//
// Definition of the MessageHeader class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_MessageHeader_INCLUDED
#define MongoDB_MessageHeader_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/MessageHeader.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API MessageHeader
/// Represents the message header which is always prepended to a
/// MongoDB request or response message.
{
public:
static const unsigned int MSG_HEADER_SIZE = 16;
enum OpCode
{
OP_REPLY = 1,
OP_MSG = 1000,
OP_UPDATE = 2001,
OP_INSERT = 2002,
OP_QUERY = 2004,
OP_GET_MORE = 2005,
OP_DELETE = 2006,
OP_KILL_CURSORS = 2007
};
explicit MessageHeader(OpCode);
/// Creates the MessageHeader using the given OpCode.
virtual ~MessageHeader();
/// Destroys the MessageHeader.
void read(BinaryReader& reader);
/// Reads the header using the given BinaryReader.
void write(BinaryWriter& writer);
/// Writes the header using the given BinaryWriter.
Int32 getMessageLength() const;
/// Returns the message length.
OpCode opCode() const;
/// Returns the OpCode.
Int32 getRequestID() const;
/// Returns the request ID of the current message.
void setRequestID(Int32 id);
/// Sets the request ID of the current message.
Int32 responseTo() const;
/// Returns the request id from the original request.
private:
void setMessageLength(Int32 length);
/// Sets the message length.
Int32 _messageLength;
Int32 _requestID;
Int32 _responseTo;
OpCode _opCode;
friend class Message;
};
//
// inlines
//
inline MessageHeader::OpCode MessageHeader::opCode() const
{
return _opCode;
}
inline Int32 MessageHeader::getMessageLength() const
{
return _messageLength;
}
inline void MessageHeader::setMessageLength(Int32 length)
{
poco_assert (_messageLength >= 0);
_messageLength = MSG_HEADER_SIZE + length;
}
inline void MessageHeader::setRequestID(Int32 id)
{
_requestID = id;
}
inline Int32 MessageHeader::getRequestID() const
{
return _requestID;
}
inline Int32 MessageHeader::responseTo() const
{
return _responseTo;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_MessageHeader_INCLUDED

@ -0,0 +1,64 @@
//
// MongoDB.h
//
// Library: MongoDB
// Package: MongoDB
// Module: MongoDB
//
// Basic definitions for the Poco MongoDB library.
// This file must be the first file included by every other MongoDB
// header file.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDBMongoDB_INCLUDED
#define MongoDBMongoDB_INCLUDED
#include "Poco/Foundation.h"
//
// The following block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the MongoDB_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// MongoDB_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
//
#if defined(_WIN32) && defined(POCO_DLL)
#if defined(MongoDB_EXPORTS)
#define MongoDB_API __declspec(dllexport)
#else
#define MongoDB_API __declspec(dllimport)
#endif
#endif
#if !defined(MongoDB_API)
#if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4)
#define MongoDB_API __attribute__ ((visibility ("default")))
#else
#define MongoDB_API
#endif
#endif
//
// Automatically link MongoDB library.
//
#if defined(_MSC_VER)
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(MongoDB_EXPORTS)
#pragma comment(lib, "PocoMongoDB" POCO_LIB_SUFFIX)
#endif
#endif
#endif // MongoDBMongoDB_INCLUDED

@ -0,0 +1,147 @@
//
// Array.h
//
// Library: MongoDB
// Package: MongoDB
// Module: ObjectId
//
// Definition of the ObjectId class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_ObjectId_INCLUDED
#define MongoDB_ObjectId_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Element.h"
#include "Poco/Timestamp.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API ObjectId
/// ObjectId is a 12-byte BSON type, constructed using:
///
/// - a 4-byte timestamp,
/// - a 3-byte machine identifier,
/// - a 2-byte process id, and
/// - a 3-byte counter, starting with a random value.
///
/// In MongoDB, documents stored in a collection require a unique _id field that acts
/// as a primary key. Because ObjectIds are small, most likely unique, and fast to generate,
/// MongoDB uses ObjectIds as the default value for the _id field if the _id field is not
/// specified; i.e., the mongod adds the _id field and generates a unique ObjectId to assign
/// as its value.
{
public:
using Ptr = SharedPtr<ObjectId>;
explicit ObjectId(const std::string& id);
/// Creates an ObjectId from a string.
///
/// The string must contain a hexadecimal representation
/// of an object ID. This means a string of 24 characters.
ObjectId(const ObjectId& copy);
/// Creates an ObjectId by copying another one.
virtual ~ObjectId();
/// Destroys the ObjectId.
Timestamp timestamp() const;
/// Returns the timestamp which is stored in the first four bytes of the id
std::string toString(const std::string& fmt = "%02x") const;
/// Returns the id in string format. The fmt parameter
/// specifies the formatting used for individual members
/// of the ID char array.
private:
ObjectId();
static int fromHex(char c);
static char fromHex(const char* c);
unsigned char _id[12];
friend class BSONWriter;
friend class BSONReader;
friend class Document;
};
//
// inlines
//
inline Timestamp ObjectId::timestamp() const
{
int time;
char* T = (char *) &time;
T[0] = _id[3];
T[1] = _id[2];
T[2] = _id[1];
T[3] = _id[0];
return Timestamp::fromEpochTime((time_t) time);
}
inline int ObjectId::fromHex(char c)
{
if ( '0' <= c && c <= '9' )
return c - '0';
if ( 'a' <= c && c <= 'f' )
return c - 'a' + 10;
if ( 'A' <= c && c <= 'F' )
return c - 'A' + 10;
return 0xff;
}
inline char ObjectId::fromHex(const char* c)
{
return (char)((fromHex(c[0]) << 4 ) | fromHex(c[1]));
}
// BSON Embedded Document
// spec: ObjectId
template<>
struct ElementTraits<ObjectId::Ptr>
{
enum { TypeId = 0x07 };
static std::string toString(const ObjectId::Ptr& id,
int indent = 0,
const std::string& fmt = "%02x")
{
return id->toString(fmt);
}
};
template<>
inline void BSONReader::read<ObjectId::Ptr>(ObjectId::Ptr& to)
{
_reader.readRaw((char*) to->_id, 12);
}
template<>
inline void BSONWriter::write<ObjectId::Ptr>(ObjectId::Ptr& from)
{
_writer.writeRaw((char*) from->_id, 12);
}
} } // namespace Poco::MongoDB
#endif // MongoDB_ObjectId_INCLUDED

@ -0,0 +1,128 @@
//
// PoolableConnectionFactory.h
//
// Library: MongoDB
// Package: MongoDB
// Module: PoolableConnectionFactory
//
// Definition of the PoolableConnectionFactory class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_PoolableConnectionFactory_INCLUDED
#define MongoDB_PoolableConnectionFactory_INCLUDED
#include "Poco/MongoDB/Connection.h"
#include "Poco/ObjectPool.h"
namespace Poco {
template<>
class PoolableObjectFactory<MongoDB::Connection, MongoDB::Connection::Ptr>
/// PoolableObjectFactory specialisation for Connection. New connections
/// are created with the given address or URI.
///
/// If a Connection::SocketFactory is given, it must live for the entire
/// lifetime of the PoolableObjectFactory.
{
public:
PoolableObjectFactory(Net::SocketAddress& address):
_address(address),
_pSocketFactory(0)
{
}
PoolableObjectFactory(const std::string& address):
_address(address),
_pSocketFactory(0)
{
}
PoolableObjectFactory(const std::string& uri, MongoDB::Connection::SocketFactory& socketFactory):
_uri(uri),
_pSocketFactory(&socketFactory)
{
}
MongoDB::Connection::Ptr createObject()
{
if (_pSocketFactory)
return new MongoDB::Connection(_uri, *_pSocketFactory);
else
return new MongoDB::Connection(_address);
}
bool validateObject(MongoDB::Connection::Ptr pObject)
{
return true;
}
void activateObject(MongoDB::Connection::Ptr pObject)
{
}
void deactivateObject(MongoDB::Connection::Ptr pObject)
{
}
void destroyObject(MongoDB::Connection::Ptr pObject)
{
}
private:
Net::SocketAddress _address;
std::string _uri;
MongoDB::Connection::SocketFactory* _pSocketFactory;
};
namespace MongoDB {
class PooledConnection
/// Helper class for borrowing and returning a connection automatically from a pool.
{
public:
PooledConnection(Poco::ObjectPool<Connection, Connection::Ptr>& pool) : _pool(pool)
{
_connection = _pool.borrowObject();
}
virtual ~PooledConnection()
{
try
{
if (_connection)
{
_pool.returnObject(_connection);
}
}
catch (...)
{
poco_unexpected();
}
}
operator Connection::Ptr ()
{
return _connection;
}
private:
Poco::ObjectPool<Connection, Connection::Ptr>& _pool;
Connection::Ptr _connection;
};
} } // namespace Poco::MongoDB
#endif // MongoDB_PoolableConnectionFactory_INCLUDED

@ -0,0 +1,187 @@
//
// QueryRequest.h
//
// Library: MongoDB
// Package: MongoDB
// Module: QueryRequest
//
// Definition of the QueryRequest class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_QueryRequest_INCLUDED
#define MongoDB_QueryRequest_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/RequestMessage.h"
#include "Poco/MongoDB/Document.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API QueryRequest: public RequestMessage
/// A request to query documents in a MongoDB database
/// using an OP_QUERY request.
{
public:
enum Flags
{
QUERY_DEFAULT = 0,
/// Do not set any flags.
QUERY_TAILABLE_CURSOR = 2,
/// Tailable means cursor is not closed when the last data is retrieved.
/// Rather, the cursor marks the final objects position.
/// You can resume using the cursor later, from where it was located,
/// if more data were received. Like any "latent cursor", the cursor may
/// become invalid at some point (CursorNotFound) for example if the final
/// object it references were deleted.
QUERY_SLAVE_OK = 4,
/// Allow query of replica slave. Normally these return an error except
/// for namespace "local".
// QUERY_OPLOG_REPLAY = 8 (internal replication use only - drivers should not implement)
QUERY_NO_CURSOR_TIMEOUT = 16,
/// The server normally times out idle cursors after an inactivity period
/// (10 minutes) to prevent excess memory use. Set this option to prevent that.
QUERY_AWAIT_DATA = 32,
/// Use with QUERY_TAILABLECURSOR. If we are at the end of the data, block for
/// a while rather than returning no data. After a timeout period, we do
/// return as normal.
QUERY_EXHAUST = 64,
/// Stream the data down full blast in multiple "more" packages, on the
/// assumption that the client will fully read all data queried.
/// Faster when you are pulling a lot of data and know you want to pull
/// it all down.
/// Note: the client is not allowed to not read all the data unless it
/// closes the connection.
QUERY_PARTIAL = 128
/// Get partial results from a mongos if some shards are down
/// (instead of throwing an error).
};
QueryRequest(const std::string& collectionName, Flags flags = QUERY_DEFAULT);
/// Creates a QueryRequest.
///
/// The full collection name is the concatenation of the database
/// name with the collection name, using a "." for the concatenation. For example,
/// for the database "foo" and the collection "bar", the full collection name is
/// "foo.bar".
virtual ~QueryRequest();
/// Destroys the QueryRequest.
Flags getFlags() const;
/// Returns the flags.
void setFlags(Flags flag);
/// Set the flags.
std::string fullCollectionName() const;
/// Returns the <db>.<collection> used for this query.
Int32 getNumberToSkip() const;
/// Returns the number of documents to skip.
void setNumberToSkip(Int32 n);
/// Sets the number of documents to skip.
Int32 getNumberToReturn() const;
/// Returns the number of documents to return.
void setNumberToReturn(Int32 n);
/// Sets the number of documents to return (limit).
Document& selector();
/// Returns the selector document.
Document& returnFieldSelector();
/// Returns the field selector document.
protected:
void buildRequest(BinaryWriter& writer);
private:
Flags _flags;
std::string _fullCollectionName;
Int32 _numberToSkip;
Int32 _numberToReturn;
Document _selector;
Document _returnFieldSelector;
};
//
// inlines
//
inline QueryRequest::Flags QueryRequest::getFlags() const
{
return _flags;
}
inline void QueryRequest::setFlags(QueryRequest::Flags flags)
{
_flags = flags;
}
inline std::string QueryRequest::fullCollectionName() const
{
return _fullCollectionName;
}
inline Document& QueryRequest::selector()
{
return _selector;
}
inline Document& QueryRequest::returnFieldSelector()
{
return _returnFieldSelector;
}
inline Int32 QueryRequest::getNumberToSkip() const
{
return _numberToSkip;
}
inline void QueryRequest::setNumberToSkip(Int32 n)
{
_numberToSkip = n;
}
inline Int32 QueryRequest::getNumberToReturn() const
{
return _numberToReturn;
}
inline void QueryRequest::setNumberToReturn(Int32 n)
{
_numberToReturn = n;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_QueryRequest_INCLUDED

@ -0,0 +1,129 @@
//
// RegularExpression.h
//
// Library: MongoDB
// Package: MongoDB
// Module: RegularExpression
//
// Definition of the RegularExpression class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_RegularExpression_INCLUDED
#define MongoDB_RegularExpression_INCLUDED
#include "Poco/RegularExpression.h"
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Element.h"
namespace Poco {
namespace MongoDB {
class MongoDB_API RegularExpression
/// Represents a regular expression in BSON format.
{
public:
using Ptr = SharedPtr<RegularExpression>;
RegularExpression();
/// Creates an empty RegularExpression.
RegularExpression(const std::string& pattern, const std::string& options);
/// Creates a RegularExpression using the given pattern and options.
virtual ~RegularExpression();
/// Destroys the RegularExpression.
SharedPtr<Poco::RegularExpression> createRE() const;
/// Tries to create a Poco::RegularExpression from the MongoDB regular expression.
std::string getOptions() const;
/// Returns the options string.
void setOptions(const std::string& options);
/// Sets the options string.
std::string getPattern() const;
/// Returns the pattern.
void setPattern(const std::string& pattern);
/// Sets the pattern.
private:
std::string _pattern;
std::string _options;
};
///
/// inlines
///
inline std::string RegularExpression::getPattern() const
{
return _pattern;
}
inline void RegularExpression::setPattern(const std::string& pattern)
{
_pattern = pattern;
}
inline std::string RegularExpression::getOptions() const
{
return _options;
}
inline void RegularExpression::setOptions(const std::string& options)
{
_options = options;
}
// BSON Regex
// spec: cstring cstring
template<>
struct ElementTraits<RegularExpression::Ptr>
{
enum { TypeId = 0x0B };
static std::string toString(const RegularExpression::Ptr& value, int indent = 0)
{
//TODO
return "RE: not implemented yet";
}
};
template<>
inline void BSONReader::read<RegularExpression::Ptr>(RegularExpression::Ptr& to)
{
std::string pattern = readCString();
std::string options = readCString();
to = new RegularExpression(pattern, options);
}
template<>
inline void BSONWriter::write<RegularExpression::Ptr>(RegularExpression::Ptr& from)
{
writeCString(from->getPattern());
writeCString(from->getOptions());
}
} } // namespace Poco::MongoDB
#endif // MongoDB_RegularExpression_INCLUDED

@ -0,0 +1,58 @@
//
// ReplicaSet.h
//
// Library: MongoDB
// Package: MongoDB
// Module: ReplicaSet
//
// Definition of the ReplicaSet class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_ReplicaSet_INCLUDED
#define MongoDB_ReplicaSet_INCLUDED
#include "Poco/Net/SocketAddress.h"
#include "Poco/MongoDB/Connection.h"
#include <vector>
namespace Poco {
namespace MongoDB {
class MongoDB_API ReplicaSet
/// Class for working with a MongoDB replica set.
{
public:
explicit ReplicaSet(const std::vector<Net::SocketAddress>& addresses);
/// Creates the ReplicaSet using the given server addresses.
virtual ~ReplicaSet();
/// Destroys the ReplicaSet.
Connection::Ptr findMaster();
/// Tries to find the master MongoDB instance from the addresses
/// passed to the constructor.
///
/// Returns the Connection to the master, or null if no master
/// instance was found.
protected:
Connection::Ptr isMaster(const Net::SocketAddress& host);
private:
std::vector<Net::SocketAddress> _addresses;
};
} } // namespace Poco::MongoDB
#endif // MongoDB_ReplicaSet_INCLUDED

@ -0,0 +1,51 @@
//
// RequestMessage.h
//
// Library: MongoDB
// Package: MongoDB
// Module: RequestMessage
//
// Definition of the RequestMessage class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_RequestMessage_INCLUDED
#define MongoDB_RequestMessage_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Message.h"
#include <ostream>
namespace Poco {
namespace MongoDB {
class MongoDB_API RequestMessage: public Message
/// Base class for a request sent to the MongoDB server.
{
public:
explicit RequestMessage(MessageHeader::OpCode opcode);
/// Creates a RequestMessage using the given opcode.
virtual ~RequestMessage();
/// Destroys the RequestMessage.
void send(std::ostream& ostr);
/// Writes the request to stream.
protected:
virtual void buildRequest(BinaryWriter& ss) = 0;
};
} } // namespace Poco::MongoDB
#endif // MongoDB_RequestMessage_INCLUDED

@ -0,0 +1,108 @@
//
// ResponseMessage.h
//
// Library: MongoDB
// Package: MongoDB
// Module: ResponseMessage
//
// Definition of the ResponseMessage class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_ResponseMessage_INCLUDED
#define MongoDB_ResponseMessage_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Message.h"
#include "Poco/MongoDB/Document.h"
#include <istream>
#include <cstdlib>
namespace Poco {
namespace MongoDB {
class MongoDB_API ResponseMessage: public Message
/// This class represents a response (OP_REPLY) from MongoDB.
{
public:
ResponseMessage();
/// Creates an empty ResponseMessage.
virtual ~ResponseMessage();
/// Destroys the ResponseMessage.
Int64 cursorID() const;
/// Returns the cursor ID.
void clear();
/// Clears the response.
std::size_t count() const;
/// Returns the number of documents in the response.
Document::Vector& documents();
/// Returns a vector containing the received documents.
bool empty() const;
/// Returns true if the response does not contain any documents.
bool hasDocuments() const;
/// Returns true if there is at least one document in the response.
void read(std::istream& istr);
/// Reads the response from the stream.
private:
Int32 _responseFlags;
Int64 _cursorID;
Int32 _startingFrom;
Int32 _numberReturned;
Document::Vector _documents;
};
//
// inlines
//
inline std::size_t ResponseMessage::count() const
{
return _documents.size();
}
inline bool ResponseMessage::empty() const
{
return _documents.size() == 0;
}
inline Int64 ResponseMessage::cursorID() const
{
return _cursorID;
}
inline Document::Vector& ResponseMessage::documents()
{
return _documents;
}
inline bool ResponseMessage::hasDocuments() const
{
return _documents.size() > 0;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_ResponseMessage_INCLUDED

@ -0,0 +1,114 @@
//
// UpdateRequest.h
//
// Library: MongoDB
// Package: MongoDB
// Module: UpdateRequest
//
// Definition of the UpdateRequest class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef MongoDB_UpdateRequest_INCLUDED
#define MongoDB_UpdateRequest_INCLUDED
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/RequestMessage.h"
#include "Poco/MongoDB/Document.h"
namespace Poco {
namespace MongoDB {
class UpdateRequest: public RequestMessage
/// This request is used to update a document in a database
/// using the OP_UPDATE client request.
{
public:
enum Flags
{
UPDATE_DEFAULT = 0,
/// If set, the database will insert the supplied object into the
/// collection if no matching document is found.
UPDATE_UPSERT = 1,
/// If set, the database will update all matching objects in the collection.
/// Otherwise only updates first matching doc.
UPDATE_MULTIUPDATE = 2
/// If set to, updates multiple documents that meet the query criteria.
/// Otherwise only updates one document.
};
UpdateRequest(const std::string& collectionName, Flags flags = UPDATE_DEFAULT);
/// Creates the UpdateRequest.
///
/// The full collection name is the concatenation of the database
/// name with the collection name, using a "." for the concatenation. For example,
/// for the database "foo" and the collection "bar", the full collection name is
/// "foo.bar".
virtual ~UpdateRequest();
/// Destroys the UpdateRequest.
Document& selector();
/// Returns the selector document.
Document& update();
/// Returns the document to update.
Flags flags() const;
/// Returns the flags
void flags(Flags flags);
/// Sets the flags
protected:
void buildRequest(BinaryWriter& writer);
private:
Flags _flags;
std::string _fullCollectionName;
Document _selector;
Document _update;
};
//
// inlines
//
inline UpdateRequest::Flags UpdateRequest::flags() const
{
return _flags;
}
inline void UpdateRequest::flags(UpdateRequest::Flags flags)
{
_flags = flags;
}
inline Document& UpdateRequest::selector()
{
return _selector;
}
inline Document& UpdateRequest::update()
{
return _update;
}
} } // namespace Poco::MongoDB
#endif // MongoDB_UpdateRequest_INCLUDED