コード例 #1
0
ファイル: Config.cpp プロジェクト: DavidXZK/OpenCC
 DictPtr ParseDict(const JSONValue& doc) {
   // Required: type
   string type = GetStringProperty(doc, "type");
   DictPtr dict;
   if (type == "group") {
     list<DictPtr> dicts;
     const JSONValue& docs = GetArrayProperty(doc, "dicts");
     for (rapidjson::SizeType i = 0; i < docs.Size(); i++) {
       if (docs[i].IsObject()) {
         DictPtr dict = ParseDict(docs[i]);
         dicts.push_back(dict);
       } else {
         throw InvalidFormat("Element of the array must be an object");
       }
     }
     return DictGroupPtr(new DictGroup(dicts));
   } else {
     string fileName = GetStringProperty(doc, "file");
     // Read from cache
     DictPtr& cache = dictCache[type][configDirectory][fileName];
     if (cache != nullptr) {
       return cache;
     }
     if (type == "text") {
       dict = LoadDictWithPaths<TextDict>(fileName);
     } else if (type == "ocd") {
       dict = LoadDictWithPaths<DartsDict>(fileName);
     } else {
       throw InvalidFormat("Unknown dictionary type: " + type);
     }
     // Update Cache
     cache = dict;
     return dict;
   }
 }
