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
= this->layout
.end();
46 vector::const_iterator block_end
;
48 for(block_end
= it
+5; it
!= block_end
&& it
!= end
; ++it
) {
49 s
.append(string(1, *it
)); }
52 for(block_end
= it
+7; it
!= block_end
&& it
!= end
; ++it
) {
53 s
.append(string(1, *it
)); }
56 for(block_end
= it
+5; it
!= block_end
&& it
!= end
; ++it
) {
57 s
.append(string(1, *it
)); }
60 for(block_end
= it
+6; it
!= block_end
&& it
!= end
; ++it
) {
61 s
.append(string(1, *it
)); }
64 for(block_end
= it
+5; it
!= block_end
&& it
!= end
; ++it
) {
65 s
.append(string(1, *it
)); }
68 for(block_end
= it
+5; it
!= block_end
&& it
!= end
; ++it
) {
69 s
.append(string(1, *it
)); }
73 const string
toUString() const {
75 for(vector::const_iterator it
= this->layout
.begin();
76 it
!= this->layout
.end(); ++it
) {
77 s
.append(string(1, *it
));
83 string::reference
operator[](const int i
) {
84 return this->layout
[i
];
87 string::reference
operator()(const int row
, const int col
) {
90 return this->layout
[12+col
];
93 return this->layout
[12+11+col
];
97 return this->layout
[col
];
101 // return an iterator on the vector
102 // iterates gunichars, need to be converted before sending to stream
104 return this->layout
.begin();
107 return this->layout
.end();
109 reverse_iterator
rbegin() {
110 return this->layout
.rbegin();
112 reverse_iterator
rend() {
113 return this->layout
.rend();
116 // a vector storing keys to allow random (write) access
117 // only stores a single char per position