The core of Poco library--foundation components

Source: Internet
Author: User
Tags crc32


Key Core:
Version.h: Version control information, macro poco_version, value format with 0xAABBCCDD, respectively, representing the main version, minor version, patch version, pre-release version;


Poco.h: simply contains the header file Foundation.h;


Foundation.h: The header files that need to be included before using any other Foundation module, mainly define the library export macro Poco_dll, Foundation_api, and automatically connect the appropriate configured library reference file Lib; including the library configuration file Config.h;

Platform-related Platform.h and the corresponding files of each platform platform_win32.h, Platform_vms.h, platform_vx.h, platform_posix.h;bug detection Bugcheck.h, Data type each platform re-declaration unified definition Types.h;

The above documents are necessary and the order is also important;


Config.h: Mainly used to configure the various modules under the foundation components related to the characteristics of the macro, such as Byte encoding, C++11 support, explicit automatic connection Reference library, shared memory, such as whether to open or cancel, macro on the corresponding module characteristics have a certain impact;


Platform.h: Define the Platform ID, version control, hardware architecture and byte order, compiler, newline encoding and other macros under different platforms;


Platform_win32.h, Platform_vms.h, Platform_vx.h, platform_posix.h: mainly specify platform-related definitions, macros, and compilation environments under different platforms;


Bugcheck.h: Class bugcheck defines a variety of static anomaly detection functions (by throwing the corresponding exception) and debugger jump function (breakpoint terminates abnormally, output to debug Log window), and generally uses the individual macros defined later, followed by a poco_static_ static assertion of assert;


Debugger.h: Debugger Class Debugger, only provides debugger interface and in debug mode when entering debug mode and output debugging information to debug Log Output window;

IsAvailable: Whether the debugger is available, under Windows using Isdebuggerpresent judgment, WCE under Checkremotedebuggerpresent,unix by setting environment variables Poco_enable_ Debugger,openvms is always valid, other systems are not available, and multiple overloaded versions of message provide output debugging information to the error output stream, debug log Output window, and multiple overloaded versions of Enter to provide breakpoints to enter debug mode;


Exception.h: Exception-related classes, Poco basic common exception base class Exception, and provide an additional operating interface, which inherits from the standard exception class Std::exception, also provides the exception declaration macro Poco_declare_exception, And in this implementation of a number of different exception classes inherited from the common exception base class exception, such as logical Exception class Logicexception, run Exception class RuntimeException, file Exception class Fileexception, etc.


Error.h: Error class, the error code and corresponding error message format encapsulation, under Windows with GetLastError get error code, getmessage through FormatMessage get error code information, Get error code by errno variable under other platform, GetMessage get error code information through Strerror_r or strerror;


MetaProgramming.h: The common definition used by metaprogramming, whether IsReference is a reference, whether Isconst is a constant, is judged by the template parameter and the corresponding enumeration value of value;

Typewrapper is a type wrapper, which is used to package and extract the element type, constant type, reference type, and commonly quoted type.


Ascii.h:ascii Code correlation attribute query, static function of conversion operation, etc. wherein, 128 ASCII code attributes include: Control code type, white space character type, punctuation type, number type, hexadecimal type, letter type, lowercase type, uppercase type, display graphic type, printable type, etc., as well as provide the appropriate query to determine the interface, in addition to provide ToLower, toupper-case conversion interface;

Properties gets the corresponding ASCII code attribute, hassomeproperties whether the query contains a property, hasproperties whether the query has only that property;


Atomiccounter.h:atomiccounter atomic Count class, different platform to provide different implementations, the Windows platform using the atomic operation function InterlockedExchange, InterlockedIncrement, The InterlockedDecrement realizes the operation of atomic accumulation, decrement and assignment.

Mac_os uses OSAtomicIncrement32, OSAtomicDecrement32 to achieve atomic operations, in addition to the GCC compiler supported by __sync_add_and_fetch, __sync_fetch_and_add, __sync_sub_and_fetch, __sync_fetch_and_sub implementation of atomic operation, for other platforms under the use of Fastmutex protection lock implementation count;


