1 // Copyright (c) 2015-2015 Josh Blum
2 // SPDX-License-Identifier: BSL-1.0
3 
4 #include <SoapySDR/Formats.h>
5 #include <cctype>
6 
7 extern "C" {
8 
SoapySDR_formatToSize(const char * format)9 size_t SoapySDR_formatToSize(const char *format)
10 {
11     size_t size = 0;
12     size_t isComplex = false;
13     char ch = 0;
14     while ((ch = *format++) != '\0')
15     {
16         if (ch == 'C') isComplex = true;
17         if (std::isdigit(ch)) size = (size*10) + size_t(ch-'0');
18     }
19     if (isComplex) size *= 2;
20     return size / 8; //bits to bytes
21 }
22 
23 } //extern "C"
24