It is currently Fri Apr 28, 2017 8:39 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 5 posts ] 
Author Message
 Post subject: Shader VMK 72 - More Gui Loader Code
PostPosted: Mon Feb 16, 2015 9:14 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
The Gui Loader code is expanded to include support for loading Null, GuiImage, GuiLayoutAbsolute, and GuiLayoutGrid objects. The Utility class is updated to support handling conversions from strings to different types of values and types.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 72 - More Gui Loader Code
PostPosted: Thu Jun 18, 2015 11:37 pm 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Hey Everyone,

Been slamming my head for a bit. I went back and was working on the Utilities class to improve some stuff and I've run into a bug I've slammed my head against for 3 hours now. I don't believe I changed anything related to this and have even attempted to load up an old version of Utilities and the bug is still present, but previously had no issues. Additionally I'm having a hard time understanding the error fully outside that it can't find GetValue that is called in StringToValue template function.

Any thoughts would be greatly appreciated.

Error 1 error LNK2019: unresolved external symbol "private: static signed char __cdecl FUtilities::GetValue<signed char>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned __int64 &)" (??$GetValue@C@FUtilities@@CACAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEA_K@Z) referenced in function "private: static bool __cdecl FUtilities::StringToValue<signed char>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,signed char *,unsigned int)" (??$StringToValue@C@FUtilities@@CA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEACI@Z) E:\Programming\ProjectGenesis\Game\ONEngineDebug.lib(Utilities.obj) ProjectGenesis

What I'm gathering is showing is that it can't link FUtilities::GetValue, but it's implemented just like in VMK 72:

Important Header Portion:
private:

   FUtilities() = delete;
   FUtilities(const FUtilities& InRef) = delete;
   FUtilities& operator=(const FUtilities& InRHS) = delete;
   
   template<typename T>
   static bool StringToValue(const std::string& InStr, T* InValue, unsigned InNumValues);

   template<typename T>
   static T GetValue(const std::string& InStr, std::size_t& InRemainder);

}; //Utilities

template<typename T>
static bool FUtilities::StringToValue(const std::string& InStr, T* InValue, unsigned InNumValues) {
   auto NumCommas = std::count(InStr.begin(), InStr.end(), ',');
   if (NumCommas != InNumValues - 1) // Example: If asking for 2 values, should have 1 comma
      return false;

   std::size_t Remainder;
   InValue[0] = GetValue<T>(InStr, Remainder);

   if (InNumValues == 1) {
      if (InStr.size() != Remainder) {
         return false;
      }
   }
   else {
      std::size_t Offset = Remainder;
      if (InStr.at(Offset) != ',')
         return false;

      unsigned LastIndex = InNumValues - 1;
      for (unsigned u = 1; u < InNumValues; ++u) {
         InValue[u] = GetValue<T>(InStr.substr(++Offset), Remainder);
         Offset += Remainder;
         if ((u < LastIndex && InStr.at(Offset) != ',') || (u == LastIndex && Offset != InStr.size())) {
            return false;
         }
      }
   }
   return true;
}


In .cpp file are the three GetValue functions:
template<>
float FUtilities::GetValue(const std::string& InStr, std::size_t& InRemainder) {
   return std::stof(InStr, &InRemainder);
}

template<>
int FUtilities::GetValue(const std::string& InStr, std::size_t& InRemainder) {
   return std::stoi(InStr, &InRemainder);
}

template<>
unsigned FUtilities::GetValue(const std::string& InStr, std::size_t& InRemainder) {
   return std::stoul(InStr, &InRemainder);
}


Offline
 Profile  
 
 Post subject: Re: Shader VMK 72 - More Gui Loader Code
PostPosted: Thu Jun 18, 2015 11:52 pm 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Wow that was rough. Figured out my issue, the template was mapping to an "int8" which I've typedef for smaller storage than the "int" and I didn't have a specific "int8" GetValue.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 72 - More Gui Loader Code
PostPosted: Sun Jun 21, 2015 7:40 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
nice work! The linker error messages are sometimes really hard to decipher as you have experienced :)


Offline
 Profile  
 
 Post subject: Re: Shader VMK 72 - More Gui Loader Code
PostPosted: Sun Jun 21, 2015 9:32 am 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Agreed, linker errors are rough and it seems linker errors associated with templates are even nastier.

I've been going back through some code between your original VMKs and my expansion of the engine after reading portions of Scott Meyer's latest effective modern c++ book to implement as a learning exercise and sometimes you feel you aren't touching a part of the code it shouldn't break.... wrong!

Great book btw, nice new updated items for C++11 and C++14 that follow along with his previous "effective" books.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron