Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / APG / Naming / Naming_Context.h
blobab178c4e57887976dcfac6b10e8d73b2577c3806
1 /* -*- C++ -*- */
2 #ifndef NAMING_CONTEXT_H
3 #define NAMING_CONTEXT_H
5 #include "ace/Naming_Context.h"
6 #include "ace/OS_NS_stdio.h"
7 #include "Name_Binding.h"
9 // Listing 1 code/ch21
10 class Naming_Context : public ACE_Naming_Context
12 public:
13 typedef ACE_Naming_Context inherited;
15 int rebind (const char *name_in,
16 const char *value_in,
17 const char *type_in = "")
19 return this->inherited::rebind (name_in, value_in, type_in);
22 int rebind (const char *name_in,
23 float value_in,
24 const char *type_in = "")
26 char buf[BUFSIZ];
27 ACE_OS::sprintf (buf, "%2f", value_in);
28 return this->inherited::rebind (name_in,
29 (const char *)buf,
30 type_in);
33 int rebind (const char *name_in,
34 int value_in,
35 const char *type_in = "")
37 char buf[BUFSIZ];
38 ACE_OS::sprintf (buf, "%d", value_in );
39 return this->inherited::rebind (name_in,
40 (const char *)buf,
41 type_in);
43 // Listing 1
45 // Listing 2 code/ch21
46 Name_Binding *fetch (const char *name)
48 ACE_NS_WString value;
49 char *type = 0;
51 if (this->resolve (name, value, type) != 0 ||
52 value.length () < 1)
54 return 0;
57 Name_Binding *rval =
58 new Name_Binding (ACE_NS_WString (name),
59 value,
60 type);
61 delete [] type;
63 return rval;
65 // Listing 2
68 #endif /* NAMING_CONTEXT_H */