[nnkit] Introduce nnkit_support_cmdline (#1755)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 5 Oct 2018 02:01:11 +0000 (11:01 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 5 Oct 2018 02:01:11 +0000 (11:01 +0900)
* [nnkit] Introduce nnkit_support_cmdline

This commit introduces nnkit_support_cmdline (v0.1) which includes
VectorArguments that implements CmdlineArguments interface.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
* Add missing license notice

contrib/nnkit/libs/support/cmdline/CMakeLists.txt [new file with mode: 0644]
contrib/nnkit/libs/support/cmdline/include/nnkit/VectorArguments.h [new file with mode: 0644]
contrib/nnkit/libs/support/cmdline/src/VectorArguments.cpp [new file with mode: 0644]

diff --git a/contrib/nnkit/libs/support/cmdline/CMakeLists.txt b/contrib/nnkit/libs/support/cmdline/CMakeLists.txt
new file mode 100644 (file)
index 0000000..52419a8
--- /dev/null
@@ -0,0 +1,5 @@
+file(GLOB_RECURSE SOURCES "src/*.cpp")
+
+add_library(nnkit_support_cmdline STATIC ${SOURCES})
+target_include_directories(nnkit_support_cmdline PUBLIC include)
+target_link_libraries(nnkit_support_cmdline PUBLIC nnkit_intf_cmdline)
diff --git a/contrib/nnkit/libs/support/cmdline/include/nnkit/VectorArguments.h b/contrib/nnkit/libs/support/cmdline/include/nnkit/VectorArguments.h
new file mode 100644 (file)
index 0000000..37b0908
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __NNKIT_VECTOR_ARGUMENTS_H__
+#define __NNKIT_VECTOR_ARGUMENTS_H__
+
+#include <nnkit/CmdlineArguments.h>
+
+#include <vector>
+#include <string>
+
+namespace nnkit
+{
+
+class VectorArguments final : public CmdlineArguments
+{
+public:
+  uint32_t size(void) const override { return _args.size(); }
+  const char *at(uint32_t nth) const override { return _args.at(nth).c_str(); }
+
+public:
+  VectorArguments &append(const std::string &arg);
+
+private:
+  std::vector<std::string> _args;
+};
+
+} // namespace nnkit
+
+#endif // __NNKIT_VECTOR_ARGUMENTS_H__
diff --git a/contrib/nnkit/libs/support/cmdline/src/VectorArguments.cpp b/contrib/nnkit/libs/support/cmdline/src/VectorArguments.cpp
new file mode 100644 (file)
index 0000000..f7d5478
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * 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 "nnkit/VectorArguments.h"
+
+namespace nnkit
+{
+
+VectorArguments &VectorArguments::append(const std::string &arg)
+{
+  _args.emplace_back(arg);
+  return (*this);
+}
+
+} // namespace nnkit