OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | Public Attributes | List of all members
ScopedNamespaceGuard Struct Reference

#include <dds_generator.h>

Collaboration diagram for ScopedNamespaceGuard:
Collaboration graph
[legend]

Public Member Functions

 ScopedNamespaceGuard (UTL_ScopedName *name, std::ostream &os, const char *keyword="namespace")
 
 ~ScopedNamespaceGuard ()
 

Public Attributes

std::ostreamos_
 
std::string semi_
 
int n_
 

Detailed Description

Definition at line 213 of file dds_generator.h.

Constructor & Destructor Documentation

◆ ScopedNamespaceGuard()

ScopedNamespaceGuard::ScopedNamespaceGuard ( UTL_ScopedName *  name,
std::ostream os,
const char *  keyword = "namespace" 
)
inline

Definition at line 214 of file dds_generator.h.

References EscapeContext_ForGenIdl, EscapeContext_Normal, os_, and dds_generator::to_string().

216  : os_(os)
217  , semi_()
218  , n_(0)
219  {
220  const bool idl = !std::strcmp(keyword, "module");
222  for (n_ = 0; name->tail();
223  name = static_cast<UTL_ScopedName*>(name->tail())) {
224  const char* str = name->head()->get_string();
225  if (str && str[0]) {
226  ++n_;
227  os_ << keyword << ' ' << dds_generator::to_string(name->head(), ec) << " {\n";
228  }
229  }
230  if (idl) semi_ = ";";
231  }
static std::string to_string(Identifier *id, EscapeContext ec=EscapeContext_Normal)
std::ostream & os_
This is for generated IDL. (Like *TypeSupport.idl)
Definition: dds_generator.h:39
This is for everything else.
Definition: dds_generator.h:45
EscapeContext
Definition: dds_generator.h:37
const char *const name
Definition: debug.cpp:60

◆ ~ScopedNamespaceGuard()

ScopedNamespaceGuard::~ScopedNamespaceGuard ( )
inline

Definition at line 233 of file dds_generator.h.

References os_.

234  {
235  for (int i = 0; i < n_; ++i) os_ << '}' << semi_ << '\n';
236  }
std::ostream & os_

Member Data Documentation

◆ n_

int ScopedNamespaceGuard::n_

Definition at line 240 of file dds_generator.h.

◆ os_

std::ostream& ScopedNamespaceGuard::os_

Definition at line 238 of file dds_generator.h.

◆ semi_

std::string ScopedNamespaceGuard::semi_

Definition at line 239 of file dds_generator.h.


The documentation for this struct was generated from the following file: