-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmain.cpp
More file actions
193 lines (154 loc) · 5.23 KB
/
main.cpp
File metadata and controls
193 lines (154 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include <iostream>
#include <dlfcn.h>
#include <stdio.h>
#include <memory>
#include "ACBrNFe.h"
#include <phpcpp.h>
class AcbrLibPhp : public Php::Base
{
private:
std::shared_ptr<ACBrNFe> nfe;
public:
/**
* c++ constructor
*/
AcbrLibPhp() = default;
/**
* c++ destructor
*/
virtual ~AcbrLibPhp() = default;
/**
* php "constructor"
* @param params
*/
void __construct(Php::Parameters ¶ms)
{
// get self reference as Php::Value object
Php::Value self(this);
std::string ePathLib = params[0];
std::string eArqConfig = params[1];
std::string eChaveCrypt = params[2];
nfe = std::make_shared<ACBrNFe>(ePathLib,eArqConfig,eChaveCrypt);
// initialize a public property
//self["property1"] = "xyz";
}
Php::Value NFE_Versao()
{
Php::Value self(this);
return nfe->_NFE_Versao();
}//NFE_ObterXml
/*
void nomeVersao()
{
// get self reference as Php::Value object
Php::Value self(this);
// overwrite the property
//self["property1"] = "abc";
Php::out << nfe->_NFE_Nome() + " " + nfe->_NFE_Versao() << "<br>" << std::endl;
}
*/
void NFE_ConfigGravarValor(Php::Parameters ¶ms)
{
// get self reference as Php::Value object
Php::Value self(this);
std::string eSessao = params[0];
std::string eChave = params[1];
std::string sValor = params[2];
nfe->_NFE_ConfigGravarValor(eSessao,eChave,sValor);
}//NFE_ConfigGravarValor
void NFE_CarregarXML(Php::Parameters ¶ms)
{
// get self reference as Php::Value object
Php::Value self(this);
std::string eArquivoOuXML = params[0];
nfe->_NFE_CarregarXML(eArquivoOuXML);
}//NFE_CarregarXML
void NFE_Assinar()
{
Php::Value self(this);
nfe->_NFE_Assinar();
}//NFE_Assinar
void NFE_LimparLista()
{
Php::Value self(this);
nfe->_NFE_LimparLista();
}//NFE_LimparLista
void NFE_ImprimirPDF()
{
Php::Value self(this);
nfe->_NFE_ImprimirPDF();
}//NFE_ImprimirPDF
void NFE_Validar()
{
// get self reference as Php::Value object
Php::Value self(this);
nfe->_NFE_Validar();
}//NFE_Validar
Php::Value NFE_ObterXml(Php::Parameters ¶ms)
{
Php::Value self(this);
std::int32_t AIndex = params[0];
return nfe->_NFE_ObterXml(AIndex);
}//NFE_ObterXml
Php::Value NFE_Enviar(Php::Parameters ¶ms)
{
Php::Value self(this);
std::int32_t ALote = params[0];
bool Imprimir = params[1];
bool Sincrono = params[2];
bool Zipado = params[3];
return nfe->_NFE_Enviar(ALote, Imprimir,Sincrono,Zipado);
}//NFE_Enviar
};
/**
* tell the compiler that the get_module is a pure C function
*/
extern "C" {
/**
* Function that is called by PHP right after the PHP process
* has started, and that returns an address of an internal PHP
* strucure with all the details and features of your extension
*
* @return void* a pointer to an address that is understood by PHP
*/
PHPCPP_EXPORT void *get_module()
{
// static(!) Php::Extension object that should stay in memory
// for the entire duration of the process (that's why it's static)
static Php::Extension myExtension("acbrlibphp", "1.0");
// description of the class so that PHP knows which methods are accessible
Php::Class<AcbrLibPhp> AcbrLibPhp("AcbrLibPhp");
// register the methods
AcbrLibPhp.method<&AcbrLibPhp::__construct>("__construct", {
Php::ByVal("eArqConfig", Php::Type::String),
Php::ByVal("eChaveCrypt", Php::Type::String)
});
AcbrLibPhp.method<&AcbrLibPhp::NFE_ConfigGravarValor>("NFE_ConfigGravarValor", {
Php::ByVal("eSessao", Php::Type::String),
Php::ByVal("eChave", Php::Type::String),
Php::ByVal("sValor", Php::Type::String)
});
AcbrLibPhp.method<&AcbrLibPhp::NFE_CarregarXML>("NFE_CarregarXML", {
Php::ByVal("eArquivoOuXML", Php::Type::String)
});
AcbrLibPhp.method<&AcbrLibPhp::NFE_Assinar>("NFE_Assinar");
AcbrLibPhp.method<&AcbrLibPhp::NFE_LimparLista>("NFE_LimparLista");
AcbrLibPhp.method<&AcbrLibPhp::NFE_ImprimirPDF>("NFE_ImprimirPDF");
AcbrLibPhp.method<&AcbrLibPhp::NFE_Validar>("NFE_Validar");
AcbrLibPhp.method<&AcbrLibPhp::NFE_ObterXml>("NFE_ObterXml",{
Php::ByVal("AIndex", Php::Type::Numeric)
});
AcbrLibPhp.method<&AcbrLibPhp::NFE_Enviar>("NFE_Enviar",{
Php::ByVal("ALote", Php::Type::Numeric),
Php::ByVal("Imprimir", Php::Type::Bool),
Php::ByVal("Sincrono", Php::Type::Bool),
Php::ByVal("Zipado", Php::Type::Bool)
});
AcbrLibPhp.method<&AcbrLibPhp::NFE_Versao>("NFE_Versao");
// the Example class has one public property
//example.property("property1", "xyz", Php::Public);
// add the class to the extension
myExtension.add(std::move(AcbrLibPhp));
return myExtension;
}
}