AUTOPTR.H:AUTOPTR Automatic Smart pointer class, provides the implementation form of the template, in addition to the template parameter type must implement the duplicate and release interface (in fact we can understand to increase the reference count and reduce the reference count) As for when release reduces the reference count to 0 o'clock, the template parameter class itself is responsible for releasing itself; provides a variety of convenient operation interfaces, secure and insecure dynamic type conversion interfaces, multiple conditional operator overloads, pointer Exchange, and so on;


Autoreleasepool.h:autoreleasepool garbage collection pool, same as autoptr, provides template parameter implementation form, and template parameters need to implement duplicate and release interface The Autoreleasepool internally maintains a collection of object pointers for template parameter types through a linked list, freeing the maintained list object (that is, the release interface of each object in the linked list) when the garbage collection pool releases or calls release; Note: When the add interface is called, the Objects that need to be maintained call duplicate (increase reference count) to ensure that the objects maintained by the garbage collection pool are valid and not released early in the morning; in fact, template parameters can generally inherit from Refcountedobject. And then the appropriate place in the sub-class call the two interface implementation can be;


Buffer.h:buffer a buffer container of a given type and size and can be adjusted, using the template parameter implementation form, _capacity container capacity size, _used has used the container size, _ptr is the buffer pointer, _ Ownmem is the buffer to have this memory, even if owns the release when the buffer is responsible for release, or externally responsible, and also provides a variety of operation of the container interface, overloading []/conditional operators, etc.;


Byteorder.h:byteorder byte order class, provides a number of different data types of flip, machine big and small end of the transformation, network sequence, host sequence conversion of the static interface implementation; For compilers that support byte-order flipping, the _byteswap_ushort, _ Byteswap_ulong, _byteswap_uint64 implementation of Flip, or manual bit-code operation to achieve the rollover; for the signed flip using the conversion to unsigned to flip;


Checksum.h:checksum Checksum, currently provides the ADLER32, CRC32 two kinds of check mode, the default is the CRC32 type, update provides updates specify the data checksum, Checksum get checksum, type gets the current checksum types, interface with the interface of Adler32 class in Java.util.zip, the two kinds of check calculation in checksum class are implemented by Zlib library directly;


environment.h:environment Environment variables, etc., get gets the specified environment variable value, set setting environment variable and corresponding value, osname get OS os name, Osdisplayname gets the operating system's friendly display name, OSVersion gets the operating system version, Osarchitecture gets the operating system processor architecture, NodeName gets the operating system node or host name, ProcessorCount gets the number of operating system processors, Libraryversion gets the Poco library version, and for cross-platform support, the ENVIRONMENT_XXX series implements the above interfaces on different platforms. , for example: Under the Windows platform with setenvironmentvariable, getenvironmentvariable implementation settings and get environment variables, GetVersionEx get the operating system name, version, GetSystemInfo gets the operating system processor architecture, number of processors, GetComputerName gets host or node name,
GetAdaptersInfo traversal gets the network card address of the first NIC adapter;


The Fifobuffer.h:basicfifobuffer is a FIFO buffer, supports reentrant, provides a readable, writable event advertisement, and the underlying buffer container _buffer,writable, readable as a read-write event, _ Begin buffer FIFO start position, _used buffer length, whether the observer is advertised when _notify satisfies the condition, _mutex lock mechanism protects buffer data, _eof is up to file or data end, _ERROR error flag is used to allow or block readable writable operations, The constructor parameter buffersize to specify the buffer size, in addition to the buffer size can also be adjusted through resize, peek snooping buffer data, read read buffer data, write write buffer data and adjust the contents of the move buffer data, Overwrites the data that was previously read by overwriting the data that was not read later, populating the data in order with the size of the buffer, used gets the buffer size that has been used, available whether the buffer has free space available, and drain discarding the specified length of data content Copy the data to the end of the buffer; advance grows buffer data length, notify advertises the Observer object, data from scratch, from there to no advertisement readable readable observer object, never full full, from full to full state can be written when the Observer object is advertised In addition, there are some other criteria for the interface, overloaded extraction operators, etc.;


