Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix coding error #17

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions mdflibrary/MdfAttachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <msclr/marshal_cppstd.h>

#include "MdfAttachment.h"
#include "mdflibrary.h"

using namespace msclr::interop;
using namespace System;
Expand Down Expand Up @@ -54,16 +55,15 @@ String^ MdfAttachment::Md5::get() {
if (attachment_ == nullptr) {
return gcnew String("");
}
const std::string temp = attachment_->Md5().has_value() ?
attachment_->Md5().value() : std::string();
return gcnew String(temp.c_str());

return attachment_->Md5().has_value()
? MdfLibrary::Utf8Conversion(
attachment_->Md5().value()) : gcnew String("");
}

String^ MdfAttachment::Filename::get() {
const std::string temp = attachment_ != nullptr ?
attachment_->FileName() : std::string();
return gcnew String(temp.c_str());
return attachment_ != nullptr ? MdfLibrary::Utf8Conversion(
attachment_->FileName()) : gcnew String("");
}

void MdfAttachment::Filename::set(String^ filename) {
Expand All @@ -75,9 +75,8 @@ void MdfAttachment::Filename::set(String^ filename) {
}

String^ MdfAttachment::FileType::get() {
const std::string temp = attachment_ != nullptr ?
attachment_->FileType() : std::string();
return gcnew String(temp.c_str());
return attachment_ != nullptr ? MdfLibrary::Utf8Conversion(
attachment_->FileType()) : gcnew String("");
}

void MdfAttachment::FileType::set(String^ type) {
Expand Down
17 changes: 5 additions & 12 deletions mdflibrary/MdfChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <msclr/marshal_cppstd.h>

#include "MdfChannel.h"
#include "mdflibrary.h"

using namespace msclr::interop;

Expand All @@ -16,9 +17,7 @@ int64_t MdfChannel::Index::get() {
}

String^ MdfChannel::Name::get() {
const auto temp = channel_ != nullptr ?
channel_->Name() : std::string();
return gcnew String(temp.c_str());
return channel_ != nullptr ? MdfLibrary::Utf8Conversion(channel_->Name()) : gcnew String("");
}

void MdfChannel::Name::set(String^ name) {
Expand All @@ -30,9 +29,7 @@ void MdfChannel::Name::set(String^ name) {
}

String^ MdfChannel::DisplayName::get() {
const auto temp = channel_ != nullptr ?
channel_->DisplayName() : std::string();
return gcnew String(temp.c_str());
return channel_ != nullptr ? MdfLibrary::Utf8Conversion(channel_->DisplayName()) : gcnew String("");
}

void MdfChannel::DisplayName::set(String^ name) {
Expand All @@ -44,9 +41,7 @@ void MdfChannel::DisplayName::set(String^ name) {
}

String^ MdfChannel::Description::get() {
const auto temp = channel_ != nullptr ?
channel_->Description() : std::string();
return gcnew String(temp.c_str());
return channel_ != nullptr ? MdfLibrary::Utf8Conversion(channel_->Description()) : gcnew String("");
}

void MdfChannel::Description::set(String^ desc) {
Expand All @@ -62,9 +57,7 @@ bool MdfChannel::UnitUsed::get() {
}

String^ MdfChannel::Unit::get() {
const auto temp = channel_ != nullptr ?
channel_->Unit() : std::string();
return gcnew String(temp.c_str());
return channel_ != nullptr ? MdfLibrary::Utf8Conversion(channel_->Unit()) : gcnew String("");
}

void MdfChannel::Unit::set(String^ unit) {
Expand Down
13 changes: 4 additions & 9 deletions mdflibrary/MdfChannelConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <msclr/marshal_cppstd.h>

#include "MdfChannelConversion.h"
#include "mdflibrary.h"

using namespace msclr::interop;

Expand All @@ -16,9 +17,7 @@ Int64 MdfChannelConversion::Index::get() {
}

String^ MdfChannelConversion::Name::get() {
const auto temp = conversion_ != nullptr ?
conversion_->Name() : std::string();
return gcnew String(temp.c_str());
return conversion_ != nullptr ? MdfLibrary::Utf8Conversion(conversion_->Name()) : gcnew String("");
}

void MdfChannelConversion::Name::set(String^ name) {
Expand All @@ -30,9 +29,7 @@ void MdfChannelConversion::Name::set(String^ name) {
}

String^ MdfChannelConversion::Description::get() {
const auto temp = conversion_ != nullptr ?
conversion_->Description() : std::string();
return gcnew String(temp.c_str());
return conversion_ != nullptr ? MdfLibrary::Utf8Conversion(conversion_->Description()) : gcnew String("");
}
void MdfChannelConversion::Description::set(String^ desc) {
const auto temp = String::IsNullOrEmpty(desc) ?
Expand All @@ -47,9 +44,7 @@ bool MdfChannelConversion::UnitUsed::get() {
}

String^ MdfChannelConversion::Unit::get() {
const auto temp = conversion_ != nullptr ?
conversion_->Unit() : std::string();
return gcnew String(temp.c_str());
return conversion_ != nullptr ? MdfLibrary::Utf8Conversion(conversion_->Unit()) : gcnew String("");
}

void MdfChannelConversion::Unit::set(String^ unit) {
Expand Down
10 changes: 4 additions & 6 deletions mdflibrary/MdfChannelGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <msclr/marshal_cppstd.h>

#include "MdfChannelGroup.h"
#include "mdflibrary.h"

using namespace msclr::interop;

namespace MdfLibrary {
Expand All @@ -24,9 +26,7 @@ void MdfChannelGroup::RecordId::set(uint64_t record_id) {
}

String^ MdfChannelGroup::Name::get() {
const auto temp = group_ != nullptr ?
group_->Name() : std::string();
return gcnew String(temp.c_str());
return group_ != nullptr ? MdfLibrary::Utf8Conversion(group_->Name()) : gcnew String("");
}

void MdfChannelGroup::Name::set(String^ name) {
Expand All @@ -38,9 +38,7 @@ void MdfChannelGroup::Name::set(String^ name) {
}

String^ MdfChannelGroup::Description::get() {
const auto temp = group_ != nullptr ?
group_->Description() : std::string();
return gcnew String(temp.c_str());
return group_ != nullptr ? MdfLibrary::Utf8Conversion(group_->Description()) : gcnew String("");
}

void MdfChannelGroup::Description::set(String^ desc) {
Expand Down
13 changes: 5 additions & 8 deletions mdflibrary/MdfChannelObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <mdf/ichannel.h>

#include "MdfChannelObserver.h"
#include "mdflibrary.h"

using namespace msclr::interop;
using namespace System;
Expand All @@ -24,15 +25,11 @@ size_t MdfChannelObserver::NofSamples::get() {
}

String^ MdfChannelObserver::Name::get() {
const auto temp = observer_ != nullptr ?
observer_->Name() : std::string();
return gcnew String(temp.c_str());
return observer_ != nullptr ? MdfLibrary::Utf8Conversion(observer_->Name()) : gcnew String("");
}

String^ MdfChannelObserver::Unit::get() {
const auto temp = observer_ != nullptr ?
observer_->Unit() : std::string();
return gcnew String(temp.c_str());
return observer_ != nullptr ? MdfLibrary::Utf8Conversion(observer_->Unit()) : gcnew String("");
}

MdfChannel^ MdfChannelObserver::Channel::get() {
Expand Down Expand Up @@ -80,7 +77,7 @@ bool MdfChannelObserver::GetChannelValueAsString(size_t sample,
}
std::string temp;
const auto valid = observer_->GetChannelValue(sample, temp);
value = gcnew String(temp.c_str());
value = MdfLibrary::Utf8Conversion(temp);
return valid;
}

Expand Down Expand Up @@ -130,7 +127,7 @@ bool MdfChannelObserver::GetEngValueAsString(size_t sample, String^% value) {
}
std::string temp;
const auto valid = observer_->GetEngValue(sample, temp);
value = gcnew String(temp.c_str());
value = MdfLibrary::Utf8Conversion(temp);
return valid;
}

Expand Down
7 changes: 4 additions & 3 deletions mdflibrary/MdfDataGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <string>
#include <msclr/marshal_cppstd.h>
#include "MdfDataGroup.h"
#include "mdflibrary.h"

using namespace msclr::interop;

namespace MdfLibrary {
Expand All @@ -14,9 +16,8 @@ int64_t MdfDataGroup::Index::get() {
}

String^ MdfDataGroup::Description::get() {
const auto temp = group_ != nullptr ?
group_->Description() : std::string();
return gcnew String(temp.c_str());
return group_ != nullptr ? MdfLibrary::Utf8Conversion(
group_->Description()) : gcnew String("");
}

void MdfDataGroup::Description::set(String^ desc) {
Expand Down
29 changes: 8 additions & 21 deletions mdflibrary/MdfETag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>
#include <msclr/marshal_cppstd.h>
#include "MdfETag.h"
#include "mdflibrary.h"

using namespace msclr::interop;

Expand All @@ -24,9 +25,7 @@ MdfETag::~MdfETag() {
}

String^ MdfETag::Name::get() {
const auto temp = tag_ != nullptr ?
tag_->Name() : std::string();
return gcnew String(temp.c_str());
return tag_ != nullptr ? MdfLibrary::Utf8Conversion(tag_->Name()) : gcnew String("");
}

void MdfETag::Name::set(String^ name) {
Expand All @@ -38,9 +37,7 @@ void MdfETag::Name::set(String^ name) {
}

String^ MdfETag::Description::get() {
const auto temp = tag_ != nullptr ?
tag_->Description() : std::string();
return gcnew String(temp.c_str());
return tag_ != nullptr ? MdfLibrary::Utf8Conversion(tag_->Description()) : gcnew String("");
}

void MdfETag::Description::set(String^ desc) {
Expand All @@ -52,9 +49,7 @@ void MdfETag::Description::set(String^ desc) {
}

String^ MdfETag::Unit::get() {
const auto temp = tag_ != nullptr ?
tag_->Unit() : std::string();
return gcnew String(temp.c_str());
return tag_ != nullptr ? MdfLibrary::Utf8Conversion(tag_->Unit()) : gcnew String("");
}

void MdfETag::Unit::set(String^ unit) {
Expand All @@ -66,9 +61,7 @@ void MdfETag::Unit::set(String^ unit) {
}

String^ MdfETag::UnitRef::get() {
const auto temp = tag_ != nullptr ?
tag_->UnitRef() : std::string();
return gcnew String(temp.c_str());
return tag_ != nullptr ? MdfLibrary::Utf8Conversion(tag_->UnitRef()) : gcnew String("");
}

void MdfETag::UnitRef::set(String^ unit) {
Expand All @@ -80,9 +73,7 @@ void MdfETag::UnitRef::set(String^ unit) {
}

String^ MdfETag::Type::get() {
const auto temp = tag_ != nullptr ?
tag_->Type() : std::string();
return gcnew String(temp.c_str());
return tag_ != nullptr ? MdfLibrary::Utf8Conversion(tag_->Type()) : gcnew String("");
}

void MdfETag::Type::set(String^ type) {
Expand All @@ -105,9 +96,7 @@ void MdfETag::DataType::set(ETagDataType type) {
}

String^ MdfETag::Language::get() {
const auto temp = tag_ != nullptr ?
tag_->Language() : std::string();
return gcnew String(temp.c_str());
return tag_ != nullptr ? MdfLibrary::Utf8Conversion(tag_->Language()) : gcnew String("");
}

void MdfETag::Language::set(String^ language) {
Expand All @@ -129,9 +118,7 @@ void MdfETag::ReadOnly::set(bool read_only) {
}

String^ MdfETag::ValueAsString::get() {
const auto temp = tag_ != nullptr ?
tag_->Value<std::string>() : std::string();
return gcnew String(temp.c_str());
return tag_ != nullptr ? MdfLibrary::Utf8Conversion(tag_->Value<std::string>()) : gcnew String("");
}

void MdfETag::ValueAsString::set(String^ value) {
Expand Down
14 changes: 5 additions & 9 deletions mdflibrary/MdfEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <msclr/marshal_cppstd.h>

#include "MdfEvent.h"
#include "mdflibrary.h"

using namespace msclr::interop;

namespace MdfLibrary {
Expand All @@ -15,9 +17,7 @@ int64_t MdfEvent::Index::get() {
}

String^ MdfEvent::Name::get() {
const auto temp = event_ != nullptr ?
event_->Name() : std::string();
return gcnew String(temp.c_str());
return event_ != nullptr ? MdfLibrary::Utf8Conversion(event_->Name()) : gcnew String("");
}

void MdfEvent::Name::set(String^ name) {
Expand All @@ -29,9 +29,7 @@ void MdfEvent::Name::set(String^ name) {
}

String^ MdfEvent::Description::get() {
const auto temp = event_ != nullptr ?
event_->Description() : std::string();
return gcnew String(temp.c_str());
return event_ != nullptr ? MdfLibrary::Utf8Conversion(event_->Description()) : gcnew String("");
}

void MdfEvent::Description::set(String^ desc) {
Expand All @@ -43,9 +41,7 @@ void MdfEvent::Description::set(String^ desc) {
}

String^ MdfEvent::Group::get() {
const auto temp = event_ != nullptr ?
event_->GroupName() : std::string();
return gcnew String(temp.c_str());
return event_ != nullptr ? MdfLibrary::Utf8Conversion(event_->GroupName()) : gcnew String("");
}

void MdfEvent::Group::set(String^ group) {
Expand Down
Loading
Loading