Skip to content

Commit

Permalink
Restore originally impoted mimetic library again
Browse files Browse the repository at this point in the history
... leaving out the changes in namespace statements made in the last few days.
  • Loading branch information
teusbenschop committed Apr 21, 2024
1 parent f58983d commit 361b2fd
Show file tree
Hide file tree
Showing 29 changed files with 184 additions and 140 deletions.
10 changes: 5 additions & 5 deletions mimetic098/body.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const MimeEntity* Body::owner() const
return m_owner;
}

bool Body::load(const std::string& fqn)
bool Body::load(const string& fqn)
{
File in(fqn);
if(!in)
Expand All @@ -132,12 +132,12 @@ const MimeEntityList& Body::parts() const
return m_parts;
}

void Body::preamble(const std::string& v)
void Body::preamble(const string& v)
{
m_preamble = v;
}

const std::string& Body::preamble() const
const string& Body::preamble() const
{
return m_preamble;
}
Expand All @@ -147,12 +147,12 @@ string& Body::preamble()
return m_preamble;
}

void Body::epilogue(const std::string& v)
void Body::epilogue(const string& v)
{
m_epilogue = v;
}

const std::string& Body::epilogue() const
const string& Body::epilogue() const
{
return m_epilogue;
}
Expand Down
2 changes: 1 addition & 1 deletion mimetic098/codec/base64.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

#include <mimetic098/codec/base64.h>

using namespace mimetic;
using namespace mimetic;

