source: source/ariba/utility/addressing/facades/to_string_v.hpp@ 9971

Last change on this file since 9971 was 5284, checked in by mies, 15 years ago

+ added new transport modules and adapted ariba to them
+ exchange endpoint descriptors an link establishment
+ clean up of base communication
+ link establishment with in the presence of multiple endpoints
+ local discovery for ipv6, ipv4 and bluetooth mac addresses

File size: 1.8 KB
Line 
1// to_string_v.hpp, created on 30.06.2009 by Sebastian Mies
2
3#ifndef TO_STRING_V_HPP_
4#define TO_STRING_V_HPP_
5
6#include <string>
7#include "vfacade.hpp"
8
9using namespace std;
10
11/**
12 * TODO: Doc
13 *
14 * @author Sebastian Mies <mies@tm.uka.de>
15 */
16/// a to to string interface
17class to_string_v {
18public:
19 //--- to_string_v ---------------------------------------------------------
20
21 /// convert address to a string that can be used to reconstruct the address
22 virtual string to_string() const = 0;
23
24 /// Assigns an address using a human-readable
25 virtual bool assign(const std::string& text) = 0;
26
27 /// convenience method for assignment of a c-strings
28 inline to_string_v& assign(const char* text) {
29 to_string_v::assign(std::string(text));
30 return *this;
31 }
32
33 /// convenience method for assignment of strings
34 inline to_string_v& operator=(const std::string& text) {
35 assign(text);
36 return *this;
37 }
38
39 /// convenience method for assignment of strings
40 inline to_string_v& operator=(const char* text) {
41 assign(text);
42 return *this;
43 }
44};
45
46typedef vfacade<to_string_v> to_string_vf;
47
48/// the object hull for to_string interfaces
49template<class NonVirtual, class AdaptorType>
50class vobject_hull<NonVirtual, to_string_v, AdaptorType> : public to_string_v {
51private:
52 typename AdaptorType::template adaptor_type<NonVirtual> obj;
53
54public:
55 template<typename T>
56 explicit vobject_hull(T& obj) :
57 obj(obj) {
58 }
59
60 explicit vobject_hull() :
61 obj() {
62 }
63
64 //--- to_string_v ---------------------------------------------------------
65
66 /// convert address to a string that can be used to reconstruct the address
67 virtual string to_string() const {
68 return obj->to_string();
69 }
70
71 /// Assigns an address using a human-readable
72 virtual bool assign(const std::string& text) {
73 return obj->assign(text);
74 }
75};
76
77#endif /* TO_STRING_V_HPP_ */
Note: See TracBrowser for help on using the repository browser.