7 #include <glibmm/ustring.h>
9 typedef Glib::ustring string
;
10 typedef std::vector
<string::value_type
> vector
;
12 typedef vector::iterator iterator
;
13 typedef vector::reverse_iterator reverse_iterator
;
15 Layout(const std::string
&s
= "") {
16 this->layout
.reserve(12+11+10); // 33 keys
22 //Layout(const Layout &l) {}
23 //Layout &operator=(const Layout &l) {}
25 void add(const string
&s
) {
26 copy(s
.begin(), s
.end(), std::back_inserter(this->layout
));
28 void add(const std::string
&s
) {
31 void addLine(const std::string
&s
) {
33 this->layout
.push_back('\n');
36 void add(const string::value_type c
) {
37 this->layout
.push_back(c
);
40 // TODO write a back_inserter
41 const std::string
toString() const {
44 vector::const_iterator it
= this->layout
.begin();
45 vector::const_iterator end
;
47 for(end
= it
+5; it
!= end
; ++it
) {
48 s
.append(string(1, *it
)); }
51 for(end
= it
+7; it
!= end
; ++it
) {
52 s
.append(string(1, *it
)); }
55 for(end
= it
+5; it
!= end
; ++it
) {
56 s
.append(string(1, *it
)); }
59 for(end
= it
+6; it
!= end
; ++it
) {
60 s
.append(string(1, *it
)); }
63 for(end
= it
+5; it
!= end
; ++it
) {
64 s
.append(string(1, *it
)); }
67 for(end
= this->layout
.end(); it
!= end
; ++it
) {
68 s
.append(string(1, *it
)); }
72 const string
toUString() const {
74 for(vector::const_iterator it
= this->layout
.begin();
75 it
!= this->layout
.end(); ++it
) {
76 s
.append(string(1, *it
));
82 string::reference
operator[](const int i
) {
83 return this->layout
[i
];
86 // return an iterator on the vector
87 // iterates gunichars, need to be converted before sending to stream
89 return this->layout
.begin();
92 return this->layout
.end();
94 reverse_iterator
rbegin() {
95 return this->layout
.rbegin();
97 reverse_iterator
rend() {
98 return this->layout
.rend();
101 // a vector storing keys to allow random (write) access
102 // only stores a single char per position