BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_StringList.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12
13#ifndef BELFEM_CL_STRINGLIST_HPP
14#define BELFEM_CL_STRINGLIST_HPP
15
16#include "typedefs.hpp"
17#include "assert.hpp"
18
19#ifdef BELFEM_CLANG
20#pragma clang diagnostic push
21#pragma clang diagnostic ignored "-Wunused-private-field"
22#endif
23
24namespace belfem
25{
26//------------------------------------------------------------------------------
27
34 class StringList
35 {
36 const uint mMemory;
37
38 uint mCount;
39
40 char ** mData;
41
42 // non-copyable, non-movable (owns raw heap memory)
43 StringList( const StringList & ) = delete ;
44 StringList & operator=( const StringList & ) = delete ;
45 StringList( StringList && ) = delete ;
46 StringList & operator=( StringList && ) = delete ;
47
48//------------------------------------------------------------------------------
49 public:
50//------------------------------------------------------------------------------
51
52 StringList( const uint aNumberOfStrings );
53
54//------------------------------------------------------------------------------
55
56 ~StringList();
57
58//------------------------------------------------------------------------------
59
60 void
61 push( const string & aString );
62
63//------------------------------------------------------------------------------
64
65 const char *
66 item( const uint aIndex ) const;
67
68//------------------------------------------------------------------------------
69
73 char **
74 data();
75
76//------------------------------------------------------------------------------
77 };
78
79 inline const char *
80 StringList::item( const uint aIndex ) const
81 {
82 BELFEM_ASSERT( aIndex < mCount,
83 "Error reading stringlist item: index %u out of bounds ( must be < %u )",
84 ( unsigned int ) aIndex,
85 ( unsigned int ) mCount );
86
87 return mData[ aIndex ];
88 }
89
90//-----------------------------------------------------------------------------
91
92 inline char **
94 {
95 return mData;
96 }
97
98//------------------------------------------------------------------------------
99}
100
101#ifdef BELFEM_CLANG
102#pragma clang diagnostic pop
103#endif
104
105#endif //BELFEM_CL_STRINGLIST_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
void push(const string &aString)
Definition cl_StringList.cpp:47
char ** data()
expose the data container
Definition cl_StringList.hpp:93
const char * item(const uint aIndex) const
Definition cl_StringList.hpp:80
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30