DCL 3.7.4
Loading...
Searching...
No Matches
main.cpp File Reference
#include <dcl/Config.h>
#include <locale.h>
#include <dcl/FileWriter.h>
#include <dcl/Arguments.h>
#include <dcl/DateTime.h>
#include "main.h"
#include "EntityCopy.h"
#include "Version.h"

Go to the source code of this file.

Functions

void __main (const MainArguments &_args)
__DCL_END_NAMESPACE __DCL_USING_NAMESPACE int main (int _argc, char *_argv[])

Function Documentation

◆ __main()

void __main ( const MainArguments & _args)

Definition at line 128 of file work/entitycopy/main.cpp.

129{
130 String srcDriver;
131 String dstDriver;
132
133 size_t first = _args.source().search(L"DRIVER *=", true);
134 if (first != (size_t)-1) {
135 srcDriver = _args.source().substring(L"DRIVER *= *[^;]+", true);
136 if (srcDriver.isEmpty()) {
137 srcDriver = _args.source().substring(first);
138 }
139 if (!srcDriver.isEmpty()) {
140 if (srcDriver.indexOf(L'{') != (size_t)-1) {
141 srcDriver = L"DCLODBC";
142 }
143 else {
144 srcDriver = srcDriver.substring(srcDriver.indexOf(L'=') + 1).trim();
145 }
146 }
147 }
148
149 first = _args.destination().search(L"DRIVER *=", true);
150 if (first != (size_t)-1) {
151 dstDriver = _args.destination().substring(L"DRIVER *= *[^;]+", true);
152 if (dstDriver.isEmpty()) {
153 dstDriver = _args.destination().substring(first);
154 }
155 if (!dstDriver.isEmpty()) {
156 if (dstDriver.indexOf(L'{') != (size_t)-1) {
157 dstDriver = L"DCLODBC";
158 }
159 else {
160 dstDriver = dstDriver.substring(dstDriver.indexOf(L'=') + 1).trim();
161 }
162 }
163 }
164
165 if (srcDriver.isEmpty() || dstDriver.isEmpty()) {
166 _args.errout() << _args.value0() << L": option '--source' or '--destination' is invalid"
167 << endl << _args.tryUsage() << endl;
168 return;
169 }
170
171 EntityCopy copy(_args, srcDriver, dstDriver);
172 if (copy.initialize()) {
173 copy.doIt();
174 }
175}
DCLCVAR const struct __endl endl
String tryUsage() const
const String & destination() const
const String & source() const

◆ main()

__DCL_END_NAMESPACE __DCL_USING_NAMESPACE int main ( int _argc,
char * _argv[] )

Definition at line 181 of file work/entitycopy/main.cpp.

182{
183 // std::locale::global(std::locale(""));
184 setlocale(LC_ALL, "");
185
187 {
190#ifdef __DCL_DEBUG
191 DCLDebugSetGlobalReport(&errout);
192#endif
193 MainArguments args(output, errout);
194 if (args.parse(_argc, _argv, false)) {
195 String sep(L'=', 80);
197 output << L"Start [" << start.toString()
198 << L"]" << endl;
199 if (args.verbose()) {
200 output << L" [" << args.toString() << L"]" << endl;
201 }
202 output << sep << endl;
203
204 try {
205 __main(args);
206 }
207 catch (Exception* e) {
208 errout << e->toStringAll() << endl;
209 e->destroy();
210 }
211
213 output << sep << endl
214 << L"Finish [" << finish.toString()
215 << L" " << (finish - start).toString()
216 << L"]" << endl;
217 }
218#ifdef __DCL_DEBUG
219#if __DCL_HAVE_ALLOC_DEBUG
220 DCLDebugDumpGlobalMemoryLeak(DCL_ALLOC_DUMP_ALL, &errout);
221#endif
222 DCLDebugSetGlobalReport(NULL);
223#endif // __DCL_DEBUG
224 }
226
227 return 0;
228}
#define NULL
Definition Config.h:312
#define STDOUT_HANDLE
Definition File.h:59
#define STDERR_HANDLE
Definition File.h:60
#define __DCL_CLEANUP
Definition Object.h:286
#define __DCL_INITIALIZE
Definition Object.h:285
String toString() const
Definition DateTime.cpp:843
static DateTime getCurrentLocalTime()
Definition DateTime.cpp:954
virtual void destroy()
Definition Exception.cpp:74
String toStringAll() const
Definition Exception.cpp:45
void __main(const MainArguments &_args)