OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Public Attributes | List of all members
NamespaceGuard Struct Reference

#include <dds_generator.h>

Collaboration diagram for NamespaceGuard:
Collaboration graph
[legend]

Public Member Functions

 NamespaceGuard (bool enabled=true, std::vector< std::string > *ns=0)
 
 ~NamespaceGuard ()
 

Public Attributes

const bool enabled_
 
std::vector< std::string > * ns_
 
std::vector< std::string > default_ns_
 

Detailed Description

Definition at line 186 of file dds_generator.h.

Constructor & Destructor Documentation

◆ NamespaceGuard()

NamespaceGuard::NamespaceGuard ( bool  enabled = true,
std::vector< std::string > *  ns = 0 
)
inline

Definition at line 191 of file dds_generator.h.

References be_global.

192  : enabled_(enabled)
193  , ns_(ns)
194  {
195  if (!ns_) {
196  default_ns_.push_back("OpenDDS");
197  default_ns_.push_back("DCPS");
198  ns_ = &default_ns_;
199  }
200  if (enabled_) {
201  std::string start_ns = "OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL\n";
202  for (size_t i = 0; i < ns_->size(); ++i) {
203  if (i > 0) {
204  start_ns += " ";
205  }
206  start_ns += "namespace " + (*ns_)[i] + " {";
207  }
208  start_ns += "\n\n";
209  be_global->header_ << start_ns;
210  be_global->impl_ << start_ns;
211  }
212  }
const bool enabled_
std::vector< std::string > * ns_
std::vector< std::string > default_ns_
BE_GlobalData * be_global
Definition: be_global.cpp:44

◆ ~NamespaceGuard()

NamespaceGuard::~NamespaceGuard ( )
inline

Definition at line 214 of file dds_generator.h.

References be_global.

215  {
216  if (enabled_) {
217  std::string end_ns;
218  for (size_t i = 0; i < ns_->size(); ++i) {
219  if (i > 0) {
220  end_ns += " ";
221  }
222  end_ns += "}";
223  }
224  end_ns += "\nOPENDDS_END_VERSIONED_NAMESPACE_DECL\n\n";
225  be_global->header_ << end_ns;
226  be_global->impl_ << end_ns;
227  }
228  }
const bool enabled_
std::vector< std::string > * ns_
BE_GlobalData * be_global
Definition: be_global.cpp:44

Member Data Documentation

◆ default_ns_

std::vector<std::string> NamespaceGuard::default_ns_

Definition at line 189 of file dds_generator.h.

◆ enabled_

const bool NamespaceGuard::enabled_

Definition at line 187 of file dds_generator.h.

◆ ns_

std::vector<std::string>* NamespaceGuard::ns_

Definition at line 188 of file dds_generator.h.


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