summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--raul/Socket.hpp53
-rw-r--r--raul/URI.hpp111
-rw-r--r--test/build_test.cpp1
-rw-r--r--test/socket_test.cpp4
-rw-r--r--test/uri_test.cpp63
-rw-r--r--wscript3
7 files changed, 32 insertions, 206 deletions
diff --git a/NEWS b/NEWS
index 9953c05..87399b8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,11 @@
-raul (0.8.9) unstable;
+raul (0.8.10) unstable;
* Remove glib dpendency
* Remove boost dependency
* Remove OSC and RDF library dependent code
* Remove remaining library code, now header only
* Remove features now provided by C++11
+ * Remove URI class
* Improve RingBuffer
* Add ThreadVar, a thread-specific variable class
* Add managed_ptr for automatic real-time safe garbage collection
diff --git a/raul/Socket.hpp b/raul/Socket.hpp
index a569511..c42485f 100644
--- a/raul/Socket.hpp
+++ b/raul/Socket.hpp
@@ -18,6 +18,7 @@
#define RAUL_SOCKET_HPP
#include <memory>
+#include <string>
#include <errno.h>
#include <netdb.h>
@@ -31,7 +32,6 @@
#include <unistd.h>
#include "raul/Noncopyable.hpp"
-#include "raul/URI.hpp"
namespace Raul {
@@ -47,11 +47,11 @@ public:
explicit Socket(Type t);
/** Wrap an existing open socket. */
- Socket(Type t,
- const Raul::URI& uri,
- struct sockaddr* addr,
- socklen_t addr_len,
- int fd);
+ Socket(Type t,
+ const std::string& uri,
+ struct sockaddr* addr,
+ socklen_t addr_len,
+ int fd);
~Socket();
@@ -60,13 +60,13 @@ public:
* Use "*" as hostname to listen on all interfaces.
* @return True on success.
*/
- bool bind(const Raul::URI& uri);
+ bool bind(const std::string& uri);
/** Connect a client socket to a server address.
* @param uri Address URI, e.g. unix:///tmp/foo or tcp://somehost:1234
* @return True on success.
*/
- bool connect(const Raul::URI& uri);
+ bool connect(const std::string& uri);
/** Mark server socket as passive to listen for incoming connections.
* @return True on success.
@@ -81,7 +81,7 @@ public:
/** Return the file descriptor for the socket. */
int fd() { return _sock; }
- const Raul::URI& uri() const { return _uri; }
+ const std::string& uri() const { return _uri; }
/** Close the socket. */
void close();
@@ -93,9 +93,9 @@ public:
void shutdown();
private:
- bool set_addr(const Raul::URI& uri);
+ bool set_addr(const std::string& uri);
- Raul::URI _uri;
+ std::string _uri;
struct sockaddr* _addr;
socklen_t _addr_len;
Type _type;
@@ -125,16 +125,16 @@ Socket::Socket(Type t)
}
inline
-Socket::Socket(Type t,
- const Raul::URI& uri,
- struct sockaddr* addr,
- socklen_t addr_len,
- int fd)
- : _uri(uri)
- , _addr(addr)
- , _addr_len(addr_len)
- , _type(t)
- , _sock(fd)
+Socket::Socket(Type t,
+ const std::string& uri,
+ struct sockaddr* addr,
+ socklen_t addr_len,
+ int fd)
+ : _uri(uri)
+ , _addr(addr)
+ , _addr_len(addr_len)
+ , _type(t)
+ , _sock(fd)
{
}
@@ -146,7 +146,7 @@ Socket::~Socket()
}
inline bool
-Socket::set_addr(const Raul::URI& uri)
+Socket::set_addr(const std::string& uri)
{
free(_addr);
if (_type == Type::UNIX && uri.substr(0, strlen("unix://")) == "unix://") {
@@ -189,7 +189,7 @@ Socket::set_addr(const Raul::URI& uri)
}
inline bool
-Socket::bind(const Raul::URI& uri)
+Socket::bind(const std::string& uri)
{
if (set_addr(uri) && ::bind(_sock, _addr, _addr_len) != -1) {
return true;
@@ -199,7 +199,7 @@ Socket::bind(const Raul::URI& uri)
}
inline bool
-Socket::connect(const Raul::URI& uri)
+Socket::connect(const std::string& uri)
{
if (set_addr(uri) && ::connect(_sock, _addr, _addr_len) != -1) {
return true;
@@ -230,13 +230,14 @@ Socket::accept()
return std::shared_ptr<Socket>();
}
- Raul::URI client_uri = _uri;
+ std::string client_uri = _uri;
if (_type != Type::UNIX) {
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
if (!getnameinfo(client_addr, client_addr_len,
host, sizeof(host), serv, sizeof(serv), 0)) {
- client_uri = Raul::URI(_uri.scheme() + "://" + host + ":" + serv);
+ const std::string scheme = _uri.substr(0, _uri.find(':'));
+ client_uri = std::string(scheme + "://" + host + ":" + serv);
}
}
diff --git a/raul/URI.hpp b/raul/URI.hpp
deleted file mode 100644
index 7bf2763..0000000
--- a/raul/URI.hpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- This file is part of Raul.
- Copyright 2007-2015 David Robillard <http://drobilla.net>
-
- Raul is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or any later version.
-
- Raul is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Raul. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef RAUL_URI_HPP
-#define RAUL_URI_HPP
-
-#include <string>
-
-#include "raul/Exception.hpp"
-
-namespace Raul {
-
-/** A URI (RFC3986) string.
- *
- * @ingroup raul
- */
-class URI : public std::basic_string<char> {
-public:
- /** Attempt to construct an invalid URI. */
- class BadURI : public Exception {
- public:
- explicit BadURI(const std::string& uri) : Exception(uri) {}
- };
-
- /** Construct a URI from a C++ string.
- *
- * This will throw an exception if `uri` is invalid. To avoid this, use
- * is_valid() first to check.
- */
- explicit URI(const std::basic_string<char>& uri)
- : std::basic_string<char>(uri)
- {
- if (!is_valid(uri)) {
- throw BadURI(uri);
- }
- }
-
- /** Construct a URI from a C string.
- *
- * This will throw an exception if `uri` is invalid. To avoid this, use
- * is_valid() first to check.
- */
- explicit URI(const char* uri)
- : std::basic_string<char>(uri)
- {
- if (!is_valid(uri)) {
- throw BadURI(uri);
- }
- }
-
- /** Copy a URI.
- *
- * Note this is faster than constructing a URI from another URI's string
- * since validation is unnecessary.
- */
- URI(const URI& uri) = default;
-
- URI& operator=(const URI& uri) = default;
-
- /** Return true iff `c` is a valid URI start character. */
- static inline bool is_valid_start_char(char c) {
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
- }
-
- /** Return true iff `c` is a valid URI scheme character. */
- static inline bool is_valid_scheme_char(char c) {
- // S3.1: scheme ::= ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
- return is_valid_start_char(c) || (c >= '0' && c <= '9') ||
- c == '+' || c == '-' || c == '.';
- }
-
- /** Return true iff `str` is a valid URI.
- *
- * Currently this only checks that `str` starts with a valid URI scheme.
- */
- static inline bool is_valid(const std::basic_string<char>& str) {
- if (!is_valid_start_char(str[0])) {
- return false; // Must start with a-z A-Z
- }
-
- for (size_t i = 1; i < str.length(); ++i) {
- if (str[i] == ':') {
- return true; // Starts with a valid scheme
- } else if (!is_valid_scheme_char(str[i])) {
- return false; // Invalid scheme character encountered
- }
- }
-
- return false; // Must start with a scheme followed by ':'
- }
-
- /** Return the URI scheme (everything before the first ':') */
- inline std::string scheme() const { return substr(0, find(":")); }
-};
-
-} // namespace Raul
-
-#endif // RAUL_URI_HPP
diff --git a/test/build_test.cpp b/test/build_test.cpp
index ea5bf2b..314862c 100644
--- a/test/build_test.cpp
+++ b/test/build_test.cpp
@@ -28,7 +28,6 @@
#include "raul/Symbol.hpp"
#include "raul/TimeSlice.hpp"
#include "raul/TimeStamp.hpp"
-#include "raul/URI.hpp"
int
main(int argc, char** argv)
diff --git a/test/socket_test.cpp b/test/socket_test.cpp
index d6a7b15..8dd4aff 100644
--- a/test/socket_test.cpp
+++ b/test/socket_test.cpp
@@ -27,8 +27,8 @@ using namespace Raul;
int
main(int argc, char** argv)
{
- Raul::URI unix_uri("unix:///tmp/raul_test_sock");
- Raul::URI tcp_uri("tcp://127.0.0.1:12345");
+ std::string unix_uri("unix:///tmp/raul_test_sock");
+ std::string tcp_uri("tcp://127.0.0.1:12345");
Raul::Socket unix_server_sock(Socket::Type::UNIX);
Raul::Socket tcp_server_sock(Socket::Type::TCP);
diff --git a/test/uri_test.cpp b/test/uri_test.cpp
deleted file mode 100644
index 5e1a648..0000000
--- a/test/uri_test.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- This file is part of Raul.
- Copyright 2007-2012 David Robillard <http://drobilla.net>
-
- Raul is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or any later version.
-
- Raul is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Raul. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#undef NDEBUG
-
-#include <cassert>
-#include <iostream>
-
-#include "raul/URI.hpp"
-
-using namespace std;
-using namespace Raul;
-
-int
-main()
-{
-#define CHECK(cond) \
- do { if (!(cond)) { \
- cerr << "Test failed: " << (cond) << endl; \
- assert(0); \
- return 1; \
- } } while (0)
-
- CHECK(URI("http://example.org").scheme() == "http");
- CHECK(URI("svn+ssh://example.org/").scheme() == "svn+ssh");
- CHECK(URI("osc.udp://example.org/").scheme() == "osc.udp");
- CHECK(URI("weird-scheme://example.org/").scheme() == "weird-scheme");
-
- URI original(std::string("http://example.org"));
- URI copy(original);
- CHECK(original == copy);
-
- bool valid = true;
- try {
- URI uri("not/a/uri");
- } catch (const URI::BadURI&) {
- valid = false;
- }
- CHECK(!valid);
-
- valid = true;
- try {
- URI uri(std::string("/this/is/a/path"));
- } catch (const URI::BadURI&) {
- valid = false;
- }
- CHECK(!valid);
-
- return 0;
-}
diff --git a/wscript b/wscript
index b73771e..4a88391 100644
--- a/wscript
+++ b/wscript
@@ -5,7 +5,7 @@ import waflib.Options as Options
import waflib.extras.autowaf as autowaf
# Version of this package (even if built as a child)
-RAUL_VERSION = '0.8.9'
+RAUL_VERSION = '0.8.10'
# Library version (UNIX style major, minor, micro)
# major increment <=> incompatible changes
@@ -71,7 +71,6 @@ tests = '''
test/symbol_test
test/thread_test
test/time_test
- test/uri_test
'''
def build(bld):