Statistics
| Branch: | Revision:

root / include / stlwrap.h @ ffa9279f

History | View | Annotate | Download (2.92 KB)

1 01873262 Georg Kunz
//==========================================================================
2
//  STLWRAP.H - part of
3
//                     OMNeT++/OMNEST
4
//            Discrete System Simulation in C++
5
//
6
//==========================================================================
7
8
/*--------------------------------------------------------------*
9
  Copyright (C) 1992-2008 Andras Varga
10
  Copyright (C) 2006-2008 OpenSim Ltd.
11

12
  This file is distributed WITHOUT ANY WARRANTY. See the file
13
  `license' for details on this and other legal matters.
14
*--------------------------------------------------------------*/
15
16
#ifndef __STLWRAP_H
17
#define __STLWRAP_H
18
19
#include "simkerneldefs.h"
20
#include <string>
21
#include <vector>
22
23
NAMESPACE_BEGIN
24
25
//
26
// Note: We *may* need to use these classes in public API functions exposed
27
// in a dll interface
28
//
29
30
/**
31
 * Wrap std::string templated class into an equivalent non-templated class.
32
 * Motivation: Microsoft Visual C++ has problems exporting templated
33
 * classes from DLLs, so we cannot use "raw" STL in our public API.
34
 *
35
 * This is related to VC71 warning C4251: <tt>class 'std::vector<_Ty>' needs
36
 * to have dll-interface to be used by clients of class 'cIniFile'</tt>.
37
 * For discussion of the issue, see
38
 * http://www.unknownroad.com/rtfm/VisualStudio/warningC4251.html
39
 *
40
 * CAREFUL! This class may cause linker error: std::string methods multiply defined
41
 */
42
class SIM_API stdstring : public std::string
43
{
44
  public:
45
    explicit stdstring() {}
46
    stdstring(const std::string& rhs) : std::string(rhs) {}
47
    stdstring(const std::string& rhs, size_type pos, size_type n) : std::string(rhs,pos,n) {}
48
    stdstring(const char *s, size_type n) : std::string(s,n) {}
49
    stdstring(const char *s) : std::string(s) {}
50
    stdstring(size_type n, char c) : std::string(n,c) {}
51
    stdstring(const_iterator first, const_iterator last) : std::string(first,last) {}
52
};
53
54
55
/**
56
 * Wrap std::vector\<stdtring\> templated class into an equivalent non-templated class.
57
 * Motivation: see description at stdstring.
58
 */
59
class SIM_API stdstringvector : public std::vector<stdstring>
60
{
61
  public:
62
    explicit stdstringvector() {}
63
    explicit stdstringvector(size_type n, const stdstring& v = stdstring()) : std::vector<stdstring>(n,v) {}
64
    stdstringvector(const stdstringvector& x) : std::vector<stdstring>(x) {}
65
    stdstringvector(const_iterator first, const_iterator last) : std::vector<stdstring>(first,last) {}
66
};
67
68
/**
69
 * Wrap std::vector\<const char *\> templated class into an equivalent non-templated class.
70
 * Motivation: see description at stdstring.
71
 */
72
class SIM_API stdcharpvector : public std::vector<const char *>
73
{
74
  public:
75
    explicit stdcharpvector() {}
76
    explicit stdcharpvector(size_type n, const char *v = 0) : std::vector<const char *>(n,v) {}
77
    stdcharpvector(const stdcharpvector& x) : std::vector<const char *>(x) {}
78
    stdcharpvector(const_iterator first, const_iterator last) : std::vector<const char *>(first,last) {}
79
};
80
81
82
NAMESPACE_END
83
84
85
#endif