@@ -257,7 +257,77 @@ namespace sio
257
257
{
258
258
return ptr (new array_message ());
259
259
}
260
-
260
+
261
+ void push (message::ptr const & message)
262
+ {
263
+ if (message)
264
+ _v.push_back (message);
265
+ }
266
+
267
+ void push (const string& text)
268
+ {
269
+ _v.push_back (string_message::create (text));
270
+ }
271
+
272
+ void push (string&& text)
273
+ {
274
+ _v.push_back (string_message::create (move (text)));
275
+ }
276
+
277
+ void push (shared_ptr<string> const & binary)
278
+ {
279
+ if (binary)
280
+ _v.push_back (binary_message::create (binary));
281
+ }
282
+
283
+ void push (shared_ptr<const string> const & binary)
284
+ {
285
+ if (binary)
286
+ _v.push_back (binary_message::create (binary));
287
+ }
288
+
289
+ void insert (size_t pos,message::ptr const & message)
290
+ {
291
+ _v.insert (_v.begin ()+pos, message);
292
+ }
293
+
294
+ void insert (size_t pos,const string& text)
295
+ {
296
+ _v.insert (_v.begin ()+pos, string_message::create (text));
297
+ }
298
+
299
+ void insert (size_t pos,string&& text)
300
+ {
301
+ _v.insert (_v.begin ()+pos, string_message::create (move (text)));
302
+ }
303
+
304
+ void insert (size_t pos,shared_ptr<string> const & binary)
305
+ {
306
+ if (binary)
307
+ _v.insert (_v.begin ()+pos, binary_message::create (binary));
308
+ }
309
+
310
+ void insert (size_t pos,shared_ptr<const string> const & binary)
311
+ {
312
+ if (binary)
313
+ _v.insert (_v.begin ()+pos, binary_message::create (binary));
314
+ }
315
+
316
+ size_t size () const
317
+ {
318
+ return _v.size ();
319
+ }
320
+
321
+ const message::ptr& at (size_t i) const
322
+ {
323
+ return _v[i];
324
+ }
325
+
326
+ const message::ptr& operator [] (size_t i) const
327
+ {
328
+ return _v[i];
329
+ }
330
+
261
331
vector<ptr>& get_vector ()
262
332
{
263
333
return _v;
@@ -280,7 +350,58 @@ namespace sio
280
350
{
281
351
return ptr (new object_message ());
282
352
}
283
-
353
+
354
+ void insert (const string & key,message::ptr const & message)
355
+ {
356
+ _v[key] = message;
357
+ }
358
+
359
+ void insert (const string & key,const string& text)
360
+ {
361
+ _v[key] = string_message::create (text);
362
+ }
363
+
364
+ void insert (const string & key,string&& text)
365
+ {
366
+ _v[key] = string_message::create (move (text));
367
+ }
368
+
369
+ void insert (const string & key,shared_ptr<string> const & binary)
370
+ {
371
+ if (binary)
372
+ _v[key] = binary_message::create (binary);
373
+ }
374
+
375
+ void insert (const string & key,shared_ptr<const string> const & binary)
376
+ {
377
+ if (binary)
378
+ _v[key] = binary_message::create (binary);
379
+ }
380
+
381
+ bool has (const string & key)
382
+ {
383
+ return _v.find (key) != _v.end ();
384
+ }
385
+
386
+ const message::ptr& at (const string & key) const
387
+ {
388
+ static shared_ptr<message> not_found;
389
+
390
+ map<string,message::ptr>::const_iterator it = _v.find (key);
391
+ if (it != _v.end ()) return it->second ;
392
+ return not_found;
393
+ }
394
+
395
+ const message::ptr& operator [] (const string & key) const
396
+ {
397
+ return at (key);
398
+ }
399
+
400
+ bool has (const string & key) const
401
+ {
402
+ return _v.find (key) != _v.end ();
403
+ }
404
+
284
405
map<string,message::ptr>& get_map ()
285
406
{
286
407
return _v;
@@ -332,6 +453,7 @@ namespace sio
332
453
{
333
454
if (message)
334
455
m_vector.push_back (message);
456
+
335
457
}
336
458
337
459
list (const string& text)
@@ -360,14 +482,57 @@ namespace sio
360
482
{
361
483
if (message)
362
484
m_vector.push_back (message);
363
-
364
485
}
365
486
487
+ void push (const string& text)
488
+ {
489
+ m_vector.push_back (string_message::create (text));
490
+ }
491
+
492
+ void push (string&& text)
493
+ {
494
+ m_vector.push_back (string_message::create (move (text)));
495
+ }
496
+
497
+ void push (shared_ptr<string> const & binary)
498
+ {
499
+ if (binary)
500
+ m_vector.push_back (binary_message::create (binary));
501
+ }
502
+
503
+ void push (shared_ptr<const string> const & binary)
504
+ {
505
+ if (binary)
506
+ m_vector.push_back (binary_message::create (binary));
507
+ }
508
+
366
509
void insert (size_t pos,message::ptr const & message)
367
510
{
368
511
m_vector.insert (m_vector.begin ()+pos, message);
369
512
}
370
513
514
+ void insert (size_t pos,const string& text)
515
+ {
516
+ m_vector.insert (m_vector.begin ()+pos, string_message::create (text));
517
+ }
518
+
519
+ void insert (size_t pos,string&& text)
520
+ {
521
+ m_vector.insert (m_vector.begin ()+pos, string_message::create (move (text)));
522
+ }
523
+
524
+ void insert (size_t pos,shared_ptr<string> const & binary)
525
+ {
526
+ if (binary)
527
+ m_vector.insert (m_vector.begin ()+pos, binary_message::create (binary));
528
+ }
529
+
530
+ void insert (size_t pos,shared_ptr<const string> const & binary)
531
+ {
532
+ if (binary)
533
+ m_vector.insert (m_vector.begin ()+pos, binary_message::create (binary));
534
+ }
535
+
371
536
size_t size () const
372
537
{
373
538
return m_vector.size ();
0 commit comments