javauis/nokiauiapi_qt/inc/autorelease.h
changeset 79 2f468c1958d0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/javauis/nokiauiapi_qt/inc/autorelease.h	Mon Oct 04 00:10:53 2010 +0300
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Nokia Corporation - initial implementation
+ *******************************************************************************/
+
+#ifndef NOKIAUIAUTORELEASE_H
+#define NOKIAUIAUTORELEASE_H
+
+/**
+ * Helper class to automatically call ReleaseStringChars for a Java
+ * string chars object obtained from a call to GetStringChars.
+ */
+class AutoReleaseStringChars
+{
+public:
+    AutoReleaseStringChars( JNIEnv* aJniEnv, jstring aString, const jchar* aPointer )
+        : mJniEnv( aJniEnv ), mString( aString ), mPointer( aPointer )
+        {}
+    virtual ~AutoReleaseStringChars()
+        {
+        mJniEnv->ReleaseStringChars( mString, mPointer );
+        }
+protected:
+    JNIEnv*      mJniEnv;
+    jstring      mString;
+    const jchar* mPointer;
+};
+
+#endif // NOKIAUIAUTORELEASE_H
+