aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Walters <rwalters@digitalstirling.com>2018-06-02 19:44:09 -0700
committerRichard Walters <rwalters@digitalstirling.com>2018-06-02 19:44:09 -0700
commit5e69673563dd72f23dabc1f6d86ad684710b23bb (patch)
tree43471032352a770c7d7eb4aff05a8c00c37d9184
Initial Revision.
-rw-r--r--CMakeLists.txt23
-rw-r--r--README.md50
-rw-r--r--include/Uri/Uri.hpp53
-rw-r--r--src/Uri.cpp25
-rw-r--r--test/CMakeLists.txt25
-rw-r--r--test/src/UriTests.cpp15
6 files changed, 191 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..bfd19d7
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,23 @@
+# CMakeLists.txt for Uri
+#
+# © 2018 by Richard Walters
+
+cmake_minimum_required(VERSION 3.8)
+set(This Uri)
+
+set(Headers
+ include/Uri/Uri.hpp
+)
+
+set(Sources
+ src/Uri.cpp
+)
+
+add_library(${This} STATIC ${Sources} ${Headers})
+set_target_properties(${This} PROPERTIES
+ FOLDER Libraries
+)
+
+target_include_directories(${This} PUBLIC include)
+
+add_subdirectory(test)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c9d305b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,50 @@
+# Uri
+
+This is a library which implements [RFC 3986](https://tools.ietf.org/html/rfc3986),
+"Uniform Resource Identifier (URI): Generic Syntax".
+
+## Usage
+
+The `Uri::Uri` class is used to parse URIs from strings, render URIs as strings, and get or set the individual elements of a URI.
+
+## Supported platforms / recommended toolchains
+
+This is a portable C++11 library which depends only on the C++11 compiler and standard library, so it should be supported on almost any platform. The following are recommended toolchains for popular platforms.
+
+* Windows -- [Visual Studio](https://www.visualstudio.com/) (Microsoft Visual C++)
+* Linux -- clang or gcc
+* MacOS -- Xcode (clang)
+
+## Building
+
+This library is not intended to stand alone. It is intended to be included in a larger solution which uses [CMake](https://cmake.org/) to generate the build system and build applications which will link with the library.
+
+There are two distinct steps in the build process:
+
+1. Generation of the build system, using CMake
+2. Compiling, linking, etc., using CMake-compatible toolchain
+
+### Prerequisites
+
+* [CMake](https://cmake.org/) version 3.8 or newer
+* C++11 toolchain compatible with CMake for your development platform (e.g. [Visual Studio](https://www.visualstudio.com/) on Windows)
+
+### Build system generation
+
+Generate the build system using [CMake](https://cmake.org/) from the solution root. For example:
+
+```bash
+mkdir build
+cd build
+cmake -G "Visual Studio 15 2017" -A "x64" ..
+```
+
+### Compiling, linking, etc.
+
+Either use [CMake](https://cmake.org/) or your toolchain's IDE to build.
+For [CMake](https://cmake.org/):
+
+```bash
+cd build
+cmake --build . --config Release
+```
diff --git a/include/Uri/Uri.hpp b/include/Uri/Uri.hpp
new file mode 100644
index 0000000..b5f85c2
--- /dev/null
+++ b/include/Uri/Uri.hpp
@@ -0,0 +1,53 @@
+#ifndef URI_HPP
+#define URI_HPP
+
+/**
+ * @file Uri.hpp
+ *
+ * This module declares the Uri::Uri class.
+ *
+ * © 2018 by Richard Walters
+ */
+
+#include <memory>
+
+namespace Uri {
+
+ /**
+ * This class represents a Uniform Resource Identifier (URI),
+ * as defined in RFC 3986 (https://tools.ietf.org/html/rfc3986).
+ */
+ class Uri {
+ // Lifecycle management
+ public:
+ ~Uri();
+ Uri(const Uri&) = delete;
+ Uri(Uri&&) = delete;
+ Uri& operator=(const Uri&) = delete;
+ Uri& operator=(Uri&&) = delete;
+
+ // Public methods
+ public:
+ /**
+ * This is the default constructor.
+ */
+ Uri();
+
+ // Private properties
+ private:
+ /**
+ * This is the type of structure that contains the private
+ * properties of the instance. It is defined in the implementation
+ * and declared here to ensure that it is scoped inside the class.
+ */
+ struct Impl;
+
+ /**
+ * This contains the private properties of the instance.
+ */
+ std::unique_ptr< struct Impl > impl_;
+ };
+
+}
+
+#endif /* URI_HPP */
diff --git a/src/Uri.cpp b/src/Uri.cpp
new file mode 100644
index 0000000..d63a5a9
--- /dev/null
+++ b/src/Uri.cpp
@@ -0,0 +1,25 @@
+/**
+ * @file Uri.cpp
+ *
+ * This module contains the implementation of the Uri::Uri class.
+ *
+ * © 2018 by Richard Walters
+ */
+
+#include <Uri/Uri.hpp>
+
+namespace Uri {
+ /**
+ * This contains the private properties of a Uri instance.
+ */
+ struct Uri::Impl {
+ };
+
+ Uri::~Uri() = default;
+
+ Uri::Uri()
+ : impl_(new Impl)
+ {
+ }
+
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..7c3eb76
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,25 @@
+# CMakeLists.txt for UriTests
+#
+# © 2018 by Richard Walters
+
+cmake_minimum_required(VERSION 3.8)
+set(This UriTests)
+
+set(Sources
+ src/UriTests.cpp
+)
+
+add_executable(${This} ${Sources})
+set_target_properties(${This} PROPERTIES
+ FOLDER Tests
+)
+
+target_link_libraries(${This} PUBLIC
+ gtest_main
+ Uri
+)
+
+add_test(
+ NAME ${This}
+ COMMAND ${This}
+)
diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp
new file mode 100644
index 0000000..3cb5336
--- /dev/null
+++ b/test/src/UriTests.cpp
@@ -0,0 +1,15 @@
+/**
+ * @file UriTests.cpp
+ *
+ * This module contains the unit tests of the Uri::Uri class.
+ *
+ * © 2018 by Richard Walters
+ */
+
+#include <gtest/gtest.h>
+#include <Uri/Uri.hpp>
+
+TEST(UriTests, Placeholder) {
+ Uri::Uri uri;
+ ASSERT_TRUE(true);
+}