summaryrefslogtreecommitdiff
path: root/mobile_src/Content/ContentUtility.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mobile_src/Content/ContentUtility.cpp')
-rwxr-xr-xmobile_src/Content/ContentUtility.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/mobile_src/Content/ContentUtility.cpp b/mobile_src/Content/ContentUtility.cpp
new file mode 100755
index 0000000..d469192
--- /dev/null
+++ b/mobile_src/Content/ContentUtility.cpp
@@ -0,0 +1,103 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "ContentUtility.h"
+#include <Commons/Regex.h>
+
+
+namespace DeviceAPI {
+namespace Content {
+
+using namespace std;
+using namespace WrtDeviceApis::Commons;
+
+ContentUtility::ContentUtility()
+{
+}
+
+ContentUtility::~ContentUtility()
+{
+}
+
+string ContentUtility::convertUriToPath(const string str)
+{
+ string result;
+ std::string schema ("file://");
+ std::string _str = ContentUtility::ltrim(str);
+
+ std::string _schema = _str.substr(0,schema.size());
+
+ if(_schema == schema)
+ {
+ result = _str.substr(schema.size());
+ }
+ else
+ {
+ result = _str;
+ }
+ return result;
+}
+
+string ContentUtility::convertPathToUri(const string str)
+{
+ string result;
+ std::string schema ("file://");
+ std::string _str = ContentUtility::ltrim(str);
+
+ std::string _schema = _str.substr(0,schema.size());
+
+ if(_schema == schema)
+ {
+ result = _str;
+ }
+ else
+ {
+ result = schema + _str;
+ }
+ return result;
+}
+
+std::string ContentUtility::ltrim(const std::string s)
+{
+ std::string str = s;
+ std::string::iterator i;
+ for (i = str.begin(); i != str.end(); i++) {
+ if (!isspace(*i)) {
+ break;
+ }
+ }
+ if (i == str.end()) {
+ str.clear();
+ } else {
+ str.erase(str.begin(), i);
+ }
+ return str;
+}
+
+bool ContentUtility::checkLocation(double lati, double longi)
+{
+ bool ret = true;
+ if(lati < MIN_LATITUDE || lati > MAX_LATITUDE ||
+ longi < MIN_LONGITUDE || longi > MAX_LONGITUDE){
+ ret = false;
+ }
+ return ret;
+}
+
+
+} // Content
+} // DeviceAPI