FPEnvironment.h: Floating-point environment fpenvironment class, mainly used to set floating point computation control word, overrun, overflow, exception, infinity, rounding error precision control; Roundingmode: Rounding mode, currently available with down, up, near, Nearly 0 of these modes, in addition flag provides a number of exception 0, precision accident, overflow, underflow, abnormal illegal instructions and other abnormal signs; Fpenvironment_xxx series realizes floating-point environment control implementation under different platforms; take the Windows platform for example: _ CONTROLFP set floating-point control word, _STATUSFP get floating-point control word, _finite, _isnan respectively for judging infinity, invalid floating-point number, copysign symbol copy, the target data to return the source data, the other platform under the STD standard library is implemented;


Instantiator.h: An instantiation that provides a simple interface for creating instantiated objects, using a template approach, abstractinstantiator to instantiate an abstract base class, Instantiator to its subclasses, Implementation of the interface to create an instance CreateInstance, the class is mainly used in Dynamicfactory, loggingfactory class implementation;


JSONString.h: Provides two global interface implementations, the conversion string is in JSON format, output to the output stream, string, in fact, the internal call Utf8::escape implementation of string Escape string formatting only;


MemoryPool.h: Simple fixed-size memory pool memorypool,_blocksize: Memory blocks per block size, _maxalloc: Maximum number of memory blocks allowed, _allocated: Number of memory blocks allocated available, _ Blocks: memory block Pointer group, maintain each memory block address, _mutex: Lock mechanism to protect memory pool access operation, constructor parameter blocksize for memory block per block fixed size, prealloc to pre-allocate available memory block, Maxalloc as the largest allocated memory block , the overall process is: pre-allocating a certain amount (at least block_reserve (128) block) of memory block, get a block of memory from the memory pool, release put back unused memory block to the memory pool management; blocksize Get block size ; allocated gets the number of allocated memory blocks, available gets the number of memory blocks available, so MemoryPool simply maintains and allocates a certain amount of fixed memory blocks, the allocated memory blocks can be externally maintained or returned to the memory pool to maintain the life cycle;


Nesteddiagnosticcontext.h:nesteddiagnosticcontext Embedded Diagnostic Context class, Context: Contextual information, including additional information info, the name of the file, the line number; _stack context container, Using vectors as a simulation stack; push: pushes new diagnostic information to the last diagnostic information in the container, pop pop-up container; Depth: Gets the context container stack depth; ToString: Gets all the diagnostic strings in the container (semicolon: isolate each information); Dump: Extraction of complete diagnostic information; clear: Clears the diagnostic information container; Current: Gets the diagnostic object under the present thread, NDC, which is convenient for use in multi-threaded environments where the corresponding diagnostic object, NDC, is freed when the thread exits; the Ndcscope class is also available. To support the packaging of diagnostic information Nesteddiagnosticcontext and manage the life cycle of current diagnostic information; POCO_NDC, poco_ndc_dbg macros can also be easily packaged;


The Nullable.h:nullable nullable type object class, implemented as a template, can represent a null object or a non-null object; _value: null type Object persisted value, _isnull: null object, _null: null type (the value is always 0 ); This class produces a nullable object by constructor, assignment, copy, or assign operation, and also provides swap, as well as overloading various comparison operations, output stream operators; value: Gets the persisted value, if NULL, throws an exception, so the general value can be judged first isnull, Based on the result to decide whether to value, clear: Reset the empty object, so that it is a null object;


Objectpool.h:poolableobjectfactory can be placed in the object factory class of the pool, implemented in a template way, internally provides CreateObject, Destroyobject creation and destruction of object interfaces and other objects are available validateobject and other interfaces, in addition to the AUTOPTR, Sharedptr-based special version, the special version is not responsible for destroying objects; Objectpool: Object Pool Class , _factory: The Factory object of the object pool; _capacity: Object pool capacity; _peakcapacity: The object pool can produce an object's upper capacity value; _size: The number of objects the object pool has produced; _pool: Object Pool Object Container (vector as the base container); _mutex: The lock mechanism to protect the object pool; _availablecondition: A conditional object that can manipulate the object pool when the condition or signal is met; the parameter objectcapacity in the constructor is the container object capacity ; Peakobjectcapacity is the capacity of the object to be generated; Factory is the factory object that produces the object; Borrowobject: Extracts the object (which may be obtained from the object pool container or directly from the factory object of the object pool, depending on the internal distribution) ; Returnobject: Returns an object that is directly added to the container object for a container that is not full, and if the container object is exceeded, the object is freed directly from the factory object, the _size count is reduced and the condition object is the trigger signal state, and the Borrowobject function has a while loop , the condition is _size >= _peakcapacity, which returns null if the condition object does not become signaled in the specified time, or continues polling until it can get to the object or the timeout returns null;


