C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
utility.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2021 Intel Corporation
5
6 This software and the related documents are Intel copyrighted materials, and
7 your use of them is governed by the express license under which they were
8 provided to you ("License"). Unless the License provides otherwise, you may
9 not use, modify, copy, publish, distribute, disclose or transmit this software
10 or the related documents without Intel's prior written permission.
11
12 This software and the related documents are provided as is, with no express or
13 implied warranties, other than those that are expressly stated in the License.
14*/
15
16#ifndef SIMICS_UTILITY_H
17#define SIMICS_UTILITY_H
18
19#include <cstddef> // size_t
20#include <string>
21#include <utility> // pair
22#include <vector>
23
25
26namespace simics {
27
28#if defined SIMICS_6_API || defined SIMICS_7_API
32template <typename IFACE>
33IFACE* get_interface(conf_object_t *obj) {
34 return detail::get_interface<IFACE>(obj);
35}
36#endif
37
49int array_index(const std::string &name);
50
58std::vector<std::string> expand_names(const std::string &name,
59 const char delimiter = '.');
60
65std::pair<size_t, size_t> overlap_range(size_t r1_start,
66 size_t r1_end,
67 size_t r2_start,
68 size_t r2_end);
69
73size_t hash_str(const std::string &name);
74
75} // namespace simics
76
77#endif
IFACE * get_interface(conf_object_t *obj)
Return the Simics C++ interface class from a configuration object.
Definition: conf-object-util.h:30
Definition: after-bank.h:33
std::vector< std::string > expand_names(const std::string &name, const char delimiter='.')
If name contains an array indicator, i.e.
std::pair< size_t, size_t > overlap_range(size_t r1_start, size_t r1_end, size_t r2_start, size_t r2_end)
Given two ranges [r1_start, r1_end) and [r2_start, r2_end), return the overlap range [o_start,...
int array_index(const std::string &name)
This function looks for a pattern in the input string that resembles an array index,...
size_t hash_str(const std::string &name)
Hashes a string to a size_t value.