metal/mtce-common/src/common/pgdbClass.h.OBS

84 lines
2.1 KiB
Plaintext

#ifndef __INCLUDE_PGDBCLASS_H__
#define __INCLUDE_PGDBCLASS_H__
/*
* Copyright (c) 2015 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
/**
* @file
* Wind River CGTS Platform PostgreSQL Database Access module for maintenance.
*
* Class, support structs and enums.
*
* This module is based off the libpq - C Library
*
* Header File: libpg-fe.h
* Library File: libpq
*
* http://www.postgresql.org/docs/8.3/static/libpq-build.html
*
*/
#include <sys/types.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <list>
#include <vector>
#include <map>
// #include <postgresql/libpq-fe.h>
#include <libpq-fe.h>
using namespace std;
#include "nodeBase.h" /* for ... comnmon definitions, emums and structs */
#include "nodeUtil.h"
#include "nodeTimers.h" /* */
#include "daemon_common.h"
#include "daemon_option.h"
#include "daemon_ini.h"
typedef std::map<std::string,std::string> mtc_key_value_type ; /* key-value pair array */
typedef std::vector<mtc_key_value_type> mtc_query_type ; /* dynamic sized array */
typedef struct
{
PGconn *conn; /* the postgresql connection */
bool connected; /* true = connected ; false = not connected */
int equote; /* use E''-style quotes for escaped strings */
int protocol; /* protocol version */
int server_version; /* server version */
const char *encoding; /* client encoding */
const char *uri; /* Connection URI */
} pgdb_conn_type ; // formerly SFmDBConn
class pgdbClass
{
protected:
const char * get_parameter_status(const char *param);
public:
pgdbClass();
~pgdbClass();
pgdb_conn_type pg ;
int connect (const char *uri);
void disconnect ();
int reconnect ();
int monitor ();
int query (const char *db_cmd , mtc_query_type & result);
int cmd (const char *db_cmd);
};
int pgdbUtil_get_version ( void );
#endif /* __INCLUDE_PGDBCLASS_H__ */