Optional.h: Optional object type class, similar to Nullable nullable type object class;


The Refcountedobject.h:refcountedobject reference count object class, which provides duplicate, release, respectively, for increasing counts, reducing the count (when the reference count is 0 o'clock releases the current object), Referencecount gets the current count; _counter: For the current atomic count;


Sharedptr.h:referencecounter reference counting class, a bit different from refcountedobject, which does not dispose of objects; Releasepolicy: Release policy, provide only interfaces that directly dispose objects ; Sharedptr shared smart pointer class; its template parameters default to Referencecounter, _pcounter: Count class object; _ptr: Instance object pointer Sharedptr is one of the differences with respect to AUTOPTR: The former provides an external reference count and a release strategy, while the latter requires the template object itself to provide a count and release policy, other interfaces provide similar, and autoptr is not consistent with the general auto_ptr performance behavior, such as object ownership, The autoptr herein is not exclusive ownership;


The Singletonholder.h:singletonholder singleton Holder class, which provides implementations as template parameters, provides the creation of an instance object on the heap and is responsible for maintaining the life cycle; the creation of an instance object operation is secured internally through a locking mechanism, because all non-static class members are In general, to achieve a true singleton implementation, often need external to maintain the creation time, such as static single-instance holder class;


String.h: A collection of string tool functions, essentially providing various string processing related function implementations in a template way; Trimleft: Character that rejects the left whitespace character property of a string (not just a space) ; Trimleftinplace: Rejects the string whitespace character and returns the rejected string; trimright, Trimrightinplace: Remove the right white-space character from the string; trim, Triminplace: Remove whitespace characters at both ends of the string ; ToUpper, Toupperinplace, ToLower, Tolowerinplace: Convert the string to uppercase and lowercase respectively; Icompare: multiple overloaded versions, providing case-insensitive string comparisons; translate: multiple overloaded versions , which provides the operation of replacing each character in Str with the value of the corresponding position in the to in the From, Replaceinplace: multiple overloaded versions, which provide a lookup from string from the STR string to the to string and return the replaced string, plus replace, Remove uses replaceinplace to replace or remove certain characters or strings; Cat: Multiple overloaded versions that provide string strings; StartsWith, EndsWith: A string that determines whether to start or end with a string; i_char_ Traits: inherited from the Std::char_traits character attribute to implement a case insensitive Istring string class type; ISUBSTR: case insensitive substring lookup; ciless: Case insensitive Function object class to support case insensitive comparison operations;


The Stringtokenizer.h:stringtokenizer string word breaker class, similar to the StringTokenizer class in Java, is a string that implements the split of a string based on a split string and holds each split character string with a vector The constructor parameter str is the split string, separators is the split string, Options is the split option, Tok_ignore_empty ignores the white space string, and Tok_trim the whitespace string for the splitter string, and the other function interfaces such as lookup, Gets the string substring, gets the number of substrings after splitting, overloads the value operator, and so on;


Void.h:void class, as a virtual class, basically has no function implementation, only provides operator overloading, copying and assignment constructors, generally used in template parameters such as Activemethod or return void null type value;


TypeList.h: Type list template implementation, Nulltypelist: null type list, supply only conditional operator, and enumeration value length (0); Typelist: Type list, where enumeration value length is the tail type enumeration value in the template parameter length+ 1, also provides head, tail, end-to-end type object, the data object is provided by the constructor, in addition, and provide overloaded operators, conditional operators, swap and other implementations;

The core of Poco library--foundation components

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.