You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/01/28 20:04:22 UTC
[2/2] incubator-mynewt-newt git commit: add HasSect() and HasKey()
functions to cfg db
add HasSect() and HasKey() functions to cfg db
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/a7247014
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/a7247014
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/a7247014
Branch: refs/heads/master
Commit: a72470143a9ce6bd1b6ca07904c20fd113e70670
Parents: d1008e6
Author: Sterling Hughes <st...@apache.org>
Authored: Mon Jan 25 17:34:51 2016 -0800
Committer: Sterling Hughes <st...@apache.org>
Committed: Thu Jan 28 11:04:16 2016 -0800
----------------------------------------------------------------------
util/cfgdb.go | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a7247014/util/cfgdb.go
----------------------------------------------------------------------
diff --git a/util/cfgdb.go b/util/cfgdb.go
index e9f079d..0c8dd96 100644
--- a/util/cfgdb.go
+++ b/util/cfgdb.go
@@ -18,8 +18,9 @@ package util
import (
"database/sql"
"fmt"
- _ "github.com/mattn/go-sqlite3"
"log"
+
+ _ "github.com/mattn/go-sqlite3"
)
type CfgDb struct {
@@ -101,6 +102,28 @@ func (c *CfgDb) Init(prefix string, dbPath string) error {
return nil
}
+func (c *CfgDb) HasSect(sect string) bool {
+ _, ok := c.Config[sect]
+ if !ok {
+ return false
+ }
+ return true
+}
+
+func (c *CfgDb) HasKey(sect string, key string) bool {
+ sMap, ok := c.Config[sect]
+ if !ok {
+ return false
+ }
+
+ _, ok = sMap[key]
+ if !ok {
+ return false
+ }
+
+ return true
+}
+
func (c *CfgDb) GetKey(sect string, key string) (string, error) {
sMap, ok := c.Config[sect]
if !ok {