コード例 #2
0
ファイル: XWindowManager.cpp プロジェクト: jonjahren/unity
std::string XWindowManager::GetWindowName(Window window_id) const
{
  std::string name = GetStringProperty(window_id, atom::_NET_WM_VISIBLE_NAME);

  if (!name.empty())
    return name;

  name = GetStringProperty(window_id, Atoms::wmName);

  if (!name.empty())
    return name;

  return GetStringProperty(window_id, XA_WM_NAME);
}
コード例 #3
0
void FScriptContextBase::FetchScriptPropertyValues(UScriptBlueprintGeneratedClass* Class, UObject* Obj)
{
	// @todo: optimize this
	for (auto Property : Class->ScriptProperties)
	{
		if (UFloatProperty* FloatProperty = Cast<UFloatProperty>(Property))
		{
			float Value = GetFloatProperty(Property->GetName());
			FloatProperty->SetFloatingPointPropertyValue(Property->ContainerPtrToValuePtr<float>(Obj), Value);
		}
		else if (UIntProperty* IntProperty = Cast<UIntProperty>(Property))
		{
			int32 Value = GetIntProperty(Property->GetName());
			IntProperty->SetPropertyValue(Property->ContainerPtrToValuePtr<int32>(Obj), Value);
		}
		else if (UBoolProperty* BoolProperty = Cast<UBoolProperty>(Property))
		{
			bool Value = GetBoolProperty(Property->GetName());
			BoolProperty->SetPropertyValue(Property->ContainerPtrToValuePtr<float>(Obj), Value);
		}
		else if (UObjectProperty* ObjectProperty = Cast<UObjectProperty>(Property))
		{
			UObject* Value = GetObjectProperty(Property->GetName());
			ObjectProperty->SetObjectPropertyValue(Property->ContainerPtrToValuePtr<UObject*>(Obj), Value);
		}
		else if (UStrProperty* StringProperty = Cast<UStrProperty>(Property))
		{
			FString Value = GetStringProperty(Property->GetName());
			StringProperty->SetPropertyValue(Property->ContainerPtrToValuePtr<FString>(Obj), Value);
		}
	}
}
コード例 #4
0
NS_IMETHODIMP nsMsgFolderCacheElement::GetInt32Property(const char *propertyName, PRInt32 *aResult)
{
  NS_ENSURE_ARG_POINTER(propertyName);
  NS_ENSURE_ARG_POINTER(aResult);
  NS_ENSURE_TRUE(m_mdbRow, NS_ERROR_FAILURE);

  nsCString resultStr;
  GetStringProperty(propertyName, resultStr);
  if (resultStr.IsEmpty())
    return NS_ERROR_FAILURE;

  PRInt32 result = 0;
  for (PRUint32 index = 0; index < resultStr.Length(); index++)
  {
    char C = resultStr.CharAt(index);
    PRInt8 unhex = ((C >= '0' && C <= '9') ? C - '0' :
    ((C >= 'A' && C <= 'F') ? C - 'A' + 10 :
     ((C >= 'a' && C <= 'f') ? C - 'a' + 10 : -1)));
    if (unhex < 0)
      break;
    result = (result << 4) | unhex;
  }
  *aResult = result;
  return NS_OK;
}
コード例 #5
0
ファイル: Build.cpp プロジェクト: XilongPei/Elastos5
String Build::GetRadioVersion()
{
    String value = GetStringProperty(
        String("gsm.version.baseband")/*TelephonyProperties.PROPERTY_BASEBAND_VERSION*/,
        String(NULL));
    return value;
}
コード例 #6
0
std::string GetStringProperty(CS_Property property, CS_Status* status) {
  llvm::SmallString<128> buf;
  int propertyIndex;
  auto source = GetPropertySource(property, &propertyIndex, status);
  if (!source) return std::string{};
  return source->GetStringProperty(propertyIndex, buf, status);
}
コード例 #7
0
llvm::StringRef GetStringProperty(CS_Property property,
                                  llvm::SmallVectorImpl<char>& buf,
                                  CS_Status* status) {
  int propertyIndex;
  auto source = GetPropertySource(property, &propertyIndex, status);
  if (!source) return llvm::StringRef{};
  return source->GetStringProperty(propertyIndex, buf, status);
}
コード例 #8
0
ファイル: Build.cpp プロジェクト: XilongPei/Elastos5
Int64 Build::GetInt64(
    /* [in] */ const String& property)
{
    AutoPtr<ISystemProperties> sysProp;
    CSystemProperties::AcquireSingleton((ISystemProperties**)&sysProp);
    String retStr = GetStringProperty(property);
    sysProp->Get(property, UNKNOWN, &retStr);
    if (retStr.Equals(UNKNOWN))
        return -1;

    return StringUtils::ParseInt64(retStr);
}
コード例 #9
0
ファイル: Build.cpp プロジェクト: XilongPei/Elastos5
static Int64 GetInt64Property(
    /* [in] */ const String& property)
{
    AutoPtr<ISystemProperties> sysProp;
    CSystemProperties::AcquireSingleton((ISystemProperties**)&sysProp);
    String retStr = GetStringProperty(property);
    sysProp->Get(property, String("unknown")/*UNKNOWN*/, &retStr);
    if (retStr.Equals("unknown"))
        return -1;

    return StringUtils::ParseInt64(retStr);
}
コード例 #10
0
void ToFCameraMITKPlayerDevice::SetProperty( const char *propertyKey, BaseProperty* propertyValue )
{
  this->m_PropertyList->SetProperty(propertyKey, propertyValue);

  ToFCameraMITKPlayerController::Pointer myController = dynamic_cast<mitk::ToFCameraMITKPlayerController*>(this->m_Controller.GetPointer());

  std::string strValue;
  GetStringProperty(propertyKey, strValue);
  if (strcmp(propertyKey, "DistanceImageFileName") == 0)
  {
    myController->SetDistanceImageFileName(strValue);
  }
  else if (strcmp(propertyKey, "AmplitudeImageFileName") == 0)
  {
    std::ifstream amplitudeImage(strValue.c_str());
    if(amplitudeImage)
    {
      this->m_PropertyList->SetBoolProperty("HasAmplitudeImage", true);
      myController->SetAmplitudeImageFileName(strValue);
    }
    else
    {
      MITK_WARN << "File " << strValue << " does not exist!";
    }
  }
  else if (strcmp(propertyKey, "IntensityImageFileName") == 0)
  {
    std::ifstream intensityImage(strValue.c_str());
    if(intensityImage)
    {
      this->m_PropertyList->SetBoolProperty("HasIntensityImage", true);
      myController->SetIntensityImageFileName(strValue);
    }
    else
    {
      MITK_WARN << "File " << strValue << " does not exist!";
    }
  }
  else if (strcmp(propertyKey, "RGBImageFileName") == 0)
  {
    std::ifstream intensityImage(strValue.c_str());
    if(intensityImage)
    {
      this->m_PropertyList->SetBoolProperty("HasRGBImage", true);
      myController->SetRGBImageFileName(strValue);
    }
    else
    {
      MITK_WARN << "File " << strValue << " does not exist!";
    }
  }
}
コード例 #11
0
  void ToFCameraPMDPlayerDevice::SetProperty(const char* propertyKey, BaseProperty* propertyValue)
  {
    this->m_PropertyList->SetProperty(propertyKey, propertyValue);

    ToFCameraPMDPlayerController::Pointer myController = dynamic_cast<mitk::ToFCameraPMDPlayerController*>(this->m_Controller.GetPointer());

    std::string strValue;
    GetStringProperty(propertyKey, strValue);
    if (strcmp(propertyKey, "PMDFileName") == 0)
    {
      myController->SetPMDFileName(strValue);
    }
  }
