MongoDB  2.7.0
misc.h
1 /* @file misc.h
2 */
3 
4 /*
5  * Copyright 2009 10gen Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #pragma once
21 
22 #include <ctime>
23 #include <limits>
24 #include <string>
25 
26 #include "mongo/platform/cstdint.h"
27 #include "mongo/util/assert_util.h"
28 #include "mongo/util/time_support.h"
29 
30 namespace mongo {
31 
32  // Like strlen, but only scans up to n bytes.
33  // Returns -1 if no '0' found.
34  inline int strnlen( const char *s, int n ) {
35  for( int i = 0; i < n; ++i )
36  if ( !s[ i ] )
37  return i;
38  return -1;
39  }
40 
41 }