0
I created a header with dll settings:
globaldef. h
#pragma once
#ifdef OPENXML_LIB
#define OPENXML __declspec(dllexport)
#else
#define OPENXML __declspec(dllimport)
#endif // OPENXML_LIB
I have created two classes so far:
xmldoc. h
#pragma once
#define XML_MODE_R 0
#define XML_MODE_RW 1
#include "globaldef.h"
#include <fstream>
#include <string>
class OPENXML XmlDocumment {
public:
XmlDocumment(std::string fileName, int mode);
~XmlDocumment();
//Load xml content to string
virtual std::string read();
private:
//Xml file
std::fstream xmlFile;
std::string filename;
int mode = 0;
};
xmldoc.cpp
#include "stdafx.h"
#include "xmldoc.h"
XmlDocumment::XmlDocumment(std::string fileName, int mode) {
this->filename = fileName;
this->mode = mode;
}
XmlDocumment::~XmlDocumment() { }
std::string XmlDocumment::read() {
switch (mode) {
case XML_MODE_R: xmlFile.open(filename, std::ios::in); break;
case XML_MODE_RW: break;
}
std::string content((std::istreambuf_iterator<char>(xmlFile)), (std::istreambuf_iterator<char>()));
xmlFile.close();
return content;
}
And the other class at the time I didn’t start writing
xmlnode. h
#pragma once
#include "globaldef.h"
class OPENXML XmlNode {
public:
};
Everything builds normally if there is no constructor, but if I add a constructor even without any parameters or empty, the compiler sends the following error:
Show xmldoc.cpp
– Sveen
#include "stdafx. h" #include "xmldoc. h" Xmldocumment::Xmldocumment(Std::string filename, int mode) { this->filename = filename; this->mode = mode; } Xmldocumment::~Xmldocumment() { } Std::string Xmldocumment::read() { switch (mode) { case XML_MODE_R: xmlFile.open(filename, Std::Ios::in); break; case XML_MODE_RW: break; } Std::string content((Std::istreambuf_iterator<char>(xmlFile)), (Std::istreambuf_iterator<char>()); xmlFile.close(); Return content; }
– Samuel Ives
Checks whether the functions used in xmldoc are correct, the visual studio once and for all while not warning correctly
– Sveen
Checks if the DLL is not corrupted
– Sveen