]> git.vomp.tv Git - vompclient.git/commitdiff
Switch Channel to std::string
authorChris Tallon <chris@vomp.tv>
Thu, 18 Nov 2021 16:42:05 +0000 (16:42 +0000)
committerChris Tallon <chris@vomp.tv>
Thu, 18 Nov 2021 16:42:05 +0000 (16:42 +0000)
boxx.cc
boxx.h
channel.cc
channel.h
demuxerts.cc
vchannellist.cc
vepglistadvanced.cc
wtextbox.cc
wtextbox.h

diff --git a/boxx.cc b/boxx.cc
index 342f64c68cf7410cf3a9d6ba78fd985d04e89e27..37362493ed651697b4ea42dc272ceb2dc047506c 100644 (file)
--- a/boxx.cc
+++ b/boxx.cc
@@ -449,6 +449,34 @@ void Boxx::drawTextCentre(const char* text, int x, int y, const DrawStyle& colou
   if (parent) parent->drawTextCentre(text, area.x + x, area.y + y, colour);
   else  surface->drawTextCentre(text, x, y, colour);
 }
+
+// std::string versions - the switch back to const char* is currently here
+
+void Boxx::drawText(const std::string& text, int x, int y, const DrawStyle& colour)
+{
+  if (parent) parent->drawText(text.c_str(), area.x + x, area.y + y, colour);
+  else surface->drawText(text.c_str(), x, y, colour);
+}
+
+void Boxx::drawText(const std::string& text, int x, int y, int width, const DrawStyle& colour)
+{
+  if (parent) parent->drawText(text.c_str(), area.x + x, area.y + y, width, colour);
+  else surface->drawText(text.c_str(), x, y, width, colour);
+}
+
+void Boxx::drawTextRJ(const std::string& text, int x, int y, const DrawStyle& colour)
+{
+  if (parent) parent->drawTextRJ(text.c_str(), area.x + x, area.y + y, colour);
+  else surface->drawTextRJ(text.c_str(), x, y, colour);
+}
+
+void Boxx::drawTextCentre(const std::string& text, int x, int y, const DrawStyle& colour)
+{
+  if (parent) parent->drawTextCentre(text.c_str(), area.x + x, area.y + y, colour);
+  else  surface->drawTextCentre(text.c_str(), x, y, colour);
+}
+
+
 // Now deprecated
 /*
 void Boxx::drawPixelAlpha(UINT x, UINT y, const Colour& colour,bool fastdraw)
diff --git a/boxx.h b/boxx.h
index da15523185bc44894fbb52e4e21474bec6dc15d5..0c1b216019ab24e280fe136814391c285fddb107 100644 (file)
--- a/boxx.h
+++ b/boxx.h
@@ -101,6 +101,11 @@ class Boxx
     void drawText(const char* text, int x, int y, int width, const DrawStyle& colour);
     void drawTextRJ(const char* text, int x, int y, const DrawStyle& colour);
     void drawTextCentre(const char* text, int x, int y, const DrawStyle& colour);
+    // std::string versions
+    void drawText(const std::string& text, int x, int y, const DrawStyle& colour);
+    void drawText(const std::string& text, int x, int y, int width, const DrawStyle& colour);
+    void drawTextRJ(const std::string& text, int x, int y, const DrawStyle& colour);
+    void drawTextCentre(const std::string& text, int x, int y, const DrawStyle& colour);
     //Now deprecated
     //void drawPixel(UINT x, UINT y, const Colour& colour, bool fastdraw=false);
     void drawBitmap(UINT x, UINT y, const Bitmap& bm, const DisplayRegion& region);
index 148f4e9a40fe9e252d2cbb62193aea6fbae926b1..8e6f22f1c4bf358ef0a27a737e237fa3d66faa2f 100644 (file)
 
 static const char* TAG = "Channel";
 
-Channel::Channel()
-{
-}
-
-Channel::~Channel()
-{
-  if (name) delete[] name;
-  index = -1; // just in case
-}
-
 void Channel::loadPids()
 {
   // Clear the list if this is a reload
index d6d33264e24bb169c6ee5b3176232516dce1696b..1825400098043a7674982738312d8d2885773d5e 100644 (file)
--- a/channel.h
+++ b/channel.h
@@ -20,8 +20,8 @@
 #ifndef CHANNEL_H
 #define CHANNEL_H
 
-#include <stdio.h>
 #include <vector>
+#include <string>
 
 #include "defines.h"
 
@@ -41,17 +41,13 @@ typedef std::vector<apid> APidList;
 class Channel
 {
   public:
-    Channel();
-    ~Channel();
-
     void loadPids();
 
     int index{-1};
     ULONG number{};
     ULONG type{};
     UCHAR vstreamtype{2}; //Mpeg2
-    char* name{};
-
+    std::string name;
 
     ULONG vpid{};
     ULONG numAPids{};
index 3aff0c19ba5696758d7777e2fa57205d1c26594e..be4a0caf1b2914bc954a62bac120cd5cf04129cd 100644 (file)
@@ -378,7 +378,6 @@ int DemuxerTS::processTS(UCHAR* buf)
         new_channelinfo.numSPids=0;
         new_channelinfo.number=0;
         new_channelinfo.type=VDR::RADIO;
-        new_channelinfo.name=NULL;
         new_channelinfo.tpid=0xFFFFF; //unused, check this
         new_channelinfo.vpid=0xFFFFF; //unused, check this
         new_channelinfo.index=0;
index 4783434fb2a953d13a68b01a46d71d4832641630..3061fd3129072927fcd2ebf69313f6e7b8f9fa5b 100644 (file)
@@ -81,7 +81,6 @@ VChannelList::~VChannelList()
 
 void VChannelList::setList(std::shared_ptr<ChannelList> tlist)
 {
-  char str[500];
   OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
 
   sl.addColumn(0);
@@ -98,7 +97,9 @@ void VChannelList::setList(std::shared_ptr<ChannelList> tlist)
     for (UINT i = 0; i < chanList->size(); i++)
     {
       chan = (*chanList)[i];
-      sprintf(str, "%lu\t%s", chan->number, chan->name);
+      //sprintf(str, "%lu\t%s", chan->number, chan->name);
+      std::ostringstream os;
+      os << chan->number << '\t' << chan->name;
       TVMediaInfo *info=NULL;
       if (osdv) {
          info= new TVMediaInfo();
@@ -106,7 +107,7 @@ void VChannelList::setList(std::shared_ptr<ChannelList> tlist)
          if (type == VDR::VIDEO) info->setStaticFallback(sa_tv);
          else info->setStaticFallback(sa_radio);
       }
-      chan->index = sl.addOption(str, chan, first, info);
+      chan->index = sl.addOption(os.str(), chan, first, info);
       first = 0;
     }
   }
index d57c2967ea41fb1bacd0e0977363e8e23460462a..dea8b6bb11ae3f1fd18ce307c363e0fc4ef9dc2e 100644 (file)
@@ -639,7 +639,7 @@ void VEpgListAdvanced::draw(bool doIndexPop)
         if (chan->number == channelNumber) break;
       }
 
-      sprintf(tempA, tr("Schedule - %s"), (*chanList)[listIndex]->name);
+      sprintf(tempA, tr("Schedule - %s"), (*chanList)[listIndex]->name.c_str());
       setTitleText(tempA);
       break;
     }
index 33464b1c53b898c72acbad860d97169762ea7cb3..8640c21f8335da8bdf908cfa53969e4f155dc470 100644 (file)
@@ -48,6 +48,11 @@ void WTextbox::setText(const char* takeText)
   text = takeText;
 }
 
+void WTextbox::setText(const std::string& takeText)
+{
+  text = takeText;
+}
+
 void WTextbox::setForegroundColour(const DrawStyle& fcolour)
 {
   foreColour = fcolour;
index c9b256dcda1f1223890a534dc4b9b2f1662c149f..d499108ba959a470a66f1989221df72e2eeb4ad9 100644 (file)
@@ -32,6 +32,7 @@ class WTextbox : public Boxx
   public:
     WTextbox(const char* ttext = NULL);
     void setText(const char* text);
+    void setText(const std::string& text);
     void draw();
     void setForegroundColour(const DrawStyle& fcolour);
     void setTextPos(int x, int y); // optional