Click here to Skip to main content
15,896,118 members
Articles / Programming Languages / C

C++ Wrapper Library for Firebird Embedded SQL

,
Rate me:
Please Sign up or sign in to vote.
4.25/5 (9 votes)
23 Sep 2009CPOL8 min read 45.7K   1.1K   24  
This article is devoted to the Embedded Firebird database usage and also development of C++ wrapper of this database.
#ifndef __cmnBufferReader_h_INCLUDED_
#define __cmnBufferReader_h_INCLUDED_

#include <new>
#include <exception>
#include <stdexcept>
#include <memory>

#include <string>
#include <vector>

namespace cmn
{
    class BufferReader
    {
        char* start;
        char* end;
        char* cursor;

        void read( int size);

    public:
        BufferReader()
        {
            start = 0;
            end = 0;
            cursor = 0;
        }

        void ConnectTo( const void *ptr, size_t size)
        {
            if( ptr == 0 || size <= 0) return;
            start = (char*)ptr;
            end = start + size;
            cursor = start;
        }

        void Disconnect()
        {
            start = 0;
        }

        bool read_int8_bool()
        {
            return read_int8() != 0;
        }

        char read_int8()
        {
            read( sizeof(char));
            return *(cursor-sizeof(char));
        }
        short read_int16()
        {
            read( sizeof(short));
            return *(short*)(cursor-sizeof(short));
        }
        int read_int32()
        {
            read( sizeof(int));
            return *(int*)(cursor-sizeof(int));
        }
        __int64 read_int64()
        {
            read( sizeof(__int64));
            return *(__int64*)(cursor-sizeof(__int64));
        }
        float read_single()
        {
            read( sizeof(float));
            return *(float*)(cursor-sizeof(float));
        }
        double read_double()
        {
            read( sizeof(double));
            return *(double*)(cursor-sizeof(double));
        }
        double read_datetime()
        {
            return read_double();
        }

        std::string read_string();
        std::string read_string_as_wstring();
        std::wstring read_wstring();
        std::wstring read_wstring2();
        std::vector<char> read_raw(); //?
        void read_raw_ref(std::vector<char>* pData);
    };
}

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Apriorit Inc.
United States United States
ApriorIT is a software research and development company specializing in cybersecurity and data management technology engineering. We work for a broad range of clients from Fortune 500 technology leaders to small innovative startups building unique solutions.

As Apriorit offers integrated research&development services for the software projects in such areas as endpoint security, network security, data security, embedded Systems, and virtualization, we have strong kernel and driver development skills, huge system programming expertise, and are reals fans of research projects.

Our specialty is reverse engineering, we apply it for security testing and security-related projects.

A separate department of Apriorit works on large-scale business SaaS solutions, handling tasks from business analysis, data architecture design, and web development to performance optimization and DevOps.

Official site: https://www.apriorit.com
Clutch profile: https://clutch.co/profile/apriorit
This is a Organisation

33 members

Written By
Software Developer (Senior) ApriorIT
Ukraine Ukraine
Senior Software Developer of Apriorit Inc.
My favorite tasks are multithreading, networking and WDK.

... But in free time : beer, meat, travelling and photo...)

LinkedIn Profile : Wineblat Eugene

Comments and Discussions