commit efa69625ea43385373c096101c641afd38145911
parent 424648b418ff3136e0514406ea0cb0f98267972b
Author: cfillion <cfillion@users.noreply.github.com>
Date: Tue, 19 Apr 2016 21:47:07 -0400
small refactoring all over the package tree
Diffstat:
11 files changed, 39 insertions(+), 45 deletions(-)
diff --git a/src/index.hpp b/src/index.hpp
@@ -25,6 +25,7 @@
#include <vector>
#include "package.hpp"
+#include "source.hpp"
class Category;
typedef std::vector<const Category *> CategoryList;
diff --git a/src/index_v1.cpp b/src/index_v1.cpp
@@ -107,7 +107,7 @@ void LoadPackageV1(TiXmlElement *packNode, Category *cat)
const char *name = packNode->Attribute("name");
if(!name) name = "";
- Package *pack = new Package(Package::typeFor(type), name, cat);
+ Package *pack = new Package(Package::getType(type), name, cat);
unique_ptr<Package> ptr(pack);
TiXmlElement *verNode = packNode->FirstChildElement("version");
@@ -150,7 +150,7 @@ void LoadVersionV1(TiXmlElement *verNode, Package *pkg)
if(!url) url = "";
Source *src = new Source(file, url, ver);
- src->setPlatform(Source::ConvertPlatform(platform));
+ src->setPlatform(Source::getPlatform(platform));
ver->addSource(src);
node = node->NextSiblingElement("source");
diff --git a/src/package.cpp b/src/package.cpp
@@ -25,7 +25,7 @@
using namespace std;
-Package::Type Package::typeFor(const char *type)
+Package::Type Package::getType(const char *type)
{
if(!strcmp(type, "script"))
return ScriptType;
diff --git a/src/package.hpp b/src/package.hpp
@@ -36,7 +36,7 @@ public:
DataType,
};
- static Type typeFor(const char *);
+ static Type getType(const char *);
static std::string displayType(Type);
Package(const Type, const std::string &name, const Category * = nullptr);
diff --git a/src/source.cpp b/src/source.cpp
@@ -23,7 +23,7 @@
using namespace std;
-Source::Platform Source::ConvertPlatform(const char *platform)
+Source::Platform Source::getPlatform(const char *platform)
{
if(!strcmp(platform, "all"))
return GenericPlatform;
diff --git a/src/source.hpp b/src/source.hpp
@@ -18,17 +18,12 @@
#ifndef REAPACK_SOURCE_HPP
#define REAPACK_SOURCE_HPP
-#include <map>
#include <string>
-#include <vector>
-#include "path.hpp"
-
-class Source;
-typedef std::vector<Source *> SourceList;
-typedef std::multimap<Path, const Source *> SourceMap;
+#include "package.hpp"
class Package;
+class Path;
class Version;
class Source {
@@ -48,7 +43,7 @@ public:
Darwin64Platform,
};
- static Platform ConvertPlatform(const char *);
+ static Platform getPlatform(const char *);
Source(const std::string &file, const std::string &url,
const Version * = nullptr);
diff --git a/src/task.cpp b/src/task.cpp
@@ -18,6 +18,7 @@
#include "task.hpp"
#include "filesystem.hpp"
+#include "source.hpp"
#include "transaction.hpp"
#include "version.hpp"
diff --git a/src/version.cpp b/src/version.cpp
@@ -19,6 +19,7 @@
#include "errors.hpp"
#include "package.hpp"
+#include "source.hpp"
#include <algorithm>
#include <cmath>
diff --git a/src/version.hpp b/src/version.hpp
@@ -20,16 +20,20 @@
#include <cstdint>
#include <ctime>
+#include <map>
#include <set>
#include <string>
-
-#include "source.hpp"
+#include <vector>
class Package;
+class Source;
+class Path;
class Version {
public:
typedef uint64_t Code;
+ typedef std::vector<Source *> SourceList;
+ typedef std::multimap<Path, const Source *> SourceMap;
Version();
Version(const std::string &, const Package * = nullptr);
diff --git a/test/package.cpp b/test/package.cpp
@@ -14,19 +14,19 @@ static const char *M = "[package]";
TEST_CASE("package type from string", M) {
SECTION("unknown")
- REQUIRE(Package::typeFor("yoyo") == Package::UnknownType);
+ REQUIRE(Package::getType("yoyo") == Package::UnknownType);
SECTION("script")
- REQUIRE(Package::typeFor("script") == Package::ScriptType);
+ REQUIRE(Package::getType("script") == Package::ScriptType);
SECTION("extension")
- REQUIRE(Package::typeFor("extension") == Package::ExtensionType);
+ REQUIRE(Package::getType("extension") == Package::ExtensionType);
SECTION("effect")
- REQUIRE(Package::typeFor("effect") == Package::EffectType);
+ REQUIRE(Package::getType("effect") == Package::EffectType);
SECTION("data")
- REQUIRE(Package::typeFor("data") == Package::DataType);
+ REQUIRE(Package::getType("data") == Package::DataType);
}
TEST_CASE("package type to string", M) {
diff --git a/test/source.cpp b/test/source.cpp
@@ -10,38 +10,30 @@ using namespace std;
static const char *M = "[source]";
-TEST_CASE("convert platforms", M) {
- SECTION("unknown") {
- REQUIRE(Source::ConvertPlatform("hello") == Source::UnknownPlatform);
- }
+TEST_CASE("source platform from string", M) {
+ SECTION("unknown")
+ REQUIRE(Source::getPlatform("hello") == Source::UnknownPlatform);
- SECTION("generic") {
- REQUIRE(Source::ConvertPlatform("all") == Source::GenericPlatform);
- }
+ SECTION("generic")
+ REQUIRE(Source::getPlatform("all") == Source::GenericPlatform);
- SECTION("generic windows") {
- REQUIRE(Source::ConvertPlatform("windows") == Source::WindowsPlatform);
- }
+ SECTION("generic windows")
+ REQUIRE(Source::getPlatform("windows") == Source::WindowsPlatform);
- SECTION("windows 32-bit") {
- REQUIRE(Source::ConvertPlatform("win32") == Source::Win32Platform);
- }
+ SECTION("windows 32-bit")
+ REQUIRE(Source::getPlatform("win32") == Source::Win32Platform);
- SECTION("windows 64-bit") {
- REQUIRE(Source::ConvertPlatform("win64") == Source::Win64Platform);
- }
+ SECTION("windows 64-bit")
+ REQUIRE(Source::getPlatform("win64") == Source::Win64Platform);
- SECTION("generic os x") {
- REQUIRE(Source::ConvertPlatform("darwin") == Source::DarwinPlatform);
- }
+ SECTION("generic os x")
+ REQUIRE(Source::getPlatform("darwin") == Source::DarwinPlatform);
- SECTION("os x 32-bit") {
- REQUIRE(Source::ConvertPlatform("darwin32") == Source::Darwin32Platform);
- }
+ SECTION("os x 32-bit")
+ REQUIRE(Source::getPlatform("darwin32") == Source::Darwin32Platform);
- SECTION("os x 64-bit") {
- REQUIRE(Source::ConvertPlatform("darwin64") == Source::Darwin64Platform);
- }
+ SECTION("os x 64-bit")
+ REQUIRE(Source::getPlatform("darwin64") == Source::Darwin64Platform);
}
TEST_CASE("source platform", M) {