1 2 // 3 // This source file is part of appleseed. 4 // Visit https://appleseedhq.net/ for additional information and resources. 5 // 6 // This software is released under the MIT license. 7 // 8 // Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited 9 // Copyright (c) 2014-2018 Francois Beaune, The appleseedhq Organization 10 // 11 // Permission is hereby granted, free of charge, to any person obtaining a copy 12 // of this software and associated documentation files (the "Software"), to deal 13 // in the Software without restriction, including without limitation the rights 14 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 // copies of the Software, and to permit persons to whom the Software is 16 // furnished to do so, subject to the following conditions: 17 // 18 // The above copyright notice and this permission notice shall be included in 19 // all copies or substantial portions of the Software. 20 // 21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 // THE SOFTWARE. 28 // 29 30 #pragma once 31 32 // appleseed.foundation headers. 33 #include "foundation/utility/api/apiarray.h" 34 #include "foundation/utility/containers/dictionary.h" 35 36 // appleseed.main headers. 37 #include "main/dllsymbol.h" 38 39 // Standard headers. 40 #include <cstddef> 41 42 namespace foundation 43 { 44 45 // 46 // Predefined array types. 47 // 48 49 APPLESEED_DECLARE_APIARRAY(FloatArray, float); 50 APPLESEED_DECLARE_APIARRAY(DoubleArray, double); 51 APPLESEED_DECLARE_APIARRAY(DictionaryArray, Dictionary); 52 53 54 // 55 // An array of strings that can be passed safely across DLL boundaries. 56 // 57 // The interface and implementation of this class both differ slightly 58 // from what APPLESEED_DECLARE_APIARRAY and APPLESEED_DEFINE_APIARRAY offer. 59 // 60 61 class APPLESEED_DLLSYMBOL StringArray 62 { 63 public: 64 // Types. 65 typedef const char* value_type; 66 typedef size_t size_type; 67 68 // Constructors. 69 StringArray(); 70 StringArray(const StringArray& rhs); 71 StringArray( 72 const size_type size, 73 const value_type* values); 74 75 // Destructor. 76 ~StringArray(); 77 78 // Assignment operator. 79 StringArray& operator=(const StringArray& rhs); 80 81 // Returns the size of the vector. 82 size_type size() const; 83 84 // Tests if the vector is empty. 85 bool empty() const; 86 87 // Clears the vector. 88 void clear(); 89 90 // Reserves memory for a given number of elements. 91 void reserve(const size_type count); 92 93 // Specifies a new size for a vector. 94 void resize(const size_type new_size); 95 96 // Adds an element to the end of the vector. 97 void push_back(const value_type val); 98 99 // Set the vector element at a specified position. 100 void set(const size_type pos, const value_type val); 101 102 // Returns the vector element at a specified position. 103 value_type operator[](const size_type pos) const; 104 105 private: 106 struct Impl; 107 Impl* impl; 108 }; 109 110 } // namespace foundation 111