CBMC
format_number_range.cpp File Reference

Format vector of numbers into a compressed range. More...

#include <algorithm>
#include <sstream>
#include <string>
#include "exception_utils.h"
#include "invariant.h"
#include "format_number_range.h"
+ Include dependency graph for format_number_range.cpp:

Go to the source code of this file.

Functions

std::string format_number_range (const std::vector< mp_integer > &input_numbers)
 create shorter representation for output More...
 
static void append_numbers (const std::string &number_range, std::vector< mp_integer > &numbers, bool last_number_is_set, bool is_range)
 Appends number resp. numbers begin_range ... number to numbers. More...
 
std::vector< mp_integerparse_number_range (const std::string &number_range)
 Parse a compressed range into a vector of numbers, e.g. More...
 

Detailed Description

Format vector of numbers into a compressed range.

Definition in file format_number_range.cpp.

Function Documentation

◆ append_numbers()

static void append_numbers ( const std::string &  number_range,
std::vector< mp_integer > &  numbers,
bool  last_number_is_set,
bool  is_range 
)
static

Appends number resp. numbers begin_range ... number to numbers.

Definition at line 74 of file format_number_range.cpp.

◆ format_number_range()

std::string format_number_range ( const std::vector< mp_integer > &  input_numbers)

create shorter representation for output

Parameters
input_numbersvector of numbers
Returns
string of compressed number range representation

Definition at line 24 of file format_number_range.cpp.

◆ parse_number_range()

std::vector<mp_integer> parse_number_range ( const std::string &  number_range)

Parse a compressed range into a vector of numbers, e.g.

"2,4-6" -> [2,4,5,6]

Definition at line 113 of file format_number_range.cpp.