SIMLIB/C++
3.09
Toggle main menu visibility
Loading...
Searching...
No Matches
src
name.cc
Go to the documentation of this file.
1
/////////////////////////////////////////////////////////////////////////////
2
//! \file name.cc object-name relation
3
//
4
// Copyright (c) 1991-2004 Petr Peringer
5
//
6
// This library is licensed under GNU Library GPL. See the file COPYING.
7
//
8
9
//
10
// All SimObject instance can have name associated.
11
// Exported functions:
12
//
13
// void SetName(SimObject *o, char *name) -- name of object o
14
// void SetName(SimObject &o, char *name)
15
// void RemoveName(SimObject *o) -- remove name of o
16
// void RemoveName(SimObject &o)
17
// const char *GetName(SimObject *o) -- get name of o
18
// const char *GetName(SimObject &o)
19
//
20
21
22
////////////////////////////////////////////////////////////////////////////
23
// interface
24
//
25
26
#include "
simlib.h
"
27
#include "
internal.h
"
28
29
////////////////////////////////////////////////////////////////////////////
30
// implementation
31
//
32
33
#include <cstdarg>
// ...
34
#include <cstdio>
// vsprintf()
35
36
namespace
simlib3
{
37
38
SIMLIB_IMPLEMENTATION
;
39
40
/////////////////////////////////////////////////////////////////////////////
41
/// assign name to object
42
void
SetName
(
SimObject
& o,
const
std::string &name)
43
{
44
o.
SetName
(name);
45
}
46
47
/// assign name to object
48
void
SetName
(
SimObject
* o,
const
std::string &name)
49
{
50
o->
SetName
(name);
51
}
52
53
/// remove name
54
void
RemoveName
(
SimObject
& o)
55
{
56
o.
SetName
(0);
57
}
58
59
/// remove name
60
void
RemoveName
(
SimObject
* o)
61
{
62
o->
SetName
(0);
63
}
64
65
/// get name of object
66
std::string
GetName
(
SimObject
& o)
67
{
68
return
o.
Name
();
69
}
70
71
/// get name of object
72
std::string
GetName
(
SimObject
* o)
73
{
74
return
o->
Name
();
75
}
76
77
/// printf-like function to create temporary name
78
/// (the length of temporary names is limited)
79
/// <br> used only for printing
80
std::string
SIMLIB_create_tmp_name
(
const
char
*fmt, ...)
81
{
82
static
char
s[256];
83
va_list va;
84
va_start(va, fmt);
85
vsnprintf(s,
sizeof
(s), fmt, va);
86
va_end(va);
87
return
s;
88
}
89
90
}
// namespace
91
simlib3::SimObject
Base class for almost all SIMLIB classes.
Definition
simlib.h:304
simlib3::SimObject::SetName
void SetName(const std::string &name)
assign the name
Definition
object.cc:125
simlib3::SimObject::Name
virtual std::string Name() const
get object name
Definition
object.cc:134
internal.h
Internal header file for SIMLIB/C++.
simlib3
Implementation of class CalendarList interface is static - using global functions in SQS namespace.
Definition
algloop.cc:32
simlib3::GetName
std::string GetName(SimObject &o)
get name of object
Definition
name.cc:66
simlib3::SIMLIB_IMPLEMENTATION
SIMLIB_IMPLEMENTATION
Definition
algloop.cc:34
simlib3::SIMLIB_create_tmp_name
std::string SIMLIB_create_tmp_name(const char *fmt,...)
printf-like function to create temporary name (the length of temporary names is limited) used only ...
Definition
name.cc:80
simlib3::RemoveName
void RemoveName(SimObject &o)
remove name
Definition
name.cc:54
simlib3::SetName
void SetName(SimObject &o, const std::string &name)
assign name to object
Definition
name.cc:42
simlib.h
Main SIMLIB/C++ interface.
Generated on
for SIMLIB/C++ by
1.18.0