sway/include/util.h

38 lines
868 B
C
Raw Normal View History

2015-08-25 17:53:59 +00:00
#ifndef _SWAY_UTIL_H
#define _SWAY_UTIL_H
#include <stdint.h>
#include <stdbool.h>
2015-08-25 13:17:18 +00:00
/**
* Wrap i into the range [0, max[
*/
int wrap(int i, int max);
2015-08-25 17:53:59 +00:00
/**
* Count number of digits in int, including '-' sign if there is one
*/
int numlen(int n);
/**
* Given a string that represents an RGB(A) color, return a uint32_t
* version of the color.
*/
uint32_t parse_color(const char *color);
/**
* Given a string that represents a boolean, return the boolean value. This
* function also takes in the current boolean value to support toggling. If
* toggling is not desired, pass in true for current so that toggling values
* get parsed as not true.
*/
2018-07-23 20:22:09 +00:00
bool parse_boolean(const char *boolean, bool current);
2018-11-17 19:31:33 +00:00
/**
* Given a string that represents a floating point value, return a float.
* Returns NAN on error.
*/
float parse_float(const char *value);
2015-08-25 17:53:59 +00:00
#endif