1 /* 2 * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <Architecture.h> 8 9 #include <algorithm> 10 11 #include <StringList.h> 12 13 14 static const size_t kMaxArchitectureCount = 16; 15 16 17 static status_t 18 string_array_to_string_list(const char* const* architectures, size_t count, 19 BStringList& _architectures) 20 { 21 _architectures.MakeEmpty(); 22 23 for (size_t i = 0; i < count; i++) { 24 BString architecture(architectures[i]); 25 if (architecture.IsEmpty() || !_architectures.Add(architecture)) { 26 _architectures.MakeEmpty(); 27 return B_NO_MEMORY; 28 } 29 } 30 31 return B_OK; 32 } 33 34 35 status_t 36 get_secondary_architectures(BStringList& _architectures) 37 { 38 const char* architectures[kMaxArchitectureCount]; 39 size_t count = get_secondary_architectures(architectures, 40 kMaxArchitectureCount); 41 return string_array_to_string_list(architectures, 42 std::min(count, kMaxArchitectureCount), _architectures); 43 } 44 45 46 status_t 47 get_architectures(BStringList& _architectures) 48 { 49 const char* architectures[kMaxArchitectureCount]; 50 size_t count = get_architectures(architectures, kMaxArchitectureCount); 51 return string_array_to_string_list(architectures, 52 std::min(count, kMaxArchitectureCount), _architectures); 53 } 54