Changeset 10:ac661f7ddd1b in rrlib_jni


Ignore:
Timestamp:
22.04.2012 19:26:23 (8 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Added conversion function: jstring to std::string.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tJNIConvert.h

    r7 r10  
    100100  return js; 
    101101} 
    102 jstring ToJstring(const finroc::util::tAbstractString& d) 
    103 { 
    104   return ToJstring(d.GetCString()); 
    105 } 
    106102jstring ToJstring(const std::string& d) 
    107103{ 
     
    208204{ 
    209205  return static_cast<jfloat>(v); 
     206} 
     207 
     208std::string ToString(jstring js) 
     209{ 
     210  const jchar* str = tJNIHelper::GetEnv()->GetStringUTFChars(js, NULL); 
     211  assert(str != NULL && "OutOfMemoryError"); 
     212  std::string s(str); 
     213  tJNIHelper::GetEnv()->ReleaseStringUTFChars(js, str); 
     214  return s; 
    210215} 
    211216 
Note: See TracChangeset for help on using the changeset viewer.