namespace
{
-VisualUrl::Location ResolveLocation( const std::string& url )
+VisualUrl::ProtocolType ResolveLocation( const std::string& url )
{
const char* urlCStr = url.c_str();
const uint32_t length = url.size();
enum { SUFFIX, HASH, HASH_DOT } state = SUFFIX;
char SVG[ 4 ] = { 'g', 'v', 's', '.' };
char GIF[ 4 ] = { 'f', 'i', 'g', '.' };
+ char JSON[ 5 ] = { 'n', 'o', 's', 'j', '.' };
unsigned int svgScore = 0;
unsigned int gifScore = 0;
+ unsigned int jsonScore = 0;
int index = count;
while( --index >= 0 )
{
return VisualUrl::GIF;
}
}
+ if( ( offsetFromEnd < sizeof(JSON) )&&( currentChar == JSON[ offsetFromEnd ] ) )
+ {
+ // early out if JSON as can't be used in N patch for now
+ if( ++jsonScore == sizeof(JSON) )
+ {
+ return VisualUrl::JSON;
+ }
+ }
switch( state )
{
case SUFFIX:
return mType;
}
-VisualUrl::Location VisualUrl::GetLocation() const
+VisualUrl::ProtocolType VisualUrl::GetProtocolType() const
{
return mLocation;
}
return mLocation == VisualUrl::LOCAL;
}
+std::string VisualUrl::GetLocation() const
+{
+ const auto location = mUrl.find( "://" );
+ if( std::string::npos != location )
+ {
+ return mUrl.substr( location + 3u ); // 3 characters forwards from the start of ://
+ }
+ return mUrl;
+}
+
+std::string VisualUrl::CreateTextureUrl( const std::string& location )
+{
+ return "dali://" + location;
+}
+
} // Internal
} // Toolkit