MyWebsitesGenerator/TestWebGen/Utilities.h
2017-05-02 08:00:52 +02:00

111 lines
2.0 KiB
C++

#pragma once
#include <iostream>
#include <string>
#include <fstream>
#include <experimental/filesystem>
using namespace std;
using namespace std::experimental::filesystem::v1;
class Utilities
{
protected:
const string meta = "meta";
const string link = "link";
const string rel = "rel";
const string href = "href";
const string http_equiv = "http-equiv";
const string content = "content";
const string name = "name";
const string li = "li";
const string ul = "ul";
const string a = "a";
const string src = "src";
const string alt = "alt";
public:
static enum DeskOrMob
{
D, //Desktop part of the page
M //Mobile part of the page
};
DeskOrMob setDM = D;
enum Levels
{
ROOT,//Content at the index.html directory level
LEVEL1,//Content at the first directory
LEVEL2//Content at the second directory
};
enum Sites
{
DEV,//Build the thepra-dev.com
ART//Build the art.thepra-dev.com
};
enum PageType
{
NORMAL,
POST
};
enum Col
{
White,
Red
};
static string ChooseLevel(Levels level);
static void FullFillContent(string link, string* desktop, string* mobile);
static string GetCurrentPath();
};
inline string Utilities::ChooseLevel(Levels level)
{
switch (level)
{
case Utilities::ROOT:return "";
break;
case Utilities::LEVEL1:return "../";
break;
case Utilities::LEVEL2:return "../../";
default:return "";
break;
}
}
inline void Utilities::FullFillContent(string link, string* desktop, string* mobile)
{
Utilities a = Utilities();
string line = "";
std::ifstream infile;
infile.open(link);
while (!infile.eof())
{
std::getline(infile, line);
if (line == "desktop")
{
line = "";
a.setDM = D;
}
if (a.setDM == D)
{
if (line == "mobile")
{
line = "";
a.setDM = M;
}
*desktop += line + "\n";
}
if (a.setDM == M)
{
*mobile += line + "\n";
}
}
infile.close();
}
inline string Utilities::GetCurrentPath()
{
path current = current_path();
string pathString = current.string();
return pathString;
}