YAC 3.15.0
Yet Another Coupler
Loading...
Searching...
No Matches
location.c
Go to the documentation of this file.
1// Copyright (c) 2024 The YAC Authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#include <stdio.h>
6#include <string.h>
7#include <limits.h>
8
9#include "location.h"
10#include "utils_common.h"
11
14 {{.name = "CELL", .type = YAC_LOC_CELL},
15 {.name = "CORNER", .type = YAC_LOC_CORNER},
16 {.name = "EDGE", .type = YAC_LOC_EDGE},
17 {.name = "UNDEFINED", .type = YAC_LOC_UNDEFINED}};
21
22enum yac_location yac_str2loc(char const * location_str) {
23
24 int location =
27
28 YAC_ASSERT(location != INT_MAX, "ERROR(yac_str2loc): invalid location")
29
30 return (enum yac_location)location;
31}
32
33char const * yac_loc2str(enum yac_location location) {
34
35 char const * location_str =
38 YAC_ASSERT(location_str,
39 "ERROR(yac_loc2str): location must be one of "
40 "YAC_LOC_CORNER/YAC_LOC_EDGE/YAC_LOC_CELL/YAC_LOC_UNDEFINED.")
41
42 return location_str;
43}
44
46
50 "ERROR(get_location): location must be one of "
51 "YAC_LOC_CORNER/YAC_LOC_EDGE/YAC_LOC_CELL/YAC_LOC_UNDEFINED.")
52
53 return (enum yac_location) location;
54}
#define YAC_ASSERT(exp, msg)
enum yac_location yac_str2loc(char const *location_str)
Definition location.c:22
@ YAC_LOCATION_COUNT
Definition location.c:18
char const * yac_loc2str(enum yac_location location)
Definition location.c:33
enum yac_location yac_get_location(int const location)
Definition location.c:45
struct yac_name_type_pair yac_location_name_type_pair[]
Definition location.c:13
yac_location
Definition location.h:12
@ YAC_LOC_CORNER
Definition location.h:15
@ YAC_LOC_UNDEFINED
Definition location.h:17
@ YAC_LOC_EDGE
Definition location.h:16
@ YAC_LOC_CELL
Definition location.h:14
const char * name
String name (e.g., "true")
int const * location
int yac_name_type_pair_get_type(struct yac_name_type_pair const *pairs, size_t count, char const *name)
Definition utils_core.c:26
char const * yac_name_type_pair_get_name(struct yac_name_type_pair const *pairs, size_t count, int type)
Definition utils_core.c:17