Operators with std::string
[libacl.git] / src / superstring.cpp
1 /**************************************************************************
2 **  (c) Copyright 1997, Andromeda Technology & Automation
3 ***************************************************************************
4 ** MODULE INFORMATION *
5 ***********************
6 **      FILE NAME      : superstring.cpp
7 **      SYSTEM NAME    : Andromeda X-Windows Encapsulation
8 **      VERSION NUMBER : $Revision: 1.5 $
9 **
10 **  DESCRIPTION      :  SuperString class implementation.
11 **
12 **  EXPORTED OBJECTS : 
13 **  LOCAL    OBJECTS : 
14 **  MODULES  USED    :
15 ***************************************************************************
16 **  ADMINISTRATIVE INFORMATION *
17 ********************************
18 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
19 **      CREATION DATE   : Jun 10, 2020
20 **      LAST UPDATE     : Jun 10, 2020
21 **      MODIFICATIONS   : 
22 **************************************************************************/
23
24 #include <stdio.h>
25 #include <ctype.h>
26 #include "String.h"
27
28 // Addition operators
29
30 SuperString operator+(const SuperString& sx, const SuperString& sy)
31 {
32    SuperString sum;
33
34    sum = sx;
35    sum._ss.insert(sum._ss.end(), sy._ss.begin(), sy._ss.end());
36
37    return sum;
38 }
39
40 SuperString operator+(const SuperString& ss, const String& s)
41 {
42    SuperString SS(ss);
43
44    SS._ss.push_back(s);
45
46    return SS;
47 }
48
49 SuperString operator+(const String& s, const SuperString& ss)
50 {
51    SuperString sum;
52
53    sum = ss;
54    sum._ss.insert(sum._ss.begin(), s);
55
56    return sum;
57 }
58
59 SuperString& SuperString::operator+=(const String& x)
60 {
61    _ss.push_back(x);
62
63    return *this;
64 }
65
66 String SuperString::join(const String &separator)
67 {
68    String joined;
69
70    if (_ss.size() != 0)
71    {
72       joined = _ss[0];
73       for (unsigned i = 1; i < _ss.size(); i++)
74       {
75          joined += separator + _ss[i];
76       }
77    }
78
79    return joined;
80 }