Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkStringsToNumbers.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkStringsToNumbers_h
14 #define mitkStringsToNumbers_h
15 
16 #include <mitkLexicalCast.h>
17 
18 namespace mitk
19 {
57  template <typename NUMBER_TYPE, typename STRING_ARRAY, typename DOUBLE_ARRAY>
58  void StringsToNumbers(unsigned int count, const STRING_ARRAY &strings, DOUBLE_ARRAY &numbers)
59  {
60  for (unsigned int i = 0; i < count; ++i)
61  {
62  numbers[i] = boost::lexical_cast<NUMBER_TYPE>(strings[i]);
63  }
64  }
65 }
66 
67 #endif
Provides a robust lexical cast from strings to numeric types with a fallback for edge-case values.
Find image slices visible on a given plane.
void StringsToNumbers(unsigned int count, const STRING_ARRAY &strings, DOUBLE_ARRAY &numbers)
Converts an array of string representations to an array of numeric values.