implement first version of container class for stored items
This commit is contained in:
parent
8c28d1adb8
commit
8d91ec55b8
|
@ -0,0 +1,67 @@
|
||||||
|
#ifndef __SICCCOBJECT_H_
|
||||||
|
#define __SICCCOBJECT_H_
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
class Sicccobject {
|
||||||
|
public:
|
||||||
|
Sicccobject() {} // just for test cases
|
||||||
|
Sicccobject( const std::string& file,
|
||||||
|
const std::string& ftype,
|
||||||
|
const std::string& fpath,
|
||||||
|
const size_t sz)
|
||||||
|
: filename(file),
|
||||||
|
filetype(ftype),
|
||||||
|
path(fpath),
|
||||||
|
size(sz)
|
||||||
|
{
|
||||||
|
upload_date = std::chrono::system_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
Sicccobject( const char *const file,
|
||||||
|
const char *const ftype,
|
||||||
|
const char *const fpath,
|
||||||
|
const size_t sz)
|
||||||
|
: filename(file),
|
||||||
|
filetype(ftype),
|
||||||
|
path(fpath),
|
||||||
|
size(sz)
|
||||||
|
{
|
||||||
|
upload_date = std::chrono::system_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
Sicccobject(const std::string& file,
|
||||||
|
const std::string& ftype,
|
||||||
|
const std::string& fpath,
|
||||||
|
const size_t sz,
|
||||||
|
const std::chrono::time_point<std::chrono::system_clock>& date)
|
||||||
|
: filename(file),
|
||||||
|
filetype(ftype),
|
||||||
|
path(fpath),
|
||||||
|
size(sz),
|
||||||
|
upload_date(date) { }
|
||||||
|
|
||||||
|
Sicccobject(const Sicccobject&);
|
||||||
|
~Sicccobject() {}
|
||||||
|
Sicccobject& operator = (const Sicccobject&);
|
||||||
|
|
||||||
|
std::string get_filename() const { return filename; }
|
||||||
|
std::string get_filetype() const { return filetype; }
|
||||||
|
std::string get_path() const { return path; }
|
||||||
|
size_t get_size() const { return size; }
|
||||||
|
std::chrono::time_point<std::chrono::system_clock>
|
||||||
|
get_uploadtime() const { return upload_date; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string filename;
|
||||||
|
std::string filetype;
|
||||||
|
std::string path;
|
||||||
|
size_t size;
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> upload_date;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::ostream& operator << (std::ostream&, const Sicccobject&);
|
||||||
|
|
||||||
|
#endif /* __SICCCOBJECT_H_ */
|
|
@ -1,16 +1,38 @@
|
||||||
#include <iostream>
|
#include "sicccobject.H"
|
||||||
#include <string>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
class Sicccobject {
|
Sicccobject::Sicccobject(const Sicccobject& obj)
|
||||||
public:
|
{
|
||||||
std::string filename;
|
filename = obj.filename;
|
||||||
std::string filetype;
|
filetype = obj.filetype;
|
||||||
size_t size;
|
path = obj.path;
|
||||||
time_t date;
|
size = obj.size;
|
||||||
Sicccobject(): filename(name), filetype(type), date();
|
upload_date = obj.upload_date;
|
||||||
~Sicccobject();
|
}
|
||||||
|
|
||||||
|
Sicccobject&
|
||||||
|
Sicccobject::operator = (const Sicccobject& obj)
|
||||||
|
{
|
||||||
|
if (this == &obj)
|
||||||
|
return *this;
|
||||||
|
|
||||||
};
|
this->filename = obj.filename;
|
||||||
|
this->filetype = obj.filetype;
|
||||||
|
this->path = obj.path;
|
||||||
|
this->size = obj.size;
|
||||||
|
this->upload_date = obj.upload_date;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream&
|
||||||
|
operator << (std::ostream& out, const Sicccobject& obj)
|
||||||
|
{
|
||||||
|
std::time_t time =
|
||||||
|
std::chrono::system_clock::to_time_t(obj.get_uploadtime());
|
||||||
|
out << "[Filename] " << obj.get_filename() << std::endl
|
||||||
|
<< "[Filetype] " << obj.get_filetype() << std::endl
|
||||||
|
<< "[Path] " << obj.get_path() << std::endl
|
||||||
|
<< "[Size] " << obj.get_size() << std::endl
|
||||||
|
<< "[Uploaded] " << std::ctime(&time) << std::endl;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue