Continued development...
This commit is contained in:
parent
c957bbbb6f
commit
50f6e972de
60
CoreUtils.mk
60
CoreUtils.mk
@ -5,22 +5,22 @@
|
||||
## Debug
|
||||
ProjectName :=CoreUtils
|
||||
ConfigurationName :=Debug
|
||||
WorkspacePath :=/home/bradarant/barant
|
||||
ProjectPath :=/home/bradarant/barant/CoreUtils
|
||||
WorkspacePath :=/home/barant/Development/BMA/server_core
|
||||
ProjectPath :=/home/barant/Development/BMA/server_core/CoreUtils
|
||||
IntermediateDirectory :=./Debug
|
||||
OutDir := $(IntermediateDirectory)
|
||||
CurrentFileName :=
|
||||
CurrentFilePath :=
|
||||
CurrentFileFullPath :=
|
||||
User :=Brad Arant
|
||||
Date :=18/07/19
|
||||
CodeLitePath :=/home/bradarant/.codelite
|
||||
LinkerName :=/usr/bin/x86_64-linux-gnu-g++
|
||||
SharedObjectLinkerName :=/usr/bin/x86_64-linux-gnu-g++ -shared -fPIC
|
||||
Date :=02/08/19
|
||||
CodeLitePath :=/home/barant/.codelite
|
||||
LinkerName :=g++
|
||||
SharedObjectLinkerName :=g++ -shared -fPIC
|
||||
ObjectSuffix :=.o
|
||||
DependSuffix :=.o.d
|
||||
PreprocessSuffix :=.i
|
||||
DebugSwitch :=-g
|
||||
PreprocessSuffix :=.o.i
|
||||
DebugSwitch :=-gstab
|
||||
IncludeSwitch :=-I
|
||||
LibrarySwitch :=-l
|
||||
OutputSwitch :=-o
|
||||
@ -31,7 +31,7 @@ OutputFile :=$(IntermediateDirectory)/lib$(ProjectName).a
|
||||
Preprocessors :=
|
||||
ObjectSwitch :=-o
|
||||
ArchiveOutputSwitch :=
|
||||
PreprocessOnlySwitch :=-E
|
||||
PreprocessOnlySwitch :=-E
|
||||
ObjectsFileList :="CoreUtils.txt"
|
||||
PCHCompileFlags :=
|
||||
MakeDirCommand :=mkdir -p
|
||||
@ -47,20 +47,20 @@ LibPath := $(LibraryPathSwitch).
|
||||
## Common variables
|
||||
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
|
||||
##
|
||||
AR := /usr/bin/x86_64-linux-gnu-ar rcu
|
||||
CXX := /usr/bin/x86_64-linux-gnu-g++
|
||||
CC := /usr/bin/x86_64-linux-gnu-gcc
|
||||
AR := ar rcus
|
||||
CXX := g++
|
||||
CC := gcc
|
||||
CXXFLAGS := -g $(Preprocessors)
|
||||
CFLAGS := -g $(Preprocessors)
|
||||
ASFLAGS :=
|
||||
AS := /usr/bin/x86_64-linux-gnu-as
|
||||
AS := as
|
||||
|
||||
|
||||
##
|
||||
## User defined environment variables
|
||||
##
|
||||
CodeLiteDir:=/usr/share/codelite
|
||||
Objects0=$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) $(IntermediateDirectory)/PString.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix)
|
||||
Objects0=$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) $(IntermediateDirectory)/PString.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix) $(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix)
|
||||
|
||||
|
||||
|
||||
@ -77,8 +77,8 @@ $(OutputFile): $(Objects)
|
||||
@echo "" > $(IntermediateDirectory)/.d
|
||||
@echo $(Objects0) > $(ObjectsFileList)
|
||||
$(AR) $(ArchiveOutputSwitch)$(OutputFile) @$(ObjectsFileList) $(ArLibs)
|
||||
@$(MakeDirCommand) "/home/bradarant/barant/.build-debug"
|
||||
@echo rebuilt > "/home/bradarant/barant/.build-debug/CoreUtils"
|
||||
@$(MakeDirCommand) "/home/barant/Development/BMA/server_core/.build-debug"
|
||||
@echo rebuilt > "/home/barant/Development/BMA/server_core/.build-debug/CoreUtils"
|
||||
|
||||
MakeIntermediateDirs:
|
||||
@test -d ./Debug || $(MakeDirCommand) ./Debug
|
||||
@ -94,7 +94,7 @@ PreBuild:
|
||||
## Objects
|
||||
##
|
||||
$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix): IMFHeader.cpp $(IntermediateDirectory)/IMFHeader.cpp$(DependSuffix)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFHeader.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFHeader.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(IntermediateDirectory)/IMFHeader.cpp$(DependSuffix): IMFHeader.cpp
|
||||
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFHeader.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFHeader.cpp$(DependSuffix) -MM IMFHeader.cpp
|
||||
|
||||
@ -102,7 +102,7 @@ $(IntermediateDirectory)/IMFHeader.cpp$(PreprocessSuffix): IMFHeader.cpp
|
||||
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFHeader.cpp$(PreprocessSuffix) IMFHeader.cpp
|
||||
|
||||
$(IntermediateDirectory)/PString.cpp$(ObjectSuffix): PString.cpp $(IntermediateDirectory)/PString.cpp$(DependSuffix)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/PString.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/PString.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/PString.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/PString.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(IntermediateDirectory)/PString.cpp$(DependSuffix): PString.cpp
|
||||
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/PString.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/PString.cpp$(DependSuffix) -MM PString.cpp
|
||||
|
||||
@ -110,7 +110,7 @@ $(IntermediateDirectory)/PString.cpp$(PreprocessSuffix): PString.cpp
|
||||
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/PString.cpp$(PreprocessSuffix) PString.cpp
|
||||
|
||||
$(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix): IMFMultipart.cpp $(IntermediateDirectory)/IMFMultipart.cpp$(DependSuffix)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFMultipart.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFMultipart.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(IntermediateDirectory)/IMFMultipart.cpp$(DependSuffix): IMFMultipart.cpp
|
||||
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFMultipart.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFMultipart.cpp$(DependSuffix) -MM IMFMultipart.cpp
|
||||
|
||||
@ -118,7 +118,7 @@ $(IntermediateDirectory)/IMFMultipart.cpp$(PreprocessSuffix): IMFMultipart.cpp
|
||||
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFMultipart.cpp$(PreprocessSuffix) IMFMultipart.cpp
|
||||
|
||||
$(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix): IMFMessage.cpp $(IntermediateDirectory)/IMFMessage.cpp$(DependSuffix)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFMessage.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFMessage.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(IntermediateDirectory)/IMFMessage.cpp$(DependSuffix): IMFMessage.cpp
|
||||
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFMessage.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFMessage.cpp$(DependSuffix) -MM IMFMessage.cpp
|
||||
|
||||
@ -126,7 +126,7 @@ $(IntermediateDirectory)/IMFMessage.cpp$(PreprocessSuffix): IMFMessage.cpp
|
||||
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFMessage.cpp$(PreprocessSuffix) IMFMessage.cpp
|
||||
|
||||
$(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix): IMFRequest.cpp $(IntermediateDirectory)/IMFRequest.cpp$(DependSuffix)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFRequest.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFRequest.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(IntermediateDirectory)/IMFRequest.cpp$(DependSuffix): IMFRequest.cpp
|
||||
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFRequest.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFRequest.cpp$(DependSuffix) -MM IMFRequest.cpp
|
||||
|
||||
@ -134,13 +134,29 @@ $(IntermediateDirectory)/IMFRequest.cpp$(PreprocessSuffix): IMFRequest.cpp
|
||||
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFRequest.cpp$(PreprocessSuffix) IMFRequest.cpp
|
||||
|
||||
$(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix): IMFResponse.cpp $(IntermediateDirectory)/IMFResponse.cpp$(DependSuffix)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/bradarant/barant/CoreUtils/IMFResponse.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFResponse.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(IntermediateDirectory)/IMFResponse.cpp$(DependSuffix): IMFResponse.cpp
|
||||
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFResponse.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFResponse.cpp$(DependSuffix) -MM IMFResponse.cpp
|
||||
|
||||
$(IntermediateDirectory)/IMFResponse.cpp$(PreprocessSuffix): IMFResponse.cpp
|
||||
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFResponse.cpp$(PreprocessSuffix) IMFResponse.cpp
|
||||
|
||||
$(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix): IMFFormData.cpp $(IntermediateDirectory)/IMFFormData.cpp$(DependSuffix)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFFormData.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(IntermediateDirectory)/IMFFormData.cpp$(DependSuffix): IMFFormData.cpp
|
||||
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFFormData.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFFormData.cpp$(DependSuffix) -MM IMFFormData.cpp
|
||||
|
||||
$(IntermediateDirectory)/IMFFormData.cpp$(PreprocessSuffix): IMFFormData.cpp
|
||||
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFFormData.cpp$(PreprocessSuffix) IMFFormData.cpp
|
||||
|
||||
$(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix): IMFPlainText.cpp $(IntermediateDirectory)/IMFPlainText.cpp$(DependSuffix)
|
||||
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/barant/Development/BMA/server_core/CoreUtils/IMFPlainText.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix) $(IncludePath)
|
||||
$(IntermediateDirectory)/IMFPlainText.cpp$(DependSuffix): IMFPlainText.cpp
|
||||
@$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IMFPlainText.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IMFPlainText.cpp$(DependSuffix) -MM IMFPlainText.cpp
|
||||
|
||||
$(IntermediateDirectory)/IMFPlainText.cpp$(PreprocessSuffix): IMFPlainText.cpp
|
||||
$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IMFPlainText.cpp$(PreprocessSuffix) IMFPlainText.cpp
|
||||
|
||||
|
||||
-include $(IntermediateDirectory)/*$(DependSuffix)
|
||||
##
|
||||
|
@ -17,6 +17,12 @@
|
||||
<File Name="IMFResponse.h"/>
|
||||
<File Name="IMFResponse.cpp"/>
|
||||
<File Name="IMFBody.h"/>
|
||||
<File Name="Directory.h"/>
|
||||
<File Name="DirectoryEntry.h"/>
|
||||
<File Name="IMFFormData.h"/>
|
||||
<File Name="IMFFormData.cpp"/>
|
||||
<File Name="IMFPlainText.h"/>
|
||||
<File Name="IMFPlainText.cpp"/>
|
||||
</VirtualDirectory>
|
||||
<Settings Type="Static Library">
|
||||
<GlobalSettings>
|
||||
|
@ -1 +1 @@
|
||||
./Debug/IMFHeader.cpp.o ./Debug/PString.cpp.o ./Debug/IMFMultipart.cpp.o ./Debug/IMFMessage.cpp.o ./Debug/IMFRequest.cpp.o ./Debug/IMFResponse.cpp.o
|
||||
./Debug/IMFHeader.cpp.o ./Debug/PString.cpp.o ./Debug/IMFMultipart.cpp.o ./Debug/IMFMessage.cpp.o ./Debug/IMFRequest.cpp.o ./Debug/IMFResponse.cpp.o ./Debug/IMFFormData.cpp.o ./Debug/IMFPlainText.cpp.o
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
Debug/IMFMessage.cpp.o: IMFMessage.cpp IMFMessage.h PString.h includes \
|
||||
IMFHeader.h IMFRequest.h IMFBody.h IMFMultipart.h
|
||||
IMFHeader.h IMFRequest.h IMFBody.h IMFMultipart.h IMFPlainText.h
|
||||
|
||||
IMFMessage.h:
|
||||
|
||||
@ -14,3 +14,5 @@ IMFRequest.h:
|
||||
IMFBody.h:
|
||||
|
||||
IMFMultipart.h:
|
||||
|
||||
IMFPlainText.h:
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36
Directory.h
Normal file
36
Directory.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef __Directory_h__
|
||||
#define __Directory_h__
|
||||
|
||||
#include "includes"
|
||||
#include "DirectoryEntry.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
class Directory {
|
||||
|
||||
public:
|
||||
Directory(std::string path) {
|
||||
dir = opendir(path);
|
||||
if(dir) {
|
||||
struct dirent entry = readdir(dir);
|
||||
while(entry) {
|
||||
directory.emplace(std::string(entry->d_name), entry);
|
||||
entry = readdir(dir)
|
||||
}
|
||||
}
|
||||
|
||||
~Directory() {}
|
||||
|
||||
|
||||
private:
|
||||
DIR *dir;
|
||||
std::map<std::string, DirectoryEntry> directory;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
28
DirectoryEntry.h
Normal file
28
DirectoryEntry.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef __DirectoryEntry_h__
|
||||
#define __DirectoryEntry_h__
|
||||
|
||||
#include "includes"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
class DirectoryEntry {
|
||||
|
||||
public:
|
||||
DirectoryEntry(struct dirent *entry) {
|
||||
memcpy(this->entry, entry, sizeof(struct dirent));
|
||||
}
|
||||
|
||||
~DirectoryEntry() {}
|
||||
|
||||
std::string getName() {
|
||||
return std::string(entry->d_name);
|
||||
}
|
||||
|
||||
private:
|
||||
struct dirent entry;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
21
IMFFormData.cpp
Normal file
21
IMFFormData.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "IMFFormData.h"
|
||||
#include "IMFMessage.h"
|
||||
#include "IMFPlainText.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
IMFFormData::IMFFormData(PString &in, std::string boundary) : IMFMultipart(in, boundary) {
|
||||
|
||||
}
|
||||
|
||||
std::string IMFFormData::getByName(std::string name) {
|
||||
std::string value;
|
||||
for(PString section: sections) {
|
||||
IMFMessage message(section);
|
||||
IMFPlainText *text = (IMFPlainText *)message.getBody();
|
||||
std::cout << text->toString();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
20
IMFFormData.h
Normal file
20
IMFFormData.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef __IMFFormData_h__
|
||||
#define __IMFFormData_h__
|
||||
|
||||
#include "IMFMultipart.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
class IMFFormData: public IMFMultipart {
|
||||
|
||||
public:
|
||||
IMFFormData();
|
||||
IMFFormData(PString &in, std::string boundary);
|
||||
|
||||
std::string getByName(std::string name);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,6 +1,7 @@
|
||||
#include "IMFMessage.h"
|
||||
#include "IMFHeader.h"
|
||||
#include "IMFMultipart.h"
|
||||
#include "IMFPlainText.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
@ -16,9 +17,14 @@ namespace coreutils {
|
||||
|
||||
std::string type = getHeader("Content-Type");
|
||||
|
||||
if(type.size() == 0)
|
||||
type = "text/plain";
|
||||
|
||||
if(type == "multipart/form-data")
|
||||
body = new IMFMultipart(in, getHeaderKeyPairValue("Content-Type", "boundary"));
|
||||
else
|
||||
else if(type == "text/plain")
|
||||
body = new IMFPlainText(in);
|
||||
else
|
||||
body = new IMFBody();
|
||||
}
|
||||
|
||||
@ -39,8 +45,8 @@ namespace coreutils {
|
||||
if(header.getKey() == key) {
|
||||
std::string value = header.getValue();
|
||||
if(valueOnly) {
|
||||
std::vector<std::string> split = PString(value).split(";");
|
||||
value = split[0];
|
||||
std::vector<PString> split = PString(value).split(";");
|
||||
value = split[0].str();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -50,9 +56,8 @@ namespace coreutils {
|
||||
|
||||
std::string IMFMessage::getHeaderKeyPairValue(std::string headerKey, std::string key) {
|
||||
coreutils::PString psource(getHeader(headerKey, false));
|
||||
std::vector<std::string> sourcep = psource.split(";");
|
||||
for(std::string keyx: sourcep) {
|
||||
PString work(keyx);
|
||||
std::vector<PString> sourcep = psource.split(";");
|
||||
for(PString work: sourcep) {
|
||||
work.skipWhitespace();
|
||||
std::string token = work.getTokenExclude("=");
|
||||
if(work.ifNext("=")) {
|
||||
@ -72,4 +77,9 @@ namespace coreutils {
|
||||
return std::string("false");
|
||||
}
|
||||
|
||||
IMFBody * IMFMessage::getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,10 +24,11 @@ namespace coreutils {
|
||||
std::string getHeader(std::string key, bool valueOnly = true);
|
||||
std::string getHeaderKeyPairValue(std::string headerKey, std::string key);
|
||||
|
||||
IMFBody *body;
|
||||
IMFBody *getBody();
|
||||
|
||||
protected:
|
||||
std::vector<IMFHeader> headers;
|
||||
IMFBody *body;
|
||||
|
||||
};
|
||||
|
||||
|
@ -3,13 +3,26 @@
|
||||
namespace coreutils {
|
||||
|
||||
IMFMultipart::IMFMultipart() {
|
||||
|
||||
buffer = "";
|
||||
}
|
||||
|
||||
IMFMultipart::IMFMultipart(PString &in, std::string boundary) {
|
||||
buffer = in.str();
|
||||
in.cursor -= 2;
|
||||
section = in.split("\r\n--" + boundary);
|
||||
|
||||
sections = in.split("\r\n--" + boundary);
|
||||
|
||||
}
|
||||
|
||||
std::string IMFMultipart::toString() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int IMFMultipart::getCount() {
|
||||
return sections.size();
|
||||
}
|
||||
|
||||
PString IMFMultipart::getSectionAt(int index) {
|
||||
return sections[index];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,10 +12,17 @@ namespace coreutils {
|
||||
IMFMultipart();
|
||||
IMFMultipart(PString &in, std::string boundary);
|
||||
|
||||
std::string toString();
|
||||
int getCount();
|
||||
PString getSectionAt(int index);
|
||||
|
||||
protected:
|
||||
std::vector<PString> sections;
|
||||
|
||||
private:
|
||||
std::string boundary;
|
||||
std::vector<std::string> section;
|
||||
|
||||
std::string buffer;
|
||||
};
|
||||
|
||||
}
|
||||
|
17
IMFPlainText.cpp
Normal file
17
IMFPlainText.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "IMFPlainText.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
IMFPlainText::IMFPlainText() {
|
||||
text = "";
|
||||
}
|
||||
|
||||
IMFPlainText::IMFPlainText(PString &in) : IMFBody() {
|
||||
text = in.str();
|
||||
}
|
||||
|
||||
std::string IMFPlainText::toString() {
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
24
IMFPlainText.h
Normal file
24
IMFPlainText.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef __IMFPlainText_h__
|
||||
#define __IMFPlainText_h__
|
||||
|
||||
#include "PString.h"
|
||||
#include "IMFBody.h"
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
class IMFPlainText: public IMFBody {
|
||||
|
||||
public:
|
||||
IMFPlainText();
|
||||
IMFPlainText(PString &in);
|
||||
|
||||
std::string toString();
|
||||
|
||||
protected:
|
||||
std::string text;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -14,21 +14,21 @@ namespace coreutils {
|
||||
return pstring.substr(cursor);
|
||||
}
|
||||
|
||||
std::vector<std::string> PString::split(std::string delimiter, int maxSize) {
|
||||
std::vector<std::string> list;
|
||||
std::vector<PString> PString::split(std::string delimiter, int maxSize) {
|
||||
std::vector<PString> list;
|
||||
size_t end,
|
||||
pos = cursor;
|
||||
while(pos < pstring.length()) {
|
||||
end = pstring.find(delimiter, pos);
|
||||
if(end == std::string::npos)
|
||||
end = pstring.length();
|
||||
list.push_back(pstring.substr(pos, end - pos));
|
||||
list.push_back(PString(pstring.substr(pos, end - pos)));
|
||||
pos = end + delimiter.size();
|
||||
if(pos > pstring.size())
|
||||
break;
|
||||
if(maxSize != 0) {
|
||||
if(list.size() >= maxSize) {
|
||||
list.push_back(pstring.substr(pos));
|
||||
list.push_back(PString(pstring.substr(pos)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace coreutils {
|
||||
PString(std::string pstring);
|
||||
|
||||
std::string str();
|
||||
std::vector<std::string> split(std::string delimiter, int maxSize = 0);
|
||||
std::vector<PString> split(std::string delimiter, int maxSize = 0);
|
||||
std::string getTokenInclude(std::string include);
|
||||
std::string getTokenExclude(std::string exclude);
|
||||
bool ifNext(std::string value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user