Lot of code for generating code. Working on unit tests.
This commit is contained in:
parent
da45929b12
commit
8f4845d4d2
42 changed files with 1089 additions and 267 deletions
46
pglablib/codebuilder/TypeMappings.h
Normal file
46
pglablib/codebuilder/TypeMappings.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef TYPEMAPPINGS_H
|
||||
#define TYPEMAPPINGS_H
|
||||
|
||||
#include <Pgsql_declare.h>
|
||||
#include <QString>
|
||||
#include <initializer_list>
|
||||
#include <unordered_map>
|
||||
|
||||
class PgTypeContainer;
|
||||
|
||||
class TypeMappings {
|
||||
public:
|
||||
using TypeMap = std::unordered_map<Oid, QString>;
|
||||
using Mapping = std::pair<Oid, QString>;
|
||||
|
||||
TypeMappings();
|
||||
|
||||
TypeMappings(std::initializer_list<Mapping> mappings);
|
||||
|
||||
QString getTypeForOid(Oid oid) const;
|
||||
|
||||
const TypeMap& typeMap() const { return m_typeMap; }
|
||||
|
||||
QString defaultStringType() const { return m_defaultStringType; }
|
||||
|
||||
void setTypes(std::shared_ptr<const PgTypeContainer> types);
|
||||
|
||||
void setDefaultStringType(QString str);
|
||||
|
||||
void setDefaultContainerType(QString str);
|
||||
|
||||
void set(Oid oid, QString type);
|
||||
/** Removing a type from the mapping will reeastablish its default mapping
|
||||
* which in most cases is the default string type for the language.
|
||||
*/
|
||||
void remove(Oid oid);
|
||||
private:
|
||||
|
||||
TypeMap m_typeMap;
|
||||
QString m_defaultStringType;
|
||||
QString m_defaultContainerType; ///< This string should contain a format variable where the element type should go
|
||||
|
||||
std::shared_ptr<const PgTypeContainer> m_types;
|
||||
};
|
||||
|
||||
#endif // TYPEMAPPINGS_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue