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

#include <dds_generator.h>

Collaboration diagram for NestedForLoops:
Collaboration graph
[legend]

Public Member Functions

 NestedForLoops (const char *type, const char *prefix, AST_Array *arr, std::string &indent, bool followTypedefs=false)
 
 ~NestedForLoops ()
 

Public Attributes

size_t n_
 
std::string & indent_
 
std::string index_
 

Detailed Description

Definition at line 449 of file dds_generator.h.

Constructor & Destructor Documentation

◆ NestedForLoops()

NestedForLoops::NestedForLoops ( const char *  type,
const char *  prefix,
AST_Array *  arr,
std::string &  indent,
bool  followTypedefs = false 
)

Definition at line 281 of file dds_generator.cpp.

References be_global, index_, n_, and AstTypeClassification::resolveActualType().

284  : n_(arr->n_dims())
285  , indent_(indent)
286 {
287  std::ostringstream index_oss;
288  size_t i = 0, j = 0;
289  while (true) {
290  for (; i < n_; ++i) {
291  be_global->impl_ <<
292  indent << "for (" << type << ' ' << prefix << i << " = 0; " <<
293  prefix << i << " < " << arr->dims()[i - j]->ev()->u.ulval << "; ++" <<
294  prefix << i << ") {\n";
295  indent += " ";
296  index_oss << "[" << prefix << i << "]";
297  }
298  if (!followTypedefs) {
299  break;
300  }
301  AST_Type* const base =
303  if (base->node_type() == AST_Decl::NT_array) {
304  arr = dynamic_cast<AST_Array*>(base);
305  n_ += arr->n_dims();
306  j = i;
307  } else {
308  break;
309  }
310  }
311  index_ = index_oss.str();
312 }
std::string & indent_
AST_Type * resolveActualType(AST_Type *element)
BE_GlobalData * be_global
Definition: be_global.cpp:43
std::string index_

◆ ~NestedForLoops()

NestedForLoops::~NestedForLoops ( )

Definition at line 314 of file dds_generator.cpp.

References be_global, indent_, and n_.

315 {
316  for (size_t i = 0; i < n_; ++i) {
317  indent_.resize(indent_.size() - 2);
318  be_global->impl_ << indent_ << "}\n";
319  }
320 }
std::string & indent_
BE_GlobalData * be_global
Definition: be_global.cpp:43

Member Data Documentation

◆ indent_

std::string& NestedForLoops::indent_

Definition at line 455 of file dds_generator.h.

Referenced by ~NestedForLoops().

◆ index_

std::string NestedForLoops::index_

◆ n_

size_t NestedForLoops::n_

Definition at line 454 of file dds_generator.h.

Referenced by NestedForLoops(), and ~NestedForLoops().


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