コード例 #12
0
ファイル: Config.cpp プロジェクト: DavidXZK/OpenCC
  SegmentationPtr ParseSegmentation(const JSONValue& doc) {
    SegmentationPtr segmentation;

    // Required: type
    string type = GetStringProperty(doc, "type");
    if (type == "mmseg") {
      // Required: dict
      DictPtr dict = ParseDict(GetObjectProperty(doc, "dict"));
      segmentation = SegmentationPtr(new MaxMatchSegmentation(dict));
    } else {
      throw InvalidFormat("Unknown segmentation type: " + type);
    }
    return segmentation;
  }
コード例 #13
0
ファイル: Build.cpp プロジェクト: XilongPei/Elastos5
ECode Build::EnsureFingerprintProperty()
{
    String value = GetStringProperty(String("ro.build.fingerprint"));
    if (value.IsNullOrEmpty()) {
        // try {
        AutoPtr<ISystemProperties> sysProp;
        CSystemProperties::AcquireSingleton((ISystemProperties**)&sysProp);
        sysProp->Set(String("ro.build.fingerprint"), FINGERPRINT);
        // } catch (IllegalArgumentException e) {
        //     Slog.e(TAG, "Failed to set fingerprint property", e);
        // }
    }
    return NOERROR;
}
コード例 #14
0
ファイル: Build.cpp プロジェクト: XilongPei/Elastos5
/**
 * Some devices split the fingerprint components between multiple
 * partitions, so we might derive the fingerprint at runtime.
 */