const char Base64::sEncTable[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Expand Down
2 changes: 1 addition & 1 deletion mimetic098/codec/qp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
***************************************************************************/
#include <mimetic098/codec/qp.h>

using namespace mimetic;
using namespace mimetic;


char QP::sTb[] = {
Expand Down
5 changes: 3 additions & 2 deletions mimetic098/contentdescription.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

namespace mimetic
{
using namespace std;

const char ContentDescription::label[] = "Content-Description";

Expand All @@ -90,13 +91,13 @@ ContentDescription::ContentDescription(const char* cstr)
set(cstr);
}

ContentDescription::ContentDescription(const std::string& val)
ContentDescription::ContentDescription(const string& val)
{
set(val);
}


void ContentDescription::set(const std::string& val)
void ContentDescription::set(const string& val)
{
m_value = val;
}
Expand Down
17 changes: 9 additions & 8 deletions mimetic098/contentdisposition.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@

namespace mimetic
{
using namespace std;

const char ContentDisposition::label[] = "Content-Disposition";

Expand All @@ -92,12 +93,12 @@ ContentDisposition::ContentDisposition(const char* cstr)
set(cstr);
}

ContentDisposition::ContentDisposition(const std::string& val)
ContentDisposition::ContentDisposition(const string& val)
{
set(val);
}

void ContentDisposition::type(const std::string& stype)
void ContentDisposition::type(const string& stype)
{
m_type.assign(stype);
}
Expand All @@ -117,7 +118,7 @@ ContentDisposition::ParamList& ContentDisposition::paramList()
return m_paramList;
}

const std::string& ContentDisposition::param(const std::string& field) const
const string& ContentDisposition::param(const string& field) const
{
ParamList::const_iterator bit = m_paramList.begin(), eit = m_paramList.end();
for(; bit != eit; ++bit)
Expand All @@ -142,15 +143,15 @@ void ContentDisposition::param(const std::string& name, const std::string& val)
m_paramList.push_back(Param(name, val));
}

void ContentDisposition::set(const std::string& val)
void ContentDisposition::set(const string& val)
{
std::string type;
string type;
StringTokenizer stok(&val, ";");
if(!stok.next(type))
return;
m_type.assign(type);

std::string sparam;
string sparam;
while(stok.next(sparam))
{
Param p(sparam);
Expand All @@ -160,7 +161,7 @@ void ContentDisposition::set(const std::string& val)

string ContentDisposition::str() const
{
std::string ostr = m_type;
string ostr = m_type;
ParamList::const_iterator bit, eit;
bit = m_paramList.begin();
eit = m_paramList.end();
Expand All @@ -170,7 +171,7 @@ string ContentDisposition::str() const
return ostr;
}

std::ostream& ContentDisposition::write(std::ostream& os, int fold) const
ostream& ContentDisposition::write(ostream& os, int fold) const
{
os << "Content-Disposition: " << m_type;
ParamList::const_iterator bit, eit;
Expand Down
7 changes: 4 additions & 3 deletions mimetic098/contenttransferencoding.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

namespace mimetic
{
using namespace std;

const char ContentTransferEncoding::label[] = "Content-Transfer-Encoding";
const char ContentTransferEncoding::base64[] = "base64";
Expand All @@ -96,7 +97,7 @@ ContentTransferEncoding::ContentTransferEncoding(const char* cstr)
}


ContentTransferEncoding::ContentTransferEncoding(const std::string& mechanism)
ContentTransferEncoding::ContentTransferEncoding(const string& mechanism)
: m_mechanism(mechanism)
{
}
Expand All @@ -106,12 +107,12 @@ const istring& ContentTransferEncoding::mechanism() const
return m_mechanism;
}

void ContentTransferEncoding::mechanism(const std::string& mechanism)
void ContentTransferEncoding::mechanism(const string& mechanism)
{
m_mechanism.assign (mechanism);
}

void ContentTransferEncoding::set(const std::string& val)
void ContentTransferEncoding::set(const string& val)
{
mechanism(val);
}
Expand Down
33 changes: 17 additions & 16 deletions mimetic098/contenttype.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@

namespace mimetic
{
using namespace std;

const char ContentType::label[] = "Content-Type";

int ContentType::Boundary::ms_i = 0;
std::string ContentType::Boundary::ms_common_boundary = std::string();
string ContentType::Boundary::ms_common_boundary = string();


ContentType::Boundary::Boundary()
Expand All @@ -101,7 +102,7 @@ ContentType::Boundary::Boundary()
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"-_."; // "=+,()/"
std::stringstream ss;
stringstream ss;
srand((unsigned int)time(0));
short tbSize = sizeof(tb)-1;
for(uint i=0; i < 48; ++i)
Expand All @@ -114,7 +115,7 @@ ContentType::Boundary::Boundary()
m_boundary = ms_common_boundary + "=_" + utils::int2hex(ms_i) + "_";
}

ContentType::Boundary::operator const std::string&() const
ContentType::Boundary::operator const string&() const
{
return m_boundary;
}
Expand All @@ -129,17 +130,17 @@ ContentType::ContentType(const char* cstr)
set(cstr);
}

ContentType::ContentType(const std::string& value)
ContentType::ContentType(const string& value)
{
set(value);
}

ContentType::ContentType(const std::string& stype, const std::string& ssubtype)
ContentType::ContentType(const string& stype, const string& ssubtype)
{
set(stype, ssubtype);
}

void ContentType::set(const std::string& stype, const std::string& ssubtype)
void ContentType::set(const string& stype, const string& ssubtype)
{
type(stype);
subtype(ssubtype);
Expand All @@ -150,7 +151,7 @@ bool ContentType::isMultipart() const
return m_type == "multipart";
}

void ContentType::param(const std::string& name, const std::string& value)
void ContentType::param(const string& name, const string& value)
{
ParamList::iterator bit = m_paramList.begin(), eit = m_paramList.end();
for(; bit != eit; ++bit)
Expand All @@ -164,7 +165,7 @@ void ContentType::param(const std::string& name, const std::string& value)
m_paramList.push_back(Param(name, value));
}

const std::string& ContentType::param(const std::string& field) const
const string& ContentType::param(const string& field) const
{
ParamList::const_iterator bit = m_paramList.begin(), eit = m_paramList.end();
for(; bit != eit; ++bit)
Expand All @@ -175,14 +176,14 @@ const std::string& ContentType::param(const std::string& field) const
return nullstring;
}

void ContentType::type(const std::string& v)
void ContentType::type(const string& v)
{
m_type.assign(v);
// if(isMultipart())
// m_paramList.push_back(ContentType::Param("boundary", Boundary()));
}

void ContentType::subtype(const std::string& v)
void ContentType::subtype(const string& v)
{
m_subtype.assign(v);
}
Expand All @@ -208,26 +209,26 @@ ContentType::ParamList& ContentType::paramList()
}


void ContentType::set(const std::string& val)
void ContentType::set(const string& val)
{
StringTokenizer stok(&val, ";");
std::string ct;
string ct;
if(!stok.next(ct))
return;

// parse type/subtype
std::string stype, ssubtype;
string stype, ssubtype;
stok.setDelimList("/");
stok.setSource(&ct);
stok.next(stype);
stok.next(ssubtype);
set(stype, ssubtype);

// parse field params
std::string params(val, std::min(val.length(), ct.length() + 1));
string params(val, min(val.length(), ct.length() + 1));
if(!params.length())
return;
std::string paramValue;
string paramValue;
stok.setDelimList(";");
stok.setSource(&params);
while(stok.next(paramValue))
Expand All @@ -239,7 +240,7 @@ void ContentType::set(const std::string& val)

string ContentType::str() const
{
std::string ostr = m_type + "/" + m_subtype;
string ostr = m_type + "/" + m_subtype;
ParamList::const_iterator bit = m_paramList.begin(),
eit = m_paramList.end();
for(; bit != eit; ++bit)
Expand Down
18 changes: 10 additions & 8 deletions mimetic098/fieldparam.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,28 @@
namespace mimetic
{

using namespace std;

FieldParam::FieldParam()
{
}

FieldParam::FieldParam(const std::string& lpv)
FieldParam::FieldParam(const string& lpv)
{
string::const_iterator bit = lpv.begin(), eit = lpv.end();
for( ; bit != eit; ++bit)
{
if(*bit == '=')
{
std::string n(lpv.begin(), bit), v(++bit, eit);
string n(lpv.begin(), bit), v(++bit, eit);
m_name.assign (remove_external_blanks(n));
m_value = remove_dquote(remove_external_blanks(v));
break;
}
}
}

FieldParam::FieldParam(const std::string& n, const std::string& v)
FieldParam::FieldParam(const string& n, const string& v)
{
name(n);
value(v);
Expand All @@ -109,25 +111,25 @@ const istring& FieldParam::name() const
return m_name;
}

const std::string& FieldParam::value() const
const string& FieldParam::value() const
{
return m_value;
}

void FieldParam::name(const std::string& n)
void FieldParam::name(const string& n)
{
m_name.assign(n);
}

void FieldParam::value(const std::string& v)
void FieldParam::value(const string& v)
{
m_value = v;
}

std::ostream& operator<<(std::ostream& os, const FieldParam& p)
ostream& operator<<(ostream& os, const FieldParam& p)
{
os << p.name() << "=";
const std::string& val = p.value();
const string& val = p.value();
if(val.find_first_of("()\\<>\"@,;:/[]?=") != std::string::npos)
return os << "\"" << val << "\"";
else
Expand Down
1 change: 1 addition & 0 deletions mimetic098/header.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@

namespace mimetic
{
using namespace std;

// MIME-Version:
const MimeVersion& Header::mimeVersion() const
Expand Down
Loading

0 comments on commit 361b2fd

Please sign in to comment.