File: FormatsC.cpp

package info (click to toggle)
soapysdr 0.8.1-7
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 948 kB
  • sloc: cpp: 5,378; ansic: 471; python: 311; sh: 21; makefile: 18
file content (23 lines) | stat: -rw-r--r-- 496 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (c) 2015-2015 Josh Blum
// SPDX-License-Identifier: BSL-1.0

#include <SoapySDR/Formats.h>
#include <cctype>

extern "C" {

size_t SoapySDR_formatToSize(const char *format)
{
    size_t size = 0;
    size_t isComplex = false;
    char ch = 0;
    while ((ch = *format++) != '\0')
    {
        if (ch == 'C') isComplex = true;
        if (std::isdigit(ch)) size = (size*10) + size_t(ch-'0');
    }
    if (isComplex) size *= 2;
    return size / 8; //bits to bytes
}

} //extern "C"