static String DeriveFingerprint() {
    String finger = GetStringProperty(String("ro.build.fingerprint"));
    if (finger.IsNullOrEmpty()) {
        StringBuilder sb;
        sb += GetStringProperty(String("ro.product.brand"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.product.name"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.product.device"));
        sb.AppendChar(':');
        sb += GetStringProperty(String("ro.build.version.release"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.build.id"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.build.version.incremental"));
        sb.AppendChar(':');
        sb += GetStringProperty(String("ro.build.type"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.build.tags"));
        finger = sb.ToString();
    }
    return finger;
}
コード例 #15
0
  void ToFCameraMITKPlayerDevice::SetProperty( const char *propertyKey, BaseProperty* propertyValue )
  {
    this->m_PropertyList->SetProperty(propertyKey, propertyValue);

    ToFCameraMITKPlayerController::Pointer myController = dynamic_cast<mitk::ToFCameraMITKPlayerController*>(this->m_Controller.GetPointer());

    std::string strValue;
    GetStringProperty(propertyValue, strValue);
    if (strcmp(propertyKey, "DistanceImageFileName") == 0)
    {
      myController->SetDistanceImageFileName(strValue);
    }
    else if (strcmp(propertyKey, "AmplitudeImageFileName") == 0)
    {
      myController->SetAmplitudeImageFileName(strValue);
    }
    else if (strcmp(propertyKey, "IntensityImageFileName") == 0)
    {
      myController->SetIntensityImageFileName(strValue);
    }
  }
コード例 #16
0
XnStatus XnSensorDevice::GetDeviceName(XnChar* strBuffer, XnUInt32& nBufferSize)
{
	return GetStringProperty(XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME, strBuffer, nBufferSize);
}
コード例 #17
0
ファイル: Build.cpp プロジェクト: XilongPei/Elastos5
static String GetStringProperty(
    /* [in] */ const String& property)
{
    return GetStringProperty(property, String("unknown")/*UNKNOWN*/);
}
コード例 #18
0
bool mitk::Annotation::GetName(std::string &nodeName, const std::string &propertyKey) const
{
  return GetStringProperty(propertyKey, nodeName);
}
コード例 #19
0
ファイル: Build.cpp プロジェクト: XilongPei/Elastos5
String Build::GetString(
    /* [in] */ const char* property)
{
    String str(property);
    return GetStringProperty(str, UNKNOWN);
}
コード例 #20
0
ファイル: Build.cpp プロジェクト: XilongPei/Elastos5
String Build::GetString(
    /* [in] */ const String& property)
{
    return GetStringProperty(property, UNKNOWN);
}
コード例 #21
0
std::string mitk::Annotation::GetText() const
{
  std::string text;
  GetStringProperty("Text", text);
  return text;
}
コード例 #22
0
void MemoryCardDriverThreaded_MacOSX::GetUSBStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
{
	LockMut( m_ChangedLock );
	// First, get all device paths
	struct statfs *fs;
	int num = getfsstat( NULL, 0, MNT_NOWAIT );
	
	fs = new struct statfs[num];
	
	num = getfsstat( fs, num * sizeof(struct statfs), MNT_NOWAIT );
	ASSERT( num != -1 );
	
	for( int i = 0; i < num; ++i )
	{
		if( strncmp(fs[i].f_mntfromname, _PATH_DEV, strlen(_PATH_DEV)) )
			continue;
		
		const RString& sDevicePath = fs[i].f_mntfromname;
		const RString& sDisk = Basename( sDevicePath ); // disk#[[s#] ...]
		
		// Now that we have the disk name, look up the IOServices associated with it.
		CFMutableDictionaryRef dict;
		
		if( !(dict = IOBSDNameMatching(kIOMasterPortDefault, 0, sDisk)) )
			continue;
		
		// Look for certain properties: Leaf, Ejectable, Writable.
		CFDictionarySetValue( dict, CFSTR(kIOMediaLeafKey), kCFBooleanTrue );
		CFDictionarySetValue( dict, CFSTR(kIOMediaEjectableKey), kCFBooleanTrue );
		CFDictionarySetValue( dict, CFSTR(kIOMediaWritableKey), kCFBooleanTrue );
		
		// Get the matching iterator. As always, this consumes a reference to dict.
		io_iterator_t iter;
		kern_return_t ret = IOServiceGetMatchingServices( kIOMasterPortDefault, dict, &iter );
		
		if( ret != KERN_SUCCESS || iter == 0 )
			continue;
		
		// I'm not quite sure what it means to have two services with this device.
		// Iterate over them all. If one contains what we want, stop.
		io_registry_entry_t device; // This is the same as an io_object_t.
		
		while( (device = IOIteratorNext(iter)) )
		{
			// Look at the parent of the device until we see an IOUSBMassStorageClass
			while( device != MACH_PORT_NULL && !IOObjectConformsTo(device, "IOUSBMassStorageClass") )
			{
				io_registry_entry_t entry;
				ret = IORegistryEntryGetParentEntry( device, kIOServicePlane, &entry );
				IOObjectRelease( device );
				device = ret == KERN_SUCCESS? entry:MACH_PORT_NULL;
			}
			// Now look for the corresponding IOUSBDevice, it's likely 2 up the tree
			while( device != MACH_PORT_NULL && !IOObjectConformsTo(device, "IOUSBDevice") )
			{
				io_registry_entry_t entry;
				ret = IORegistryEntryGetParentEntry( device, kIOServicePlane, &entry );
				IOObjectRelease( device );
				device = ret == KERN_SUCCESS? entry:MACH_PORT_NULL;
			}
			if( device == MACH_PORT_NULL )
				continue;
			
			// At this point, it is pretty safe to say that we've found a USB device.
			vDevicesOut.push_back( UsbStorageDevice() );
			UsbStorageDevice& usbd = vDevicesOut.back();
			
			LOG->Trace( "Found memory card at path: %s.", fs[i].f_mntonname );
			usbd.SetOsMountDir( fs[i].f_mntonname );
			usbd.iVolumeSizeMB = int( (uint64_t(fs[i].f_blocks) * fs[i].f_bsize) >> 20 );
		
			// Now we can get some more information from the registry tree.
			usbd.iBus = GetIntProperty( device, CFSTR("USB Address") );
			usbd.iPort = GetIntProperty( device, CFSTR("PortNum") );
			// usbd.iLevel ?
			usbd.sSerial = GetStringProperty( device, CFSTR("USB Serial Number") );
			usbd.sDevice = fs[i].f_mntfromname;
			usbd.idVendor = GetIntProperty( device, CFSTR(kUSBVendorID) );
			usbd.idProduct = GetIntProperty( device, CFSTR(kUSBProductID) );
			usbd.sVendor = GetStringProperty( device, CFSTR("USB Vendor Name") );
			usbd.sProduct = GetStringProperty( device, CFSTR("USB Product Name") );
			IOObjectRelease( device );
			break; // We found what we wanted
		}
		IOObjectRelease( iter );
	}
	m_bChanged = false;
	delete[] fs;
}
コード例 #23
0
ファイル: Build.cpp プロジェクト: XilongPei/Elastos5
namespace Os {

static String GetStringProperty(
    /* [in] */ const String& property,
    /* [in] */ const String& defaultValue)
{
    AutoPtr<ISystemProperties> sysProp;
    CSystemProperties::AcquireSingleton((ISystemProperties**)&sysProp);
    String value;
    sysProp->Get(property, defaultValue, &value);
    return value;
}

static String GetStringProperty(
    /* [in] */ const String& property)
{
    return GetStringProperty(property, String("unknown")/*UNKNOWN*/);
}

static AutoPtr<ArrayOf<String> > GetStringPropertyList(
    /* [in] */ const String& property,
    /* [in] */ const String& separator)
{
    AutoPtr<ISystemProperties> sysProp;
    CSystemProperties::AcquireSingleton((ISystemProperties**)&sysProp);
    String value;
    sysProp->Get(property, &value);

    AutoPtr<ArrayOf<String> > array;
    if (value.IsNullOrEmpty()) {
        array = ArrayOf<String>::Alloc(0);
    }
    else {
        StringUtils::Split(value, separator, (ArrayOf<String>**)&array);
    }
    return array;
}

static Int32 GetInt32Property(
    /* [in] */ const String& property)
{
    AutoPtr<ISystemProperties> sysProp;
    CSystemProperties::AcquireSingleton((ISystemProperties**)&sysProp);
    Int32 value;
    sysProp->GetInt32(property, 0, &value);
    return value;
}

static Int64 GetInt64Property(
    /* [in] */ const String& property)
{
    AutoPtr<ISystemProperties> sysProp;
    CSystemProperties::AcquireSingleton((ISystemProperties**)&sysProp);
    String retStr = GetStringProperty(property);
    sysProp->Get(property, String("unknown")/*UNKNOWN*/, &retStr);
    if (retStr.Equals("unknown"))
        return -1;

    return StringUtils::ParseInt64(retStr);
}

static AutoPtr<ArrayOf<String> > InitACTIVE_CODENAMES()
{
    AutoPtr<ArrayOf<String> > all = GetStringPropertyList(String("ro.build.version.all_codenames"), String(","));
    if (all != NULL && all->GetLength() > 0) {
        if ((*all)[0].Equals("REL")) {
            all = ArrayOf<String>::Alloc(0);
        }
    }

    return all;
}

static Int32 InitResourcesSDKInt()
{
    AutoPtr<ArrayOf<String> > array = InitACTIVE_CODENAMES();
    return GetInt32Property(String("ro.build.version.sdk"))
        +  array != NULL ? array->GetLength() : 0;
}

/**
 * Some devices split the fingerprint components between multiple
 * partitions, so we might derive the fingerprint at runtime.
 */
static String DeriveFingerprint() {
    String finger = GetStringProperty(String("ro.build.fingerprint"));
    if (finger.IsNullOrEmpty()) {
        StringBuilder sb;
        sb += GetStringProperty(String("ro.product.brand"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.product.name"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.product.device"));
        sb.AppendChar(':');
        sb += GetStringProperty(String("ro.build.version.release"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.build.id"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.build.version.incremental"));
        sb.AppendChar(':');
        sb += GetStringProperty(String("ro.build.type"));
        sb.AppendChar('/');
        sb += GetStringProperty(String("ro.build.tags"));
        finger = sb.ToString();
    }
    return finger;
}

const String Build::VERSION::INCREMENTAL = GetStringProperty(String("ro.build.version.incremental"));
const String Build::VERSION::RELEASE = GetStringProperty(String("ro.build.version.release"));
const String Build::VERSION::SDK = GetStringProperty(String("ro.build.version.sdk"));
const Int32 Build::VERSION::SDK_INT = GetInt32Property(String("ro.build.version.sdk"));
const String Build::VERSION::CODENAME = GetStringProperty(String("ro.build.version.codename"));
const Int32 Build::VERSION::RESOURCES_SDK_INT = InitResourcesSDKInt();

AutoPtr<ArrayOf<String> > Build::VERSION::ALL_CODENAMES
    = GetStringPropertyList(String("ro.build.version.all_codenames"), String(","));

AutoPtr<ArrayOf<String> > Build::VERSION::ACTIVE_CODENAMES = InitACTIVE_CODENAMES();

const Int32 Build::VERSION_CODES::CUR_DEVELOPMENT;
const Int32 Build::VERSION_CODES::BASE;
const Int32 Build::VERSION_CODES::BASE_1_1;
const Int32 Build::VERSION_CODES::CUPCAKE;
const Int32 Build::VERSION_CODES::DONUT;
const Int32 Build::VERSION_CODES::ECLAIR;
const Int32 Build::VERSION_CODES::ECLAIR_0_1;
const Int32 Build::VERSION_CODES::ECLAIR_MR1;
const Int32 Build::VERSION_CODES::FROYO;
const Int32 Build::VERSION_CODES::GINGERBREAD;
const Int32 Build::VERSION_CODES::GINGERBREAD_MR1;
const Int32 Build::VERSION_CODES::HONEYCOMB;
const Int32 Build::VERSION_CODES::HONEYCOMB_MR1;
const Int32 Build::VERSION_CODES::HONEYCOMB_MR2;
const Int32 Build::VERSION_CODES::ICE_CREAM_SANDWICH;
const Int32 Build::VERSION_CODES::ICE_CREAM_SANDWICH_MR1;
const Int32 Build::VERSION_CODES::JELLY_BEAN;
const Int32 Build::VERSION_CODES::JELLY_BEAN_MR1;
const Int32 Build::VERSION_CODES::JELLY_BEAN_MR2;
const Int32 Build::VERSION_CODES::KITKAT;
const Int32 Build::VERSION_CODES::KITKAT_WATCH;
const Int32 Build::VERSION_CODES::L;
const Int32 Build::VERSION_CODES::LOLLIPOP;

const String Build::TAG("Build");
const String Build::UNKNOWN("unknown");
const String Build::ID = GetStringProperty(String("ro.build.id"));
const String Build::DISPLAY = GetStringProperty(String("ro.build.display.id"));
const String Build::PRODUCT = GetStringProperty(String("ro.product.name"));
const String Build::DEVICE = GetStringProperty(String("ro.product.device"));
const String Build::BOARD = GetStringProperty(String("ro.product.board"));
const String Build::CPU_ABI;
const String Build::CPU_ABI2;
const String Build::MANUFACTURER = GetStringProperty(String("ro.product.manufacturer"));
const String Build::BRAND = GetStringProperty(String("ro.product.brand"));
const String Build::MODEL = GetStringProperty(String("ro.product.model"));
const String Build::BOOTLOADER = GetStringProperty(String("ro.bootloader"));
const String Build::RADIO = GetStringProperty(String("gsm.version.baseband")); ///TelephonyProperties.PROPERTY_BASEBAND_VERSION
const String Build::HARDWARE = GetStringProperty(String("ro.hardware"));
const String Build::SERIAL = GetStringProperty(String("ro.serialno"));
const String Build::TYPE = GetStringProperty(String("user")); //GetStringProperty(String("ro.build.type");
const String Build::TAGS = GetStringProperty(String("ro.build.tags"));
const String Build::FINGERPRINT = DeriveFingerprint();

const Int64 Build::TIME = GetInt64Property(String("ro.build.date.utc")) * 1000;
const String Build::USER = GetStringProperty(String("ro.build.user"));
const String Build::HOST = GetStringProperty(String("ro.build.host"));

AutoPtr<ArrayOf<String> > Build::SUPPORTED_ABIS
    = GetStringPropertyList(String("ro.product.cpu.abilist"), String(","));

AutoPtr<ArrayOf<String> > Build::SUPPORTED_32_BIT_ABIS
    = GetStringPropertyList(String("ro.product.cpu.abilist32"), String(","));

AutoPtr<ArrayOf<String> > Build::SUPPORTED_64_BIT_ABIS
    = GetStringPropertyList(String("ro.product.cpu.abilist64"), String(","));

const Boolean Build::IS_DEBUGGABLE = GetInt32Property(String("ro.debuggable")) == 1;

ECode Build::EnsureFingerprintProperty()
{
    String value = GetStringProperty(String("ro.build.fingerprint"));
    if (value.IsNullOrEmpty()) {
        // try {
        AutoPtr<ISystemProperties> sysProp;
        CSystemProperties::AcquireSingleton((ISystemProperties**)&sysProp);
        sysProp->Set(String("ro.build.fingerprint"), FINGERPRINT);
        // } catch (IllegalArgumentException e) {
        //     Slog.e(TAG, "Failed to set fingerprint property", e);
        // }
    }
    return NOERROR;
}

String Build::GetRadioVersion()
{
    String value = GetStringProperty(
        String("gsm.version.baseband")/*TelephonyProperties.PROPERTY_BASEBAND_VERSION*/,
        String(NULL));
    return value;
}

String Build::GetString(
    /* [in] */ const char* property)
{
    String str(property);
    return GetStringProperty(str, UNKNOWN);
}

Int64 Build::GetInt64(
    /* [in] */ const char* property)
{
    String str(property);
    return GetInt64Property(str);
}

String Build::GetString(
    /* [in] */ const String& property)
{
    return GetStringProperty(property, UNKNOWN);
}

Int64 Build::GetInt64(
    /* [in] */ const String& property)
{
    AutoPtr<ISystemProperties> sysProp;
    CSystemProperties::AcquireSingleton((ISystemProperties**)&sysProp);
    String retStr = GetStringProperty(property);
    sysProp->Get(property, UNKNOWN, &retStr);
    if (retStr.Equals(UNKNOWN))
        return -1;

    return StringUtils::ParseInt64(retStr);
}


} // namespace Os
コード例 #24
0
bool mitk::Overlay::GetName(std::string& nodeName, mitk::BaseRenderer* renderer, const std::string& propertyKey) const
{
  return GetStringProperty(propertyKey, nodeName, renderer);
}
コード例 #25
0
ファイル: nsMsgHdr.cpp プロジェクト: dualsky/FossaMail
NS_IMETHODIMP nsMsgHdr::GetAccountKey(char **aResult)
{
  NS_ENSURE_ARG_POINTER(aResult);

  return GetStringProperty("account", aResult);
}
コード例 #26
0
XnStatus XnSensorDevice::GetVendorSpecificData(XnChar* strBuffer, XnUInt32& nBufferSize)
{
	return GetStringProperty(XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA, strBuffer, nBufferSize);
}
コード例 #27
0
XnStatus XnSensorDevice::GetSerialNumber(XnChar* strBuffer, XnUInt32& nBufferSize)
{
	return GetStringProperty(XN_MODULE_PROPERTY_ID, strBuffer, nBufferSize);
}
コード例 #28
0
ファイル: mitkLabel.cpp プロジェクト: MITK/MITK
std::string mitk::Label::GetName() const
{
    std::string name;
    GetStringProperty("name", name);
    return name;
}
コード例 #29
0
ファイル: mitkCustomTagParser.cpp プロジェクト: Cdebus/MITK
mitk::PropertyList::Pointer mitk::CustomTagParser::ParseDicomPropertyString(std::string dicomPropertyString)
{
  auto results = mitk::PropertyList::New();
  if ("" == dicomPropertyString)
  {
    //MITK_ERROR << "Could not parse empty custom dicom string";
    return results;
  }

  std::map<std::string, std::string> privateParameters;

  // convert hex to ascii
  // the Siemens private tag contains the information like this
  // "43\52\23\34" we jump over each \ and convert the number
  int len = dicomPropertyString.length();
  std::string asciiString;
  for (int i = 0; i < len; i += 3)
  {
    std::string byte = dicomPropertyString.substr(i, 2);
    auto chr = (char)(int)strtol(byte.c_str(), nullptr, 16);
    asciiString.push_back(chr);
  }

  // extract parameter list
  std::size_t beginning = asciiString.find("### ASCCONV BEGIN ###") + 21;
  std::size_t ending = asciiString.find("### ASCCONV END ###");
  std::string parameterListString = asciiString.substr(beginning, ending - beginning);

  boost::replace_all(parameterListString, "\r\n", "\n");
  boost::char_separator<char> newlineSeparator("\n");
  boost::tokenizer<boost::char_separator<char>> parameters(parameterListString, newlineSeparator);
  for (const auto &parameter : parameters)
  {
    std::vector<std::string> parts;
    boost::split(parts, parameter, boost::is_any_of("="));

    if (parts.size() == 2)
    {
      parts[0].erase(std::remove(parts[0].begin(), parts[0].end(), ' '), parts[0].end());
      parts[1].erase(parts[1].begin(), parts[1].begin() + 1); // first character is a space
      privateParameters[parts[0]] = parts[1];
    }
  }

  std::string revisionString = "";

  try
  {
    revisionString = ExtractRevision(privateParameters["tSequenceFileName"]);
  }
  catch (const std::exception &e)
  {
    MITK_ERROR << "Cannot deduce revision information. Reason: "<< e.what();
    return results;
  }

  results->SetProperty(m_RevisionPropertyName, mitk::StringProperty::New(revisionString));

  std::string jsonString = GetRevisionAppropriateJSONString(revisionString);

  boost::property_tree::ptree root;
  std::istringstream jsonStream(jsonString);
  try
  {
    boost::property_tree::read_json(jsonStream, root);
  }
  catch (const boost::property_tree::json_parser_error &e)
  {
    mitkThrow() << "Could not parse json file. Error was:\n" << e.what();
  }

  for (auto it : root)
  {
    if (it.second.empty())
    {
      std::string propertyName = m_CESTPropertyPrefix + it.second.data();
      if (m_JSONRevisionPropertyName == propertyName)
      {
        results->SetProperty(propertyName, mitk::StringProperty::New(it.first));
      }
      else
      {
        results->SetProperty(propertyName, mitk::StringProperty::New(privateParameters[it.first]));
      }
    }
    else
    {
      MITK_ERROR << "Currently no support for nested dicom tag descriptors in json file.";
    }
  }

  std::string offset = "";
  std::string measurements = "";
  results->GetStringProperty("CEST.Offset", offset);
  results->GetStringProperty("CEST.measurements", measurements);

  if ("" == measurements)
  {
    std::string stringRepetitions = "";
    std::string stringAverages = "";
    results->GetStringProperty("CEST.repetitions", stringRepetitions);
    results->GetStringProperty("CEST.averages", stringAverages);
    std::stringstream  measurementStream;
    try
    {
      measurementStream << std::stoi(stringRepetitions) + std::stoi(stringAverages);
      measurements = measurementStream.str();
      MITK_INFO << "Could not find measurements, assuming repetitions + averages. Which is: " << measurements;
    }
    catch (const std::invalid_argument &ia)
    {
      MITK_ERROR
        << "Could not find measurements, fallback assumption of repetitions + averages could not be determined either: "
        << ia.what();
    }
  }

  std::string preparationType = "";
  std::string recoveryMode = "";
  std::string spoilingType = "";
  results->GetStringProperty(CEST_PROPERTY_NAME_PREPERATIONTYPE().c_str(), preparationType);
  results->GetStringProperty(CEST_PROPERTY_NAME_RECOVERYMODE().c_str(), recoveryMode);
  results->GetStringProperty(CEST_PROPERTY_NAME_SPOILINGTYPE().c_str(), spoilingType);

  if (this->IsT1Sequence(preparationType, recoveryMode, spoilingType, revisionString))
  {
    MITK_INFO << "Parsed as T1 image";

    mitk::LocaleSwitch localeSwitch("C");

    std::stringstream trecStream;

    std::string trecPath = m_DicomDataPath + "/TREC.txt";
    std::ifstream list(trecPath.c_str());

    if (list.good())
    {
      std::string currentTime;
      while (std::getline(list, currentTime))
      {
        trecStream << currentTime << " ";
      }
    }
    else
    {
      MITK_WARN << "Assumed T1, but could not load TREC at " << trecPath;
    }

    results->SetStringProperty(CEST_PROPERTY_NAME_TREC().c_str(), trecStream.str().c_str());
  }
  else
  {
    MITK_INFO << "Parsed as CEST or WASABI image";
    std::string sampling = "";
    bool hasSamplingInformation = results->GetStringProperty("CEST.SamplingType", sampling);
    if (hasSamplingInformation)
    {
      std::string offsets = GetOffsetString(sampling, offset, measurements);
      results->SetStringProperty(m_OffsetsPropertyName.c_str(), offsets.c_str());
    }
    else
    {
      MITK_WARN << "Could not determine sampling type.";
    }
  }


  //persist all properties
  mitk::IPropertyPersistence *persSrv = GetPersistenceService();
  if (persSrv)
  {
    auto propertyMap = results->GetMap();
    for (auto const &prop : *propertyMap)
    {
      PropertyPersistenceInfo::Pointer info = PropertyPersistenceInfo::New();
      std::string key = prop.first;
      std::replace(key.begin(), key.end(), '.', '_');
      info->SetNameAndKey(prop.first, key);

      persSrv->AddInfo(info);
    }
  }

  return results;
}