YetAnotherCoupler 3.5.2
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
8#include "location.h"
9#include "utils_common.h"
10
13 {{.name = "CELL", .type = YAC_LOC_CELL},
14 {.name = "CORNER", .type = YAC_LOC_CORNER},
15 {.name = "EDGE", .type = YAC_LOC_EDGE},
16 {.name = "UNDEFINED", .type = YAC_LOC_UNDEFINED}};
20
21enum yac_location yac_str2loc(char const * location_str) {
22
23 int location =
26
27 YAC_ASSERT(location != INT_MAX, "ERROR(yac_str2loc): invalid location")
28
29 return (enum yac_location)location;
30}
31
32char const * yac_loc2str(enum yac_location location) {
33
34 char const * location_str =
37 YAC_ASSERT(location_str,
38 "ERROR(yac_loc2str): location must be one of "
39 "YAC_LOC_CORNER/YAC_LOC_EDGE/YAC_LOC_CELL/YAC_LOC_UNDEFINED.")
40
41 return location_str;
42}
43
44enum yac_location yac_get_location(int const location) {
45
47 (location == YAC_LOC_CELL) || (location == YAC_LOC_CORNER) ||
48 (location == YAC_LOC_EDGE) || (location == YAC_LOC_UNDEFINED),
49 "ERROR(get_location): location must be one of "
50 "YAC_LOC_CORNER/YAC_LOC_EDGE/YAC_LOC_CELL/YAC_LOC_UNDEFINED.")
51
52 return (enum yac_location) location;
53}
@ YAC_LOCATION_COUNT
Definition location.c:17
enum yac_location yac_str2loc(char const *location_str)
Definition location.c:21
char const * yac_loc2str(enum yac_location location)
Definition location.c:32
enum yac_location yac_get_location(int const location)
Definition location.c:44
struct yac_name_type_pair yac_location_name_type_pair[]
Definition location.c:12
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
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
#define YAC_ASSERT(exp, msg)
Definition yac_assert.h:16