Skip to content

Commit

Permalink
fix problems with auto & not creating references in clang, remove ref…
Browse files Browse the repository at this point in the history
…erences to shared pointers
  • Loading branch information
carltimmer committed Aug 27, 2024
1 parent 39f53de commit 9fb3304
Show file tree
Hide file tree
Showing 23 changed files with 142 additions and 142 deletions.
10 changes: 5 additions & 5 deletions src/libsrc++/BaseStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ namespace evio {
* Get the children of this structure.
* @return the children of this structure.
*/
std::vector<std::shared_ptr<BaseStructure>> BaseStructure::getChildren() const {return children;}
std::vector<std::shared_ptr<BaseStructure>> & BaseStructure::getChildren() {return children;}


/**
Expand Down Expand Up @@ -1642,7 +1642,7 @@ namespace evio {

// Special cases:
if (type == DataType::CHARSTAR8) {
auto sd = getStringData();
auto & sd = getStringData();
numberDataItems = sd.size();
}
else if (type == DataType::COMPOSITE) {
Expand Down Expand Up @@ -2644,15 +2644,15 @@ namespace evio {
uint32_t BaseStructure::setAllHeaderLengths() {
// if length info is current, don't bother to recalculate it
if (lengthsUpToDate) {
return header->getLength();
return header->getLength();
}

uint32_t datalen, len;

if (isLeaf()) {
// # of 32 bit ints for leaves, 0 for empty containers (also considered leaves)
datalen = dataLength();
//std::cout << " setAllHeaderLengths: is leaf, len = " << datalen << "\n";
//std::cout << " setAllHeaderLengths: is leaf, len = " << datalen << "\n";
}
else {
datalen = 0;
Expand All @@ -2678,7 +2678,7 @@ namespace evio {

// set the datalen for the header

//std::cout << "setAllHeaderLengths: set data type " << header->getDataTypeName() <<
//std::cout << " setAllHeaderLengths: set data type " << header->getDataTypeName() <<
// " to len = " << datalen << "\n";

header->setLength(datalen);
Expand Down
2 changes: 1 addition & 1 deletion src/libsrc++/BaseStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ namespace evio {
void remove(size_t childIndex);

std::shared_ptr<BaseStructure> getParent() const;
std::vector<std::shared_ptr<BaseStructure>> getChildren() const;
std::vector<std::shared_ptr<BaseStructure>> & getChildren();
std::shared_ptr<BaseStructure> getChildAt(size_t index) const;

size_t getChildCount() const;
Expand Down
2 changes: 1 addition & 1 deletion src/libsrc++/CompactEventBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ namespace evio {
// Does this node contain other containers?
if (node->getDataTypeObj().isStructure()) {
// Iterate through list of children
auto kids = node->getChildNodes();
auto & kids = node->getChildNodes();
if (kids.empty()) return;
for (auto child : kids) {
writeNode(child, swapData);
Expand Down
2 changes: 1 addition & 1 deletion src/libsrc++/CompositeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3226,7 +3226,7 @@ namespace evio {
else if (typ == DataType::CHARSTAR8) {
ss << "a=" << getFloat();

auto strs = getStrings();
auto & strs = getStrings();
for (int j=0; j < strs.size(); j++) {
ss << strs[j];
if (j < strs.size() - 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/libsrc++/Compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ uint8_t* Compressor::uncompressGZIP(uint8_t* gzipped, uint32_t off,
}

uint32_t destLen = *uncompLen;
auto ungzipped = new uint8_t[destLen];
auto *ungzipped = new uint8_t[destLen];

int err = uncompressGZIP(ungzipped, &destLen, gzipped + off, &length, origUncompLen);
if (err != Z_OK) {
Expand Down Expand Up @@ -462,7 +462,7 @@ uint8_t* Compressor::uncompressGZIP(ByteBuffer & gzipped, uint32_t * uncompLen)

// Max length of uncompressed data.
uint32_t dstLen = *uncompLen;
auto ungzipped = new uint8_t[dstLen];
auto *ungzipped = new uint8_t[dstLen];

int err = uncompressGZIP(ungzipped, &dstLen,
gzipped.array() + gzipped.arrayOffset() + gzipped.position(),
Expand Down
48 changes: 24 additions & 24 deletions src/libsrc++/EventBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::INT32);

auto vect = structure->getIntData();
auto & vect = structure->getIntData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -187,7 +187,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::UINT32);

auto vect = structure->getUIntData();
auto & vect = structure->getUIntData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -212,7 +212,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::SHORT16);

auto vect = structure->getShortData();
auto & vect = structure->getShortData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -237,7 +237,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::USHORT16);

auto vect = structure->getUShortData();
auto & vect = structure->getUShortData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -262,7 +262,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::LONG64);

auto vect = structure->getLongData();
auto & vect = structure->getLongData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -287,7 +287,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::ULONG64);

auto vect = structure->getULongData();
auto & vect = structure->getULongData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -312,7 +312,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::CHAR8);

auto vect = structure->getCharData();
auto & vect = structure->getCharData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -337,7 +337,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::UCHAR8);

auto vect = structure->getUCharData();
auto & vect = structure->getUCharData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -362,7 +362,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::FLOAT32);

auto vect = structure->getFloatData();
auto & vect = structure->getFloatData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -387,7 +387,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::DOUBLE64);

auto vect = structure->getDoubleData();
auto & vect = structure->getDoubleData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -412,7 +412,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::CHARSTAR8);

auto vect = structure->getStringData();
auto & vect = structure->getStringData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand All @@ -438,7 +438,7 @@ namespace evio {

structure->getHeader()->setDataType(DataType::COMPOSITE);

auto vect = structure->getCompositeData();
auto & vect = structure->getCompositeData();
vect.clear();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
Expand Down Expand Up @@ -469,7 +469,7 @@ namespace evio {
structure->getHeader()->getDataType().getName());
}

auto vect = structure->getIntData();
auto & vect = structure->getIntData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -495,7 +495,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getUIntData();
auto & vect = structure->getUIntData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -521,7 +521,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getShortData();
auto & vect = structure->getShortData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -547,7 +547,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getUShortData();
auto & vect = structure->getUShortData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -573,7 +573,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getLongData();
auto & vect = structure->getLongData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -599,7 +599,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getULongData();
auto & vect = structure->getULongData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -625,7 +625,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getCharData();
auto & vect = structure->getCharData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -651,7 +651,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getUCharData();
auto & vect = structure->getUCharData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -677,7 +677,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getFloatData();
auto & vect = structure->getFloatData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -703,7 +703,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getDoubleData();
auto & vect = structure->getDoubleData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand All @@ -729,7 +729,7 @@ namespace evio {
throw EvioException("cannot append ints to structure of type " + structure->getHeader()->getDataType().getName());
}

auto vect = structure->getStringData();
auto & vect = structure->getStringData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand Down Expand Up @@ -757,7 +757,7 @@ namespace evio {
structure->getHeader()->getDataType().getName());
}

auto vect = structure->getCompositeData();
auto & vect = structure->getCompositeData();
for (int i=0; i < count; i++) {
vect.push_back(data[i]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsrc++/EventParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace evio {
// Does the present structure contain structures? (as opposed to a leaf, which contains primitives). If
// it is a leaf we are done. That will leave the raw bytes in the "leaf" structures (e.g., a bank of ints)
// --which will be interpreted by the various "get data" methods.
auto bytes = structure->getRawBytes();
auto & bytes = structure->getRawBytes();
ByteOrder byteOrder = structure->getByteOrder();

if (bytes.empty()) {
Expand Down Expand Up @@ -225,7 +225,7 @@ namespace evio {
// Does the present structure contain structures? (as opposed to a leaf, which contains primitives). If
// it is a leaf we are done. That will leave the raw bytes in the "leaf" structures (e.g., a bank of ints)
// --which will be interpreted by the various "get data" methods.
auto bytes = structure->getRawBytes();
auto & bytes = structure->getRawBytes();
ByteOrder byteOrder = structure->getByteOrder();

if (bytes.empty()) {
Expand Down
Loading

0 comments on commit 9fb3304

Please sign in to comment.