00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "Application.h"
00023 #include <Sockets/Exception.h>
00024
00025
00026 Application::Application(int argc, char *argv[]) : m_lt("std::vector")
00027 , m_overwrite(false)
00028 {
00029 if (argc < 2)
00030 {
00031 printf("Usage: %s [options] <.wsdl filename>\n", *argv);
00032 printf(" -port <portname> Select portType\n");
00033 printf(" -namespace <ns> Define a global namespace\n");
00034 printf(" -classname <name> Soap Client classname\n");
00035 printf(" -lt <type> Vector type (default: std::vector)\n");
00036 printf(" -overwrite Replace existing files\n");
00037
00038 exit(-1);
00039 }
00040 for (int i = 1; i < argc; i++)
00041 if (!strcmp(argv[i], "-port") && i < argc - 1)
00042 m_portname = argv[++i];
00043 else
00044 if (!strcmp(argv[i], "-overwrite"))
00045 m_overwrite = true;
00046 else
00047 if (!strcmp(argv[i], "-namespace") && i < argc - 1)
00048 m_global_ns = argv[++i];
00049 else
00050 if (!strcmp(argv[i], "-classname") && i < argc - 1)
00051 m_classname = argv[++i];
00052 else
00053 if (!strcmp(argv[i], "-lt") && i < argc - 1)
00054 m_lt = argv[++i];
00055 else
00056 m_filename = argv[i];
00057
00058 if (m_classname.empty() && !m_filename.empty())
00059 {
00060 size_t pos = m_filename.find(".");
00061 if (pos != std::string::npos)
00062 {
00063 m_classname = m_filename.substr(0, pos);
00064 }
00065 }
00066 }
00067
00068
00069 Application::~Application()
00070 {
00071 }
00072
00073
00074 FILE *Application::myfopen(const std::string& filename, const std::string& mode)
00075 {
00076 if (!mode.empty() && mode[0] == 'w')
00077 {
00078 FILE *fil = fopen(filename.c_str(), "r");
00079 if (fil)
00080 {
00081 fclose(fil);
00082 if (!m_overwrite)
00083 {
00084 throw Exception("File already exists: " + filename);
00085 }
00086 }
00087 fil = fopen(filename.c_str(), mode.c_str());
00088 if (!fil)
00089 {
00090 throw Exception("Couldn't create file: " + filename);
00091 }
00092 return fil;
00093 }
00094 FILE *fil = fopen(filename.c_str(), mode.c_str());
00095 if (!fil)
00096 {
00097 throw Exception("Couldn't open file: " + filename);
00098 }
00099 return fil;
00100 }